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: 0x35
Introduced: Frontier (EVM genesis)
CALLDATALOAD reads 32 bytes from the call data (input data passed to the contract) starting at a specified offset. Bytes beyond call data bounds are zero-padded.
Specification
Stack Input:
Stack Output:
Gas Cost: 3 (GasFastestStep)
Operation:
Behavior
CALLDATALOAD loads exactly 32 bytes from call data, reading from the specified byte offset. If the offset extends beyond call data, the remaining bytes are padded with zeros.
Key characteristics:
- Always returns 32 bytes (256 bits)
- Zero-pads when offset + 32 > calldata.length
- Big-endian byte order
- Does not revert on out-of-bounds access
Examples
Basic Usage
Function Arguments
Zero Padding
Gas Cost
Cost: 3 gas (GasFastestStep)
CALLDATALOAD shares the same cost tier with:
- ADD, SUB (0x01, 0x03): 3 gas
- NOT, ISZERO (0x19, 0x15): 3 gas
- Comparison operations: 3 gas
Comparison:
- CALLDATALOAD (read 32 bytes): 3 gas
- CALLDATACOPY (copy N bytes): 3 + memory + copy cost
- MLOAD (read from memory): 3 gas
Common Usage
Manual ABI Decoding
Dynamic Array Length
Calldata Validation
Security
Out-of-Bounds Reading
Function Selector Validation
Calldata Bounds Check
Implementation
Edge Cases
Offset Beyond Calldata
Partial Overlap
Zero Offset Empty Calldata
Maximum Offset
References