Offset zero refers to the low-order end of a packed word.
LET’S PICTURE IT
A drawer’s numbering can begin at the right side of a written diagram.
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.
Choose a display direction
Hexadecimal words are normally printed with higher-order bytes on the left. A lower-order-aligned first field therefore appears at the right end of that display.
Read compiler byte offsets
For two uint128 fields in a slot, offsets zero and sixteen refer to their distance from the lower-order end. They are byte offsets, not bit offsets.
Extract only the intended bits
To inspect the second field, shift right by 128 bits and apply its width mask. Keep the other packed field separate rather than treating the whole word as one value.
Preserve neighbors when writing
A partial-field update must retain unrelated bits. Manual assembly that overwrites the full slot can corrupt other fields sharing that word.
Inspect the layout
slot word = (b << 128) | a
a: byte offset 0
b: byte offset 16
This illustrates unsigned packed fields and is not a complete assembly implementation.