Crypto glossary

Calldata

Definition

Calldata is the input data of an Ethereum transaction: it tells a smart contract which function to run and with what arguments.

Every Ethereum transaction carries a data field called calldata. When the transaction calls a contract, the first four bytes select the function and the rest encodes the arguments under the ABI rules. Contracts can read calldata but not modify it, which makes it cheaper than copying data into memory or storage. Each byte is charged gas, with zero bytes costing less than non-zero ones.

Because calldata is stored permanently in the chain's history, early rollups posted their compressed transaction batches there to guarantee data availability. That made calldata the largest cost of using a layer 2 until the Dencun upgrade in March 2024 introduced blobs, a separate and much cheaper data space, and most rollups migrated to it.

Calldata is public: anyone can decode it with a block explorer, so it should never contain secrets. Pectra later raised the minimum cost for transactions that are mostly data, nudging bulk data toward blobs. When reading a suspicious transaction, the decoded calldata shows what a signature really authorises, for example an unlimited token approval.

Example

Before signing, a user checks the decoded calldata in their wallet and sees the call is approve(spender, max uint256), an unlimited allowance rather than the simple swap they expected.

Related terms