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

Long bytes and strings in storage

Long content moves to a hash-derived data region.

LET’S PICTURE IT

A long note uses its index card for a length marker and stores the text on another shelf.

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.

Identify the long form

For bytes or string with at least thirty-two payload bytes, the declared slot stores twice the byte length plus one. The low bit distinguishes this long representation.

Find the content base

The data region begins at Keccak-256 of the encoded declared slot. Its consecutive words hold the byte content under the storage byte-array rules.

Inspect the boundary case

Thirty-one payload bytes use the short inline form. Thirty-two payload bytes use the long form, whose marker is sixty-five, even though the content itself fits one word.

Measure strings in bytes

Multi-byte UTF-8 text can cross the storage threshold with fewer than thirty-two visible symbols. Count actual encoded bytes before choosing the representation.

Inspect the layout

payload length: 32 bytes
main slot marker: 65 (0x41)
data begins: keccak256(encoded declared slot)

This is storage layout, not standard ABI head-and-tail encoding.

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

What marker is stored for a 32-byte long payload?

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.