Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
LABS
Glossary

Calldata

Calldata is the immutable, non-executable data field of an Ethereum transaction, primarily used to pass input arguments to smart contract functions and as a low-cost data layer for rollups.
Chainscore © 2026
definition
BLOCKCHAIN GLOSSARY

What is Calldata?

A technical definition of calldata, the immutable input data for smart contract function execution on the Ethereum Virtual Machine (EVM).

Calldata is the immutable, read-only input data passed to a smart contract during a transaction or message call on the Ethereum Virtual Machine (EVM) and compatible blockchains. It is a byte array located in a transaction's data field that specifies which function to execute and includes the encoded arguments for that function. Unlike contract storage, calldata is non-persistent and exists only for the duration of the external call, making it a gas-efficient location for passing function parameters, especially when those parameters are only needed for computation and not for storage.

The structure of calldata is defined by the Ethereum ABI (Application Binary Interface) specification. The first four bytes are a function selector, a hash of the function's signature that uniquely identifies the intended function within the contract. The remaining bytes contain the arguments, each padded to 32 bytes and concatenated in order. When a contract is called, the EVM loads this data, allowing the contract's logic to decode and use the provided inputs. This mechanism is fundamental to all contract-to-contract and external-actor-to-contract interactions.

Using calldata has significant implications for gas optimization. For external functions, parameters stored in calldata are cheaper than parameters stored in memory. Therefore, developers declare function parameters as calldata instead of memory when the function does not need to modify the input data. This is a critical optimization for reducing transaction costs, particularly for functions that handle large arrays or complex data structures passed from an external caller.

Calldata is distinct from other data locations in Solidity: storage (persistent on-chain), memory (temporary, mutable), and stack (EVM opcode handling). It is also different from a transaction's other core fields, such as to (recipient address), value (attached ether), and gasLimit. In the context of Layer 2 solutions and rollups, calldata is especially important, as posting compressed calldata to Layer 1 is a primary method for ensuring data availability and security in optimistic rollups like Arbitrum and Optimism.

how-it-works
BLOCKCHAIN DATA PRIMER

How Calldata Works

A technical breakdown of calldata, the immutable data payload used to execute functions on the Ethereum Virtual Machine (EVM).

Calldata is the immutable, read-only data payload sent with a transaction to specify which smart contract function to call and with what arguments. It is the primary input mechanism for interacting with smart contracts on Ethereum and other EVM-compatible blockchains. When you initiate a transaction—such as swapping tokens or minting an NFT—the details of that action are encoded into a byte sequence and placed in the transaction's data field, which the network refers to as calldata.

The structure of calldata is defined by the Ethereum ABI (Application Binary Interface) specification. It begins with a 4-byte function selector, a hash of the function's signature that tells the EVM which function to execute. This is followed by the encoded arguments for that function, padded to 32-byte words. For example, a call to a transfer(address to, uint256 amount) function would have its selector followed by the 32-byte representation of the recipient's address and the token amount.

A key characteristic of calldata is its immutability and low-cost storage. Unlike data stored in contract memory (memory) or storage (storage), calldata resides directly within the transaction and cannot be modified by the contract. Historically, it was also a significantly cheaper location to read from, especially before Ethereum's EIP-4844 introduced blob transactions, which provided an even more cost-effective data availability layer for rollups.

Within a Solidity smart contract, calldata is accessed via the calldata data location. Function parameters marked as calldata (e.g., function process(bytes calldata input)) provide gas efficiency, as the data is read directly from the transaction without needing to be copied to memory first. Understanding this distinction is crucial for optimizing gas costs, particularly when handling large arrays or bytes data.

The role of calldata extends beyond simple contract calls. It is foundational for delegate calls, where one contract executes code from another while preserving the original contract's context; the calldata is passed directly to the delegated logic. Furthermore, Layer 2 rollups like Optimism and Arbitrum originally used calldata as their primary data availability layer, posting batched transaction data to Ethereum Mainnet—a practice that evolved with the adoption of blob transactions for greater scalability.

key-features
EVM EXECUTION

Key Features of Calldata

Calldata is the primary mechanism for passing immutable input data to smart contracts on the Ethereum Virtual Machine (EVM). These features define its role in transaction execution and cost structure.

01

Immutable Input Data

Calldata is a read-only, non-modifiable byte array that contains the arguments passed to a smart contract function. It is the primary input mechanism for contract execution. Key characteristics include:

  • Immutable: The executing contract cannot alter the calldata.
  • External Visibility: It is accessible via the global msg.data variable and the abi.decode() function.
  • Function Selector: The first 4 bytes are the function selector, a hash of the function signature used to route the call.
02

Gas Cost Structure

Post-EIP-2028, calldata is the cheapest data location to publish on-chain for contract calls, significantly cheaper than storing data in contract memory or storage. The gas cost is:

  • Non-zero bytes: 16 gas per byte.
  • Zero bytes: 4 gas per byte.
  • This incentivizes data compression (e.g., using more zero bytes) and makes calldata the preferred location for passing large amounts of input data in a transaction, especially for Layer 2 rollups which batch transactions.
