Overview
Opcode:0x37
Introduced: Frontier (EVM genesis)
CALLDATACOPY copies a specified range of call data bytes to memory. Out-of-bounds bytes are zero-padded.
Specification
Stack Input:Behavior
Copieslength bytes from calldata starting at offset to memory starting at destOffset. Zero-pads if calldata bounds exceeded.
Examples
Basic Copy
Proxy Pattern
Gas Cost
Base: 3 gas Memory expansion: Variable Copy cost: 3 gas per 32-byte word (rounded up)Common Usage
Forwarding Calls
Security
Bounds Validation
Check offsets don’t overflow when adding length.Implementation
- TypeScript
References
- Yellow Paper - Section 9.1
- EVM Codes - CALLDATACOPY

