Overview
Opcode:0x36
Introduced: Frontier (EVM genesis)
CALLDATASIZE pushes the byte length of the call data (input data) onto the stack.
Specification
Stack Input:Behavior
CALLDATASIZE returns the total number of bytes in the call data, including function selector. Key characteristics:- Returns exact byte count
- Includes 4-byte function selector (if present)
- Always >= 0
- Constant throughout execution
Examples
Basic Usage
Validation
Gas Cost
Cost: 2 gas (GasQuickStep) Same as ADDRESS, ORIGIN, CALLER, etc.Common Usage
Bounds Checking
Copying Entire Calldata
Security
Safe opcode, no vulnerabilities.Implementation
- TypeScript
References
- Yellow Paper - Section 9.1
- EVM Codes - CALLDATASIZE

