Overview
Opcode:0xf0
Introduced: Frontier (EVM genesis)
CREATE deploys a new contract by executing initialization code and storing the resulting runtime bytecode. The new contract’s address is deterministically computed from the creator’s address and nonce.
Specification
Stack Input:Behavior
CREATE executes a multi-step deployment process:- Pop stack arguments: value, memory offset, length
- Charge gas: Base 32,000 + init code cost + memory expansion
- Read init code from memory at offset:length
- Compute address:
keccak256(rlp([sender, nonce]))[12:] - Forward gas: Up to 63/64 of remaining gas (EIP-150)
- Execute init code in new context with forwarded gas
- Store runtime code returned by init code (charged 200 gas/byte)
- Push address to stack (0 if deployment failed)
- Refund unused gas from child execution
- Clear return_data on success, set to child output on failure
- Cannot be called in static context (EIP-214)
- Init code executes with empty storage/code
- Nonce incremented before address computation
- Init code size limited to 49,152 bytes (EIP-3860)
- Runtime code size limited to 24,576 bytes (EIP-170)
Examples
Basic Contract Creation
Address Prediction
Factory Contract
Constructor with Arguments
Gas Cost
Total cost: 32,000 + init_code_cost + memory_expansion + deployment_costBase Cost: 32,000 gas
Fixed cost for CREATE operation.Init Code Cost (EIP-3860)
Shanghai+: 2 gas per word (32 bytes)Memory Expansion
Dynamic cost for reading init code from memory:Deployment Cost
Runtime code storage: 200 gas per byte of returned codeGas Forwarding (EIP-150)
Tangerine Whistle+: Forward up to 63/64 of remaining gas:Example Calculation
Common Usage
Contract Factory
Clone Pattern (Minimal Proxy)
Upgradeable Contract
Security
Nonce Prediction
CREATE addresses are predictable - can pre-compute future deployment addresses:Deployment Failure
CREATE returns 0 on failure - must check result:Constructor Reentrancy
Init code can make external calls - reentrancy risk during construction:Gas Griefing
Init code controls gas consumption - griefing risk:Code Size Limits
Init code: Max 49,152 bytes (EIP-3860, Shanghai+) Runtime code: Max 24,576 bytes (EIP-170, Spurious Dragon+)Implementation
References
- Yellow Paper - Section 7 (Contract Creation)
- EIP-150 - Gas cost changes (63/64 rule)
- EIP-170 - Contract code size limit (24,576 bytes)
- EIP-214 - STATICCALL restrictions
- EIP-3860 - Init code size limit (49,152 bytes)
- evm.codes - CREATE - Interactive reference

