Member-only story

Solidity Tutorial: All About Memory

Understanding the short term memory of the EVM

Jean Cvllr
Better Programming
20 min readSep 3, 2022

photo by Mech Mind on Unsplash

This is Part II of the “All About Data Locations” sub-series.

We will learn the layout of the EVM memory, its reserved spaces, the free memory pointer, how to use memory references to read and write from/to memory and the conventional best practices when working with memory.

We will use code snippets of the contracts from the Ethereum Name Service (ENS) to support this article with meaningful examples. This will help us understand better how the smart contracts behind this popular project work under the hood.

Table of Content

  • Introduction
  • The EVM Memory — Overview
  • Layout of Memory
  • Basics of Memory
  • Reading from Memory (MLOAD)
  • Writing to Memory (MSTORE + MSTORE8)
  • Knowing the Memory Size (MSIZE)
  • The Free memory pointer
  • memory references as functions parameters
  • memory references inside functions body
  • The Memory Expansion cost
  • Memory between contract calls
  • Conclusion

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Jean Cvllr
Jean Cvllr

Written by Jean Cvllr

Smart Contract engineer at @LUKSO. Full Stack Developer. https://github.com/CJ42

Responses (1)

Write a response