Home

calldata

Calldata is a data location in Solidity that refers to the function call data passed to an external function. It is a read-only, non-persistent region that exists only for the duration of the call and contains the ABI-encoded arguments of that call. Calldata is intended for inputs, not for storage.

Calldata is cheaper than memory for external inputs because it avoids copying data. Accessing elements of calldata

Usage: You typically declare external functions with reference types (such as strings or arrays) marked as calldata

Calldata contains the input data for the call: the function selector (the first four bytes) plus the

does
not
allocate
memory;
however,
it
is
immutable
within
the
function.
If
the
function
needs
to
modify
the
values,
the
data
must
first
be
copied
into
memory
or
another
storage
location.
to
avoid
copies,
for
example:
function
batchTransfer(address
recipient,
uint[]
calldata
amounts)
external;
In
internal
or
public
calls,
data
are
usually
handled
in
memory,
and
changes
require
copying.
ABI-encoded
arguments.
It
differs
from
memory
(modifiable)
and
storage
(persistent)
and
is
most
useful
when
inputs
are
large
or
numerous.