Calculate solidity storage slot

Derive an EVM storage slot for a mapping key, dynamic-array element, or simply laid-out struct field.

freeworks offlinenothing uploaded
ToolSolidity Storage Slot Calculator
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

A mapping entry hashes the 32-byte key encoding followed by the 32-byte mapping slot. A dynamic-array element starts at keccak256 of the array slot and adds its index; a struct field uses the supplied slot offset. The struct mode assumes one complete slot per field and does not model Solidity packing.

  • Slot zero and index zero make the first declaration easy to inspect.
  • Decimal and hexadecimal entry match compiler and debugger notation.

Worked example

A mapping(address => uint256) at slot 0
keccak256(pad32(key) ++ pad32(0)) is the slot the value lives at
Input
											Kind: mapping
Base slot: 0
Mapping key: 0x0000000000000000000000000000000000000001
Mapping key type: address
Array index: 0
Struct field slot offset: 0
										
Output
												Slot hex: 0xada5013122d395ba3c54772283fb069b10426056ef8ca54750cb9bb552a59e7d
Slot decimal: 78541660797044910968829902406342334108369226379826116161446442989268089806461
Explanation: Mapping slot: keccak256(pad32(key) . pad32(baseSlot)).
											

When to use this

Proxy upgrade reviews inspect occupied slots, Foundry traces debug mapping reads, and inline assembly uses sload for array elements.

Edge cases

  • Packed uint128 fields share a slot, so the simple struct offset is not a replacement for compiler layout output.
  • A UTF-8 string key and a zero-padded address key have different byte encodings before hashing.
  • Index arithmetic wraps at the 256-bit EVM word size and is displayed masked to 32 bytes.

References