Introduction to Storage
Learn about the storage data location in Solidity.
Storage is a foundational concept in Solidity, serving as the primary location for storing all state variables. Unlike memory
, storage
variables are changeable, allowing the state of a contract to be modified. The data stored in storage
is persistent, making it durable and recorded on the blockchain.
Press + to interact
Grouping values
State variables in storage
are organized compactly. Whenever possible, several values occupy the same storage slot. Dynamic arrays and structs are exceptions to this compact grouping.
Variable size considerations
Variables less than 32 bytes are combined in the same storage slot.
If the combined size exceeds 32 bytes, variables move to the next available storage spot.
Data is stored ...