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/create2.ts.

Algorithm

  1. Hash init code: initCodeHash = keccak256(initCode)
  2. Concatenate data: data = 0xff ++ sender (20 bytes) ++ salt (32 bytes) ++ initCodeHash (32 bytes)
  3. Hash and extract: address = keccak256(data)[12:32]
Pseudocode:
Total data size: 1 + 20 + 32 + 32 = 85 bytes

Salt Formats

Bigint salt: Converted to 32-byte big-endian:
Uint8Array salt: Must be exactly 32 bytes:
Hex salt: Convert from hex string:

Complete Example

Use Cases

Deterministic Deployments

Deploy to same address across different chains:

Counterfactual Addresses

Interact with contract before deployment:

Vanity Addresses

Generate addresses with specific patterns:

Upgradeable Proxies

Deploy proxies to deterministic addresses:

EIP-1014

CREATE2 was introduced in EIP-1014 to enable:
  • Deterministic addresses independent of nonce
  • Counterfactual interactions (interact before deployment)
  • State channels with guaranteed addresses
  • Cross-chain consistency (same address on different chains)

CREATE vs CREATE2

FeatureCREATECREATE2
Formulakeccak256(rlp([addr, nonce]))[12:]keccak256(0xff ++ addr ++ salt ++ keccak256(code))[12:]
ParametersDeployer, nonceDeployer, salt, init code
DeterminismSequential (nonce-based)Arbitrary (salt-based)
RedeploymentDifferent addressSame address if inputs identical
Cross-chainDifferent addressesSame address possible

Performance

Cryptographic operations:
  • Two keccak256 hashes (init code + final data)
  • No RLP encoding required
Bundle size impact: Adds keccak256 (~5-10 KB)

Error Handling

See Also