The Ethereum Virtual Machine

CREATE2

CREATE2 is an opcode for deploying a contract to an address you can compute in advance — before the contract exists, and even before the deploying account has ever acted. The original CREATE opcode derives a new contract's address from the deployer's address and its current nonce, so the address depends on transaction history and is hard to predict. CREATE2 instead derives the address purely from inputs you control, making deployment addresses fully deterministic.

The address is the last 20 bytes of keccak256(0xff ++ deployerAddress ++ salt ++ keccak256(initCode)), where salt is an arbitrary 32-byte value you pick and initCode is the contract's creation bytecode. The 0xff prefix domain-separates it from CREATE addresses. Because every input is known ahead of time, anyone can calculate exactly where a given contract will live without deploying it — the address is a function of the code and the salt, not of when or in what order deployment happens.

This unlocks 'counterfactual' deployment: you can treat a contract as if it already exists, send funds to its precomputed address, and only actually deploy the bytecode there later, on demand, when someone needs to interact with it. Account-abstraction and smart-contract wallets lean on this heavily — a user can be handed a wallet address to receive funds immediately, with the wallet contract deployed lazily the first time it transacts, saving gas for accounts that are never used. The same salt-and-code recipe also yields identical contract addresses across different chains.

There is a sharp safety caveat. The address commits to keccak256(initCode), so deploying different bytecode requires a different salt — but a contract deployed via CREATE2 could historically be SELFDESTRUCTed and a new contract redeployed to the very same address with the same salt but different code (the 'metamorphic contract' trick), letting code at a trusted address silently change. The deprecation of SELFDESTRUCT has largely closed this loophole, but it remains a cautionary tale about assuming code at an address is fixed.

address = keccak256(0xff ++ deployer ++ salt ++ keccak256(init_code))[12:]

The deployed address is fully determined by the deployer, salt, and init code.