Overview
Opcode:0x3b
Introduced: Frontier (EVM genesis)
EXTCODESIZE returns the size in bytes of the code stored at a given address.
Specification
Stack Input:- Frontier: 20 gas
- Tangerine Whistle (EIP-150): 700 gas
- Berlin (EIP-2929): 2600 gas (cold) / 100 gas (warm)
Behavior
Returns the bytecode length of the account at the given address. Returns 0 for:- EOAs (externally owned accounts)
- Non-existent accounts
- Contracts during construction (before constructor completes)
Examples
Basic Usage
Contract Detection
Constructor Bypass
Gas Cost
Historical evolution:| Hardfork | Cold | Warm |
|---|---|---|
| Frontier | 20 | - |
| Tangerine Whistle | 700 | - |
| Berlin | 2600 | 100 |
Common Usage
Proxy Implementation Check
Security
Constructor Bypass
During construction, EXTCODESIZE returns 0:Better Pattern
Use tx.origin check or whitelist:Implementation
- TypeScript
References
- Yellow Paper - Section 9.1
- EVM Codes - EXTCODESIZE
- EIP-150 - Gas cost changes
- EIP-2929 - Access lists

