Skip to main content

Try it Live

Run Address examples in the interactive playground
This page is a placeholder. All examples on this page are currently AI-generated and are not correct. This documentation will be completed in the future with accurate, tested examples.
View the complete executable example at playground/src/examples/primitives/address/create.ts.

Algorithm

  1. RLP encode sender address and nonce as list: [address, nonce]
  2. Hash with keccak256 producing 32-byte hash
  3. Extract address from last 20 bytes: hash[12:32]
Pseudocode:

Nonce Handling

Nonce encoding: RLP encodes nonce as minimal big-endian bytes (no leading zeros) Examples:
  • Nonce 0 → empty bytes []
  • Nonce 1[0x01]
  • Nonce 127[0x7f]
  • Nonce 255[0xff]
  • Nonce 256[0x01, 0x00]

Complete Example

Use Cases

Predicting Contract Addresses

Calculate address before deployment:

Factory Contracts

Track contract addresses deployed by factory:

Address Validation

Verify contract was deployed by expected address:

CREATE vs CREATE2

FeatureCREATECREATE2
DeterminismNonce-based (sequential)Salt-based (arbitrary)
DependenciesKeccak256, RLPKeccak256 only
Parameters(address, nonce)(address, salt, initCode)
PredictabilityRequires tracking nonceFully deterministic always
RedeploymentDifferent address each timeSame address if inputs identical

Performance

Cryptographic operations:
  • RLP encoding (~O(n) where n = nonce size)
  • keccak256 hash
Bundle size impact: Adds keccak256 + RLP encoder (~10-15 KB total) Dependencies:
  • keccak256 - Hash function for address derivation
  • rlpEncode - RLP encoding for [address, nonce] list
Use Factory API for tree-shakeable builds that inject these dependencies explicitly.

Error Handling

See Also