Creation Bytecode vs Runtime Bytecode
Nov 6, 2025
Understanding the difference between creation and runtime bytecode is crucial for contract deployment and analysis.
TL;DR
Deployment Input = Creation Bytecode + Constructor Args (ABI-encoded)
└─ From compiler └─ You append this
Creation bytecode does NOT include constructor arguments.
Quick Reference
| Bytecode Type | Contains | Use Case |
|---|---|---|
| Creation | Init logic + Runtime code | forge inspect Contract bytecode |
| Runtime | Final on-chain code | cast code <address> |
Deployment Hex Pattern
0x[CREATION_CODE][CONSTRUCTOR_ARGS]
└─ Fixed length └─ Variable (32 bytes per param)
Example
# Contract: constructor(uint256 supply, address owner)
CREATION=
# 0x608060405234801561001057600080fd5b50...
ARGS=
# 0x00000000000000000000000000000000000000000000000000000000000f4240
# 000000000000000000000000742d35cc6634c0532925a3b844bc454e4438f44e
# Deploy (remove 0x from args)
Hex Breakdown
0x608060405234801561001057600080fd5b50... ← Creation bytecode
00000000000000000000000000000000000000000000000000000000000f4240 ← uint256 (32 bytes)
000000000000000000000000742d35cc6634c0532925a3b844bc454e4438f44e ← address (32 bytes, left-padded)
Clone Existing Contract
Deployment tx input already has both parts - use directly:
# 1. Find deployment tx (Etherscan/Sourcify)
# 2. Extract full bytecode
FULL=
# 3. Deploy (args already included)
Example: Multicall3
# Contract: 0xcA11bde05977b3631167028862bE2a173976CA11
# No constructor args - only creation bytecode
TX="0x4f0a3c5bb2dcb0420c54838830c894f09e10f0e59d91b0d19cb2d4c234cb2c2f"
BYTECODE=
Common Mistakes
# ❌ Using runtime bytecode
# ❌ Forgetting constructor args
# ❌ Not removing 0x prefix
DEPLOY="" # Double 0x
# ✅ Correct
DEPLOY=""
Key Points
-
Creation ≠ Deployment
- Compiler outputs creation bytecode
- You must append ABI-encoded constructor args
-
Constructor args pattern
- Each
uint256/address= 32 bytes (64 hex chars) - Addresses are left-padded with zeros
- Each
-
Cloning contracts
- Get deployment tx input via Sourcify/Etherscan
- Contains both creation code + args, ready to use
-
Why
cast creationfails- Needs RPC trace APIs (rarely available)
- Use block explorers instead
Resources
- Sourcify - Find deployment transactions
- Etherscan - Contract creation info
- Solidity Docs: Contract Creation
- EVM Bytecode
- Foundry Book: Cast Reference