Solidity Storage Slot Calculator
Work out the exact storage slot for any Solidity state variable, including mapping entries, dynamic array elements and nested mappings, so you can read state directly or check a proxy layout.
Last reviewed by the Radiatus Cloud team
Need this done properly for your business?
Radiatus delivers secure cloud, DevOps & compliance engineering.
Storage is a flat map of 256-bit slots and the compiler assigns them in order
Every contract has 2^256 storage slots, almost all of which are zero. Simple state variables are laid out from slot zero in declaration order, packed together where several fit in 32 bytes, which is why declaration order affects gas and why reordering variables changes the layout. Knowing the slot lets you read private state directly with a storage query, because private in Solidity means inaccessible to other contracts rather than hidden: everything in storage is public to anyone reading the chain.
Mappings and dynamic arrays are placed by hashing
A mapping occupies a slot that stays empty; its entries live at the keccak hash of the key concatenated with the slot number. A dynamic array stores its length in its declared slot and its elements starting at the keccak hash of that slot number. Both schemes exist so that entries land in effectively unpredictable places and cannot collide with the ordinary sequential layout, and both are exactly reproducible, which is what makes reading them possible.
Layout is why proxy upgrades corrupt state
A proxy holds the storage and delegates the logic, so the new implementation must have a layout compatible with the old one. Inserting a variable in the middle of the declarations shifts everything after it, and the new contract then reads a balance where a boolean used to be. The damage is silent and immediate: nothing reverts, the values are simply wrong. Append-only ordering, storage gaps in upgradeable base contracts, and unstructured storage at a hashed slot all exist to prevent exactly this.
Related tools
- Ethereum Unit Converter — Convert between Wei, Gwei, and Ether units.
- Gas Fee Calculator — Calculate transaction costs based on gas price and limit.
- IPFS CID Generator — Generate IPFS Content Identifiers (CID) from text or files.
- Wallet Address Validator — Validate Ethereum and Bitcoin wallet addresses.
Frequently Asked Questions
Can I read a private variable?
Yes. Private restricts access from other contracts; it does not hide anything. Everything in storage is readable by anyone querying the chain at the right slot.
Where does a mapping entry live?
At keccak256 of the key concatenated with the mapping slot number, both padded to 32 bytes. The mapping slot itself stays empty.
Where are dynamic array elements?
The declared slot holds the length. Element zero is at keccak256 of the slot number, and each subsequent element is one slot further.
Why does variable order matter?
Because the compiler packs variables that fit together into one slot and assigns them sequentially. Reordering changes the layout, and for a proxy that means the new logic reads the wrong data.
What is a storage gap?
Reserved empty slots in an upgradeable base contract so that variables can be added later without shifting anything in the contracts that inherit from it.
Privacy & Security
Everything runs in your browser; nothing is uploaded.
How to Use
Describe the variable to find its storage slot.
Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.