Graph of memory locations in Solidity: storage, calldata, etc…


In Solidity smart contracts, there are 4 memory locations:

  • storage
  • memory
  • stack
  • calldata

They all have different lifetimes and it’s not always easy to choose which one is right. In the below graph I drew their lifetimes against the execution of blocks, smart contract and functions.

Lifetime of memory locations in Solidity

Storage is the only memory location than span across block, i.e it persists to the blockchain.

Memory spans across multiple function executions in the same smart contract.

Stack last only as long as the function it is contained in.

And calldata is only available in the argument of the outer function execution

More great articles

100+ video tutorials on Ethereum / Solidity development

EatTheBlocks Pro just reached a new milestone: there are now more than 100 videos on Ethereum & Solidity development. That's…

Read Story

Updates added to “Learn Ethereum Dapps” ebook – v1.1.0

Last week I released my ebook Learn Ethereum Dapps, where I teach how to build a ToDo list Dapp on…

Read Story

What to build on Ethereum? Dapp ideas

So, you are thinking of building a Dapp on Ethereum, but you are still not sure what to build? In…

Read Story

Never miss a minute

Get great content to your inbox every week. No spam.

    Only great content, we don’t share your email with third parties.