Skip to main content

Module storage_layout

Module storage_layout 

Source
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§

DecodedStorage
A value read out of storage.
StorageLayout
The layout of one contract’s storage as solc emitted it.
StorageMember
StorageRef
A resolved place in storage: what a path names.
StorageType
StorageVariable

Enums§

PathSegment
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.
StorageEncoding

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 index of an array whose elements take element_bytes sits, counting from first: 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 0x hex 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.