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.
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:
Stack Output:
Gas Cost: 32,000 + init_code_cost + memory_expansion + deployment_cost
Operation:
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
Key rules:
- 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_cost
Base Cost: 32,000 gas
Fixed cost for CREATE operation.
Init Code Cost (EIP-3860)
Shanghai+: 2 gas per word (32 bytes)
Pre-Shanghai: No init code cost.
Memory Expansion
Dynamic cost for reading init code from memory:
Deployment Cost
Runtime code storage: 200 gas per byte of returned code
Gas Forwarding (EIP-150)
Tangerine Whistle+: Forward up to 63/64 of remaining gas:
Pre-Tangerine Whistle: Forward all remaining gas after charging.
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:
Risk: Attacker can pre-compute addresses and exploit race conditions.
Mitigation: Use CREATE2 if address unpredictability is required.
Deployment Failure
CREATE returns 0 on failure - must check result:
Constructor Reentrancy
Init code can make external calls - reentrancy risk during construction:
Mitigation: Use reentrancy guards, check-effects-interactions.
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