A numbered drawer contains thirty-two byte-sized compartments.
SEE IT FOR YOURSELF
Pack small values into Solidity storage slotsStep 1 / 4
In this simple default-layout example, two uint128 values come before one uint256. Each slot holds thirty-two bytes.
In this simple default-layout example, two uint128 values come before one uint256. Each slot holds thirty-two bytes.The first sixteen-byte value occupies the low-order half of slot zero. Low-order bytes are shown on the right.The second uint128 fits in the remaining sixteen bytes. Both values now share slot zero.C needs a complete thirty-two-byte slot, so it begins at slot one. Two packed small values plus C use two slots.
Animated local teaching model. No wallet, RPC or live blockchain data. Some labels and hashes are abbreviated for readability.
Separate slot and value
A storage slot is identified by a 256-bit key and contains a 256-bit word. The slot number and the numeric value stored there are different quantities.
Count bytes and hex digits
Thirty-two bytes display as sixty-four hexadecimal digits. A leading 0x is notation, so it does not add another byte to the stored word.
Account for smaller fields
Solidity can place multiple suitable small value types in one slot. Reading the word then requires the correct offsets and widths to interpret individual fields.
Use the real compiler layout
Default sequential examples are a starting point. Inheritance, custom layout bases, mappings and manual slot conventions require additional context.