Memory vs. Calldata
Discover the similarity and differences between memory and calldata.
We'll cover the following
This is a short lesson on memory
and calldata
usage in Solidity. As we know, when we declare reference type variables in Solidity, we specify a storage location for the data. So far, we’ve looked at storage and memory data locations. Now we’ll look at a new one, calldata
, in comparison with memory
.
What is calldata
?
Like memory, calldata
is a temporary storage location that’s only used when defining reference type parameters or arguments (strings, arrays, structs, and mappings) for functions in Solidity. This storage is immediately wiped once the function call is completed. Let’s take a look at the code below:
Get hands-on with 1400+ tech skills courses.