A directory lookup can locate a multi-drawer record rather than a single field.
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.
Derive the entry base
For a mapping value that is a struct, the key derivation still selects a base slot. It does not force every struct member into that one word.
Lay out members from that base
If the struct contains two uint128 fields then a uint256, the two small members share the base word and the full-width member uses the next slot.
Keep nested members recursive
An array or mapping inside that struct has its own declared relative position and hash-derived rules. Apply those rules after locating the containing struct.
Avoid a misleading single-slot label
A user record may span several slots even though one mapping key selects it. Label the base and each member offset separately in an inspection tool.
Inspect the layout
struct Record { uint128 a; uint128 b; uint256 c; }
base = hash(address key, mapping slot)
a and b: base
c: base + 1
The hash input uses the standard padded address-key layout described in the previous lesson.