Solidity theorytheory 0/50 · 0%
Deployment · hard

43. Create2 and deterministic addresses

Knowing an address before you deploy.

`CREATE` derives an address from the deployer and nonce; `CREATE2` derives it from the deployer, a salt and the init code hash, so it is predictable and reproducible across chains.

address predicted = address(uint160(uint256(keccak256(abi.encodePacked(
    bytes1(0xff), deployer, salt, keccak256(initCode)
)))));

This powers counterfactual wallets and factories: you can send funds to an address before the contract exists.

Check your understanding

  1. 1. What does CREATE2 depend on?

  2. 2. What is a counterfactual deployment?

  3. 3. Does changing constructor arguments change the CREATE2 address?