Skip to content

Compute storage slots for mappings, dynamic arrays, ERC-1967 proxy slots and ERC-7201 namespaces.

Loading tool

About Storage Slot Calculator

Compute Solidity storage slots: the slot of a mapping value (including nested mappings), the slot of a dynamic array element (with packing for small element types), the slot and offset of each state variable from a list of declarations, and well-known locations such as ERC-1967 proxy slots and ERC-7201 namespaced storage.

Common uses

  • Read a balance or allowance directly with eth_getStorageAt
  • Set storage in Foundry or Hardhat tests (vm.store, hardhat_setStorageAt)
  • Find the implementation or admin slot of an ERC-1967 proxy
  • Compute an ERC-7201 namespace location for upgradeable contracts

FAQ

How is the storage slot of a mapping value computed?
For mapping(K => V) at slot p, the value for key k is at keccak256(abi.encode(k, p)). For string and bytes keys the key is not padded: keccak256(abi.encodePacked(k, p)). Nested mappings repeat the step with the previous result as p.
Where are dynamic array elements stored?
The array length is stored at its slot p, and the elements start at keccak256(p). Element i is at keccak256(p) + i times the slots per element, with elements of 16 bytes or less packed several per slot.
What is the ERC-1967 implementation slot?
bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1), which is 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc.