In this track: Storage, memory and layout
advanced · 4 MIN READ

The 32-byte storage word

Storage reads and writes address full words.

LET’S PICTURE IT

A numbered drawer contains thirty-two byte-sized compartments.

SEE IT FOR YOURSELF
Pack small values into Solidity storage slotsStep 1 / 4
Pack small values into Solidity storage slotsFirstuint128 A16 bytesSeconduint128 B16 bytesThirduint256 C32 bytesSimple elementary types only; not a complete compiler layoutSlot 0 · 32 bytesUnused · 16 BA · 16 BHigh-order bytes ← → low-order bytesSlot 0 · fullB · 16 BA · 16 BDeclaration order and sizes determine this packingSlot 0BASlot 1C · 32 bytesTry different sequences in the storage-layout tool

In this simple default-layout example, two uint128 values come before one uint256. Each slot holds thirty-two bytes.

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.

Inspect the layout

slot key: 0
word: 0x000000000000000000000000000000000000000000000000000000000000002a

This word holds integer 42 when interpreted as uint256.

TURN UNDERSTANDING INTO PRACTICEOpen the Storage layout →
QUICK CHECK · NO PRESSURE

How many hex digits represent a full storage word?

Your progress stays in this browser.
Keep exploring the original referenceSolidity documentation ↗

Original explanations by EtherTools. Examples are educational and source-linked; this site is independent of the Ethereum Foundation. Our approach.