The Calldata
is a read-only byte-addressable space where the data parameter of a transaction or call is held. Unlike the Stack, to use this data you have to specify an exact byte offset and number of bytes you want to read. The opcodes related to Calldata provided by EVM are:
• CALLDATASIZE returns the size of transaction data
• CALLDATALOAD imports 32 bytes of transaction data onto the stack
• CALLDATACOPY copies transaction data of a certain number of bytes to
memory
calldata
behaves almost like memory
. It is an unmodifiable and temporary area that can be used to store function arguments. As copying between memory and storage can be quite expensive, specifying a location can be
helpful to control the gas expenditure at times.