Search⌘ K
AI Features

Memory vs. Calldata

Understand the key differences between memory and calldata storage locations in Solidity functions. Learn when to use calldata for immutable function arguments to save gas and improve contract efficiency. Explore practical code examples to see how these temporary storage types behave during smart contract execution.

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, ...