In this track: Build, test and reason
advanced · 4 MIN READ

Read compiler storage output

Use slot, offset and type information together.

LET’S PICTURE IT

A cabinet map needs both the drawer number and the compartment width.

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.

Request the correct artifact

Solidity’s standard JSON output can include storageLayout for a contract. Keep the exact source hierarchy and compiler settings used to generate it.

Read slot and byte offset

A field at slot zero with offset sixteen begins sixteen bytes from the low-order end. Slot keys and inner byte offsets are different coordinate systems.

Follow referenced type entries

Structs, arrays and mappings need the type descriptions and their own layout rules. A single top-level label may represent several storage words.

Compare before and after carefully

For an upgrade review, inspect the full old and new layouts. Matching variable names alone does not establish preserved field meaning.

Define the test

field a: slot 0, offset 0, uint128
field b: slot 0, offset 16, uint128
field c: slot 1, offset 0, uint256

Test plans are framework-neutral unless labeled as complete Solidity or JavaScript. Use a local test environment and no real funds.

QUICK CHECK · NO PRESSURE

Is byte offset sixteen the same as storage slot sixteen?

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.