03

ABI Encoding Standard

Calldata must be formatted according to the Ethereum Application Binary Interface (ABI) specification. This encoding standard defines how to:

  • Pack arguments (e.g., uint256, address, arrays) into a contiguous byte array.
  • Generate the 4-byte function selector from the function signature (e.g., transfer(address,uint256)).
  • Handle dynamic types like string and bytes using offsets and length prefixes. Tools like web3.js and ethers.js libraries handle this encoding automatically for developers.
04

`msg.data` & `abi.decode`

Within a smart contract, the incoming calldata is accessed through specific global variables and functions:

  • msg.data (bytes): The complete calldata byte array, including the function selector.
  • msg.sig (bytes4): The first 4 bytes of msg.data, representing the function selector.
  • abi.decode(): A built-in function used to decode the ABI-encoded arguments from the calldata into Solidity data types, typically used with msg.data[4:] to skip the selector.
05

Use Case: Optimistic Rollups

Optimistic Rollups (e.g., Arbitrum, Optimism) heavily leverage calldata's low gas cost. Their core scaling mechanism involves:

  • Batching: Thousands of L2 transactions are compressed and their calldata is posted to L1 Ethereum as part of a rollup batch.
  • Data Availability: This published calldata serves as the cryptographic commitment and data availability layer, allowing anyone to reconstruct the L2 state and challenge invalid state transitions.
  • Cost Efficiency: Using calldata instead of other storage locations is critical for keeping L2 transaction fees low.
06

Comparison to `memory` & `storage`

Calldata is one of three primary data locations in Solidity, each with distinct costs and mutability:

  • calldata: Read-only, external input. Cheapest to receive, cannot be modified.
  • memory: Mutable, temporary storage. More expensive to allocate and write to than reading calldata.
  • storage: Persistent, on-chain state. Most expensive to read from and write to (SSTORE opcode). A best practice is to use calldata for function parameters when the function does not need to modify them.
ecosystem-usage
CALDATA

Ecosystem Usage

Calldata is the primary mechanism for transmitting function calls and their arguments in Ethereum transactions. Its usage is fundamental to smart contract interaction and has significant implications for gas costs and data availability.

01

Function Execution & ABI Encoding

Calldata is the input data for a smart contract function call. It contains the function selector (a hash of the function signature) and the ABI-encoded arguments. This encoded data tells the EVM exactly which function to execute and with what parameters. For example, a call to a token's transfer(address to, uint256 amount) function will have its selector and encoded recipient address and amount in the calldata.

02

Gas Cost Dynamics (Pre- & Post-EIP-4844)

Historically, calldata was expensive, costing 16 gas per non-zero byte and 4 gas per zero byte. This made it costly for layer-2 rollups to post transaction data. EIP-4844 (Proto-Danksharding) introduced blob-carrying transactions, which provide a new, much cheaper data location for rollups. Blobs are priced separately in a fee market, drastically reducing the cost of data availability for L2s while keeping execution layer calldata for direct contract calls.

03

Primary Use Case: Layer-2 Data Publishing

The largest consumer of calldata is Optimistic Rollups and ZK-Rollups. They batch thousands of transactions, compress them, and publish the data as calldata to Ethereum Mainnet. This allows anyone to reconstruct the L2 state and verify correctness (fraud proofs) or validity (ZK proofs). Post-EIP-4844, this data is increasingly published to blobs, but calldata remains the fallback mechanism and is still used for direct contract interactions on L1.

04

`calldata` vs. `memory` vs. `storage`

In Solidity, function parameters with complex types (like arrays, structs) can be marked with a data location:

  • calldata: Read-only, external function parameters. Most gas-efficient for external calls.
  • memory: Mutable, temporary storage. Used for internal function parameters and variables.
  • storage: Persistent, on-chain state. Reading/writing is very gas-intensive. Using calldata for external functions avoids unnecessary copies, optimizing gas usage.
05

Calldata in Event Logs & Indexing

While event logs (emit) are the primary method for off-chain indexing, calldata itself is inspectable on-chain. Contracts can use assembly (msg.data) or libraries to parse raw calldata. Off-chain, explorers and indexers decode the calldata using the contract's Application Binary Interface (ABI) to present human-readable transaction details, showing the function called and arguments passed.

06

Security Considerations

Calldata is a direct user input vector and must be rigorously validated. Key risks include:

  • Signature Replay: Calldata containing a signature must include a nonce or chain ID.
  • Integer Overflows/Underflows: ABI-decoded integers must be bounds-checked.
  • Function Selector Clashing: Maliciously crafted calldata can call unexpected functions if selectors are not properly validated in fallback or receive functions.
  • Gas Griefing: Large calldata can increase gas costs for downstream operations.
