Expand description
solc’s storage layout: where every state variable lives and how it is encoded.
solc --storage-layout (any release since 0.5.13, the legacy pipeline included) emits,
per contract, the slot, byte offset, and type of each state variable and a table of
the types with their encodings. That is compiler-issued fact, not inference, which is
why a debugger may read counter, balances[0xabc], config.owner, or items[2]
from a storage snapshot without ETHDebug variable information: the slot arithmetic for
mappings, arrays, and structs is the language’s own, fixed rule.
StorageLayout::resolve turns a path into a slot and byte offset;
StorageLayout::decode turns the words at those slots into a value, reading each
word through a callback so the caller decides what “the storage at this step” means.
Nothing here reads a chain.
Structs§
- Decoded
Storage - A value read out of storage.
- Storage
Layout - The layout of one contract’s storage as solc emitted it.
- Storage
Member - Storage
Ref - A resolved place in storage: what a path names.
- Storage
Type - Storage
Variable
Enums§
- Path
Segment - One step of a path such as
balances[0xabc].total: the name it starts with, an index or key in brackets, or a member after a dot. - Storage
Encoding
Functions§
- add_
word word + addend, wrapping at 256 bits like the EVM does.- decode_
value - Decodes the bytes of an in-place value by its Solidity type label.
- element_
place - Where element
indexof an array whose elements takeelement_bytessits, counting fromfirst: small elements pack several to a slot, never straddling one; larger elements take whole slots. - mapping_
slot keccak256(key . slot), the slot of a mapping entry.- parse_
path - Splits
name,name[key],name.member, or any chain of those into its segments. - parse_
word - Parses a decimal or
0xhex number into a word. - word_
hex - A word as
0x-prefixed hex. - word_
to_ decimal - A big-endian unsigned number as decimal text.
Type Aliases§
- Word
- A 256-bit storage word or slot number, big-endian.