Blockchain & Cryptocurrency Glossary

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

  • search-icon Clear Definitions
  • search-icon Practical
  • search-icon Technical
  • search-icon Related Terms

Create2

1 min read
Pronunciation
[kree-eyt too]
Analogy
Imagine reserving a specific P.O. Box number *before* you even set up your office. With the old deployment method (`CREATE`), your P.O. Box number depended on how many other boxes you had already opened (your nonce). With `CREATE2`, you can calculate a specific, predictable P.O. Box number using your name (deployer address), a chosen secret code (salt), and the blueprint of your office (init code hash). You can give this number out, and anyone can be sure that *if* an office is ever set up at that P.O. Box using those specific ingredients, it will be the one you intended.
Definition
An opcode (operation code) in the Ethereum Virtual Machine (EVM) introduced in EIP-1014 that allows smart contracts to be deployed to addresses that can be pre-determined before deployment. The address depends on the deployer's address, a salt value, and the hash of the contract's initialization code, rather than just the deployer's address and nonce.
Key Points Intro
`CREATE2` enables counterfactual deployment and deterministic contract addresses.
Key Points

Allows prediction of a contract's address before it is actually deployed.

The address depends on: the deployer address, a salt (a 32-byte value chosen by the deployer), and the hash of the contract's creation bytecode.

Enables 'counterfactual instantiation' - interacting with an address that doesn't yet have code, with the assurance that if code is ever deployed there with the right parameters, it will be the expected code.

Useful for state channel setups, layer 2 scaling solutions, and certain smart contract wallet designs.

Example
A Layer 2 system might use `CREATE2` to guarantee that users can always deploy a withdrawal contract at a specific, predictable address on Layer 1 to reclaim their funds, even if the Layer 2 operator becomes unresponsive. Users can interact with this predetermined address.
Technical Deep Dive
The `CREATE2` opcode (0xF5) calculates the deployment address as `keccak256(0xFF + sender_address + salt + keccak256(init_code))[12:]`. The `0xFF` prefix prevents collision with addresses generated by the original `CREATE` opcode (which depends on `sender_address` and `nonce`). The `salt` allows the same deployer to deploy the same code multiple times at different predictable addresses by changing the salt. If a contract is deployed using `CREATE2` to an address that already has code or a non-zero nonce, the deployment fails.
Security Warning
While powerful, `CREATE2` needs careful handling. If the `salt` or `init_code` is not managed correctly, it could lead to unexpected deployment outcomes or prevent deployment entirely. Its primary use cases often involve complex layer 2 or state channel interactions.

Create2 - Related Articles

No related articles for this term.