Member-only story

All About Solidity Data Locations — Storage

Diving into storage references and smart contract storage layout.

Jean Cvllr
Better Programming
19 min readJul 20, 2022

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

In today's article, we cover in more detail an important data location in the EVM: the smart contract storage.

We will see how the layout of the contract storage works, storage references. how to write to the contract storage in assembly. We will also use some contracts from OpenZeppelin and Compound to learn how storage references work in practice while learning the Solidity code behind these popular contracts and protocols along the way.

Table of Content

  • Introduction
  • Layout of Storage
  • Basics of Storage
  • Interacting with Storage
  • Storage pointers in function parameters
  • Storage pointers in function body
  • The cost of reading storage.
  • Conclusion

Introduction

Understanding the storage model in Ethereum and EVM-based chain is essential for good smart contract development.

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 (4)

Write a response

These are `immutable`, so they should end up in the bytecode, I suppose.
> If we look at the top state variables defined, we can see that the configuration values beneficiary and start timestamp are packed into the same storage slot because of their type.

If we look at the top state variables defined, we can see that the configuration values beneficiary and start timestamp are packed into the same storage slot because of their type.

Thats correct. Therefore `_beneficiary` and _start` cannot be inspected as they are not part of storage. Can you please update this example?

derived contract are placed in sub-sequential slots (slot 1, 2, 3, etc…)

Derived contracts means Child Contracts