Skip to main content
CallData is the data payload sent with Ethereum transactions to invoke smart contract functions. Understanding how calldata works is essential for working with smart contracts.

What is CallData?

Transaction calldata contains:
  1. Function Selector (4 bytes) - Identifies which function to call
  2. Encoded Parameters (variable length) - ABI-encoded function arguments

Example: ERC20 Transfer

Calling transfer(address to, uint256 amount):

Function Selectors

The function selector is the first 4 bytes of the keccak256 hash of the function signature:

Canonical Function Signatures

Function signatures must follow strict formatting:
  • No spaces: transfer(address,uint256) ✅ not transfer(address, uint256)
  • Full type names: uint256 ✅ not uint
  • No parameter names: (address,uint256) ✅ not (address to, uint256 amount)

How the EVM Processes CallData

The EVM does not automatically decode calldata. Contract bytecode manually reads calldata using specialized opcodes.

1. Transaction Arrives

2. EVM Loads Contract Bytecode

3. Bytecode Dispatcher Runs

Solidity compilers generate a “dispatcher” that reads the selector and jumps to the appropriate function:

4. Function Code Reads Parameters

When execution jumps to the transfer function:

EVM Opcodes for CallData

The EVM provides three opcodes for accessing calldata:

CALLDATALOAD

Loads 32 bytes from calldata starting at offset:

CALLDATASIZE

Returns the total size of calldata in bytes:

CALLDATACOPY

Copies calldata to memory:

CallData vs Bytecode

Gas Costs

CallData has specific gas costs (post-EIP-2028):
  • Zero bytes: 4 gas per byte
  • Non-zero bytes: 16 gas per byte
This incentivizes compression and efficient encoding:

Special Cases

Empty CallData

Sending ETH to an EOA or calling fallback/receive functions:

Constructor CallData

Contract deployment transactions contain bytecode + constructor parameters:

See Also