calldata-vs-other-data
EVM STORAGE PRIMER

Calldata vs. Other Data Locations

A technical comparison of the primary data storage locations within the Ethereum Virtual Machine (EVM), focusing on their cost, mutability, and lifecycle.

Calldata is a read-only, non-persistent data location in the Ethereum Virtual Machine (EVM) that contains the arguments passed to a function during an external call. It is the cheapest data location to use for function inputs, as it exists only for the duration of the call and its gas cost scales linearly with non-zero bytes, making zero bytes exceptionally cheap. This makes calldata the optimal choice for passing large arrays or raw data that the function only needs to read, such as digital signatures or Merkle proofs, without incurring high storage or memory costs.

In contrast, memory is a temporary, mutable data location that is erased between external calls. While reading from memory is inexpensive, writing to it has a moderate gas cost. Memory is typically used for variables declared within a function, for manipulating data loaded from calldata, or for constructing arguments for internal function calls. Unlike calldata, memory can be written to, but its contents are not persistent. The key distinction is that function parameters of reference type (like arrays or structs) must be explicitly marked as calldata to be stored there; otherwise, they default to memory and trigger a copy from the incoming calldata, wasting gas.

Storage is the persistent, on-chain data location that maps to state variables in a smart contract. It is the most expensive location to read from and write to, with operations costing thousands of gas. Data in storage persists across transactions and is permanently recorded on the blockchain. It is used for the core state of a contract, such as token balances or governance settings. Choosing between calldata, memory, and storage is a fundamental gas optimization: use calldata for immutable inputs, memory for intermediate computation, and storage only for data that must survive the transaction.

rollup-data-availability
DATA AVAILABILITY MECHANISM

Calldata as Rollup Data Availability

An explanation of how Ethereum transaction calldata is used as a cost-effective data availability layer for optimistic rollups.

In the context of optimistic rollups, calldata refers to the practice of posting transaction data from the rollup's sequencer onto the Ethereum mainnet as part of a regular transaction's input data field. This mechanism provides the data availability guarantee required for the rollup's security model, allowing any party to reconstruct the rollup's state and challenge invalid state transitions during the dispute window. By using calldata, rollups leverage Ethereum's existing security and decentralization while minimizing costs compared to storing data directly in contract storage.

The technical implementation involves the rollup's sequencer batching hundreds of L2 transactions, compressing the data, and publishing it as the data payload of an Ethereum transaction. This data is permanently recorded on-chain and is immutable and publicly verifiable. For an optimistic rollup like Optimism or Arbitrum, this published calldata is the cryptographic commitment to the rollup's state transitions. Without this data being available, verifiers would be unable to compute the correct state or submit fraud proofs, breaking the rollup's security.

A key advantage of using calldata is its historical cost efficiency. Ethereum's gas pricing historically made calldata (especially non-zero bytes) significantly cheaper than contract storage operations. This economic incentive drove its adoption as the primary DA solution for early optimistic rollups. However, its cost is variable and subject to mainnet congestion. This volatility led to the exploration and development of alternative data availability solutions like blobs introduced by EIP-4844 and dedicated DA layers.

The shift from pure calldata is exemplified by Ethereum's Proto-Danksharding upgrade (EIP-4844), which introduced blob-carrying transactions. Blobs provide a dedicated, large, and temporary data space that is much cheaper than calldata for rollup data. While calldata remains a functional and fully secure DA layer, modern rollup architectures are increasingly migrating to blobs to achieve lower transaction fees while maintaining the same level of data availability security on Ethereum.

From a security perspective, the use of calldata ensures trust minimization. The Data Availability Committee (DAC) model, used by some early scaling solutions, is not required because the data is unconditionally available on-chain. This aligns with Ethereum's credible neutrality and allows for permissionless verification. The guarantee that data cannot be withheld is fundamental to the fraud proof mechanism in optimistic rollups and the validity proof system in zk-rollups that may also use calldata for input data.

CALDATA

Frequently Asked Questions

Calldata is a critical, cost-efficient data location in Ethereum transactions. These questions cover its technical function, optimization strategies, and role in scaling.

Calldata is a read-only, non-persistent data location that contains the arguments passed to a smart contract function during an external call or transaction. It is the primary mechanism for sending input data to a contract, such as function selectors and parameters. Unlike contract storage, calldata is not stored on-chain after execution, making it a gas-efficient way to pass information. On Ethereum, accessing calldata is cheaper than accessing memory for certain operations, especially post-EIP-2929. It is a key component of the Ethereum Virtual Machine (EVM) execution model, fundamental to all contract interactions.

ENQUIRY

Get In Touch
today.

Our experts will offer a free quote and a 30min call to discuss your project.

NDA Protected
24h Response
Directly to Engineering Team
10+
Protocols Shipped
$20M+
TVL Overall
NDA Protected Directly to Engineering Team
Calldata: Definition & Role in Ethereum & Rollups | ChainScore Glossary