New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Mappings in Solidity: How Mappings Are Stored

BaseMon, Oct 9, 2023, 12:00 AM

Learn how dynamic size values are stored using hash-based slot positions. Unravel the mystery of mappings and enhance your understanding of smart contract storage. Dive into advanced storage techniques and level up your coding skills! 🚀💡 📚 Head to Base Camp for full courses on smart contract development: https://docs.base.org/base-camp/docs/welcome ✅ Subscribe to our channel here: https://www.youtube.com/@BuildonBase ► Build on Base: https://base.org ► Follow us on Twitter: https://twitter.com/buildonbase ► Join our Discord: https://base.org/discord

Transcript

We have already learned how storage works for fixed-size types. However, mappings fall into a different category called dynamic size values . This is mainly because with mappings, we cannot know how many values ​​will be stored in this structure. For that reason, Solidity assigns values ​​to spaces in a different way. Basically, it applies a hash to the key and the position of the space.

For example, in the last exercise, we created an advanced storage contract using the sender's address as the key. This means that the location of the age will be the sender's hash and zero space, since the mapping is located in zero space. The result of this will be a number. A hash is also a number. And this number will point to a specific storage location.

Automatic transcript — names and jargon may be misspelled.