Tool 03 · Upgrades · Free

Storage Layout Visualizer

See exactly how solc packs your state variables into slots — then diff two versions to catch the layout changes that silently corrupt an upgradeable proxy. Both modes run in your browser.

At a glance

ModesLayout · Upgrade diff
HandlesPacking, gaps, structs, inheritance
UploadsNone
CostFree
Best forAny upgradeable contract

Storage Layout & Upgrade Safety

Run it

Parent contracts occupy the first slots. Paste the flattened source, or the tool will tell you what is missing.

How it works

What this tool does, and what it can't.

Solidity packs state variables into 32-byte slots left to right, starting a new slot whenever the next variable does not fit in the remaining bytes. Mappings, dynamic arrays, fixed arrays, structs, string and bytes always begin a fresh slot. constant and immutable variables take no slot at all — they live in bytecode.

The layout view renders each slot as a bar, showing which variables share it and how many bytes are unused. That wasted space is real money: a variable in its own slot costs 20,000 gas on first write and 2,100 on every cold read, where a packed one may cost nothing extra at all.

The upgrade diff compares the two layouts position by position and classifies every difference. Type changes, insertions, removals and moves are Critical, because the new code will read data written by a different variable. Appending at the end is safe. Renaming with an identical type and position is safe but flagged, so you can confirm it was deliberate.

FAQ

Questions about this tool.

More in the methodology and the glossary.

Inserting a variable anywhere except the end, removing one, reordering them, changing a type's size, changing inheritance order, or unpacking a slot by widening a type. Any of these shifts every variable after it, and the new implementation then reads the wrong bytes.

A uint256[50] private __gap; at the end of an upgradeable base contract reserves slots so children can grow without collision. When you add N slots of state above it, reduce the gap by exactly N. The tool flags a gap whose size changed so you can check the arithmetic.

Yes, for contracts present in the same paste — parent variables are laid out first, in most-base-first order, exactly as solc does. If a parent is missing the tool says so explicitly rather than producing a confidently wrong slot number.

No, and you should run that too — it validates against the actual deployed implementation, which a browser tool cannot. This is for the moment before that: reviewing a proposed change, or understanding a layout you did not write.

Group small types together so they share slots: an address (20 bytes) plus a uint96 fills exactly one slot. Put bool next to an address rather than alone. And check whether a variable is ever reassigned — if not, immutable removes the storage access entirely.

Beyond automation

No tool reads your specification. We do.

The findings that drain protocols come from state assumptions, economic design and cross-contract interaction — none of which a scanner sees. Free scoping in under two working days.