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

Loading player…

Storage in Solidity: How Storage Works

BaseMon, Oct 9, 2023, 12:00 AM

Learn the core components of contract storage in Solidity. Discover the big table concept, fixed-size values, and variable order's impact. Save storage, save money, and optimize your smart contract development. 📚 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://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

now let's see how the storage of a contract Works in solidity we need to imagine the storage of a contract as a big table that goes from zero to 2 to the power of 256 minus 1 which is a very very big number each slot in the storage has a size of 32 bytes or 256 bits if you remember in the last exercise we were using a unit 8. which means that it has a size of 8 Bits and this value will be a store only in a portion of this slot however if we will have use a u in 256 it will occupy the full slot this type of values are known as fixed size values because we know its size at compile time we know that the Eon 8 will occupy exactly 8 Bits in solidity the order in which the variables are declared will influence the position in the storage that means that the value of H will be a store in the slot zero since H is the first variable that is declared within the contract this will become more important as you become a smart contract developer because you can save storage which means you can save money by for instance choosing the right data type to store values

Automatic transcript — names and jargon may be misspelled.