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

Storage layout challenge set

Combine packing, derived slots and data-location boundaries.

LET’S PICTURE IT

A good cabinet map distinguishes the drawer number, inner compartment and separate working desk.

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.

Challenge one: predict packing

For uint128 a, uint128 b and uint256 c under a simple default layout, identify each slot and byte offset. Explain why c begins a second word.

Challenge two: derive an entry

For an address-keyed mapping at a declared slot, write both full words of the hash input. Explain why a twenty-byte packed address is not interchangeable here.

Challenge three: compare locations

Explain why a string’s ABI encoding, short storage encoding and memory representation cannot be substituted for each other merely because the text looks identical.

Check against actual output

Use compiler storage layout for real declarations, then compare the simple subset with the local visualizer. State the tool’s exclusions before applying its result to structs or inheritance.

Inspect the layout

a: slot 0, offset 0
b: slot 0, offset 16
c: slot 1, offset 0

Assumptions: uint128, uint128, uint256; no inherited state or custom base.

Explain the assumptions alongside the answer, then inspect the compiler layout for more complex declarations.

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

Can the elementary packing tool fully verify an upgrade layout?

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.