From the docs:
calldata is a special data location that contains the function arguments, only available for external function call parameters.
Every reference type, i.e. arrays and structs, has an additional annotation, the “data location”, about where it is stored. There are three data locations: memory, storage and calldata. Calldata is only valid for parameters of external contract functions and is required for this type of parameter. Calldata is a non-modifiable, non-persistent area where function arguments are stored, and behaves mostly like memory.
calldata is the input data to a transaction on a function. For example, if you look at this transaction, you will see that the
calldata is as follows:
Say if we have a smart contract, we called method1, and then call method2 which contains assembly with calldataload. will this calldataload load the input of method2 or method1?
If those two method calls are different, then the
calldata for each transaction will be different. The
method1() will simply be the input params (in the format seen above) for that method, and the
method2() will simply be the input params for that method.
If the two methods interact on the contract, whichever method is called in the transaction will be the method whose
calldata is used and persists throughout the transaction.
Edit, based on flygoing's comment:
calldataload will load different data depending on the call frame, and will persist for an individual call frame, but not to the next call frame. E.g. if EOA calls function a on
contract A, and
contract A calls
function b on
contract B, the calldataload will no longer load the EOA's call data and will instead load the data used in the sub-call frame.