@tevm/voltaire / primitives/State
primitives/State
Type Aliases
StorageKeyLike
StorageKeyLike =Defined in: src/primitives/State/StorageKeyType.ts:57 Inputs that can be converted to StorageKeyTypeStorageKeyType| {address:AddressType;slot:bigint; }
StorageKeyType
StorageKeyType = object
Defined in: src/primitives/State/StorageKeyType.ts:35
Composite key for EVM storage operations combining address and slot.
The StorageKey uniquely identifies a storage location within the EVM by
combining a contract address with a 256-bit storage slot number. This is
fundamental to how the EVM organizes persistent contract storage.
Design Rationale
Each smart contract has its own isolated storage space addressed by 256-bit slots. To track storage across multiple contracts in a single VM instance, we need a composite key that includes both the contract address and the slot number.Storage Model
In the EVM:- Each contract has 2^256 storage slots
- Each slot can store a 256-bit value
- Slots are initially zero and only consume gas when first written
Example
Properties
address
Defined in: src/primitives/State/StorageKeyType.ts:40 The contract address that owns this storage slot. Standard 20-byte Ethereum address.readonlyaddress:AddressType
slot
Defined in: src/primitives/State/StorageKeyType.ts:46 The 256-bit storage slot number within the contract’s storage space. Slots are sparsely allocated - most remain at zero value.readonlyslot:bigint
Variables
create()
Defined in: src/primitives/State/index.ts:15constcreate: (address,slot) =>StorageKeyType
Parameters
address
AddressType
slot
bigint
Returns
StorageKeyType
EMPTY_CODE_HASH
Defined in: src/primitives/State/constants.js:21 Hash of empty EVM bytecode (Keccak256 of empty bytes). This is a well-known constant in Ethereum representing the Keccak256 hash of an empty byte array. It’s used to identify accounts with no associated contract code. Value: Keccak256("") = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470constEMPTY_CODE_HASH:HashType
See
https://voltaire.tevm.sh/primitives/state for State documentationSince
0.0.0Example
EMPTY_TRIE_ROOT
Defined in: src/primitives/State/constants.js:50 Root hash of an empty Merkle Patricia Trie. This is the root hash of an empty trie structure in Ethereum, used as the initial value for account storage roots and state roots when they contain no data. Value: Keccak256(RLP(null)) = 0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421constEMPTY_TRIE_ROOT:HashType
See
https://voltaire.tevm.sh/primitives/state for State documentationSince
0.0.0Example
equals()
Defined in: src/primitives/State/index.ts:24constequals: (a,b) =>boolean
Parameters
a
StorageKeyLike
b
StorageKeyLike
Returns
boolean
from()
Defined in: src/primitives/State/index.ts:20constfrom: (value) =>StorageKeyType
Parameters
value
StorageKeyLike
Returns
StorageKeyType
fromString()
Defined in: src/primitives/State/index.ts:32constfromString: (str) =>StorageKeyType|undefined
Parameters
str
string
Returns
StorageKeyType | undefined
hashCode()
Defined in: src/primitives/State/index.ts:36consthashCode: (key) =>number
Parameters
key
StorageKeyLike
Returns
number
is()
Defined in: src/primitives/State/index.ts:22constis: (value) =>value is StorageKeyType
Parameters
value
unknown
Returns
value is StorageKeyType
StorageKey
Defined in: src/primitives/State/index.ts:50constStorageKey:object
Type Declaration
create()
create: (address,slot) =>StorageKeyType
Parameters
address
AddressType
slot
bigint
Returns
StorageKeyType
equals()
equals: (a,b) =>boolean
Parameters
a
StorageKeyLike
b
StorageKeyLike
Returns
boolean
from()
from: (value) =>StorageKeyType
Parameters
value
StorageKeyLike
Returns
StorageKeyType
fromString()
fromString: (str) =>StorageKeyType|undefined
Parameters
str
string
Returns
StorageKeyType | undefined
hashCode()
hashCode: (key) =>number
Parameters
key
StorageKeyLike
Returns
number
is()
is: (value) =>value is StorageKeyType
Parameters
value
unknown
Returns
value is StorageKeyType
toString()
toString: (key) =>string
Parameters
key
StorageKeyLike
Returns
string
toString()
Defined in: src/primitives/State/index.ts:30consttoString: (key) =>string
Parameters
key
StorageKeyLike
Returns
string
Functions
_create()
_create(Defined in: src/primitives/State/create.js:18 Create a new StorageKeyaddress,slot):StorageKeyType
Parameters
address
AddressType
Contract address
slot
bigint
Storage slot number
Returns
StorageKeyType
A new StorageKey
See
https://voltaire.tevm.sh/primitives/state for State documentationSince
0.0.0Throws
Example
_equals()
_equals(Defined in: src/primitives/State/equals.js:23 Check equality between two storage keys. Two storage keys are equal if and only if both their address and slot number match exactly.a,b):boolean
Parameters
a
StorageKeyLike
First storage key
b
StorageKeyLike
Second storage key
Returns
boolean
True if both address and slot match
See
https://voltaire.tevm.sh/primitives/state for State documentationSince
0.0.0Throws
Example
_from()
_from(Defined in: src/primitives/State/from.js:15 Convert StorageKeyLike to StorageKeyvalue):StorageKeyType
Parameters
value
StorageKeyLike
Value to convert
Returns
StorageKeyType
StorageKey
See
https://voltaire.tevm.sh/primitives/state for State documentationSince
0.0.0Throws
Example
_fromString()
_fromString(Defined in: src/primitives/State/fromString.js:18 Parse a StorageKey from its string representationstr):StorageKeyType|undefined
Parameters
str
string
String representation from toString()
Returns
StorageKeyType | undefined
Parsed StorageKey or undefined if invalid
See
https://voltaire.tevm.sh/primitives/state for State documentationSince
0.0.0Throws
Example
_hashCode()
_hashCode(Defined in: src/primitives/State/hashCode.js:17 Compute a hash code for the storage key for use in hash-based collectionskey):number
Parameters
key
StorageKeyLike
Storage key to hash
Returns
number
Hash code as a number
See
https://voltaire.tevm.sh/primitives/state for State documentationSince
0.0.0Throws
Example
_is()
_is(Defined in: src/primitives/State/is.js:18 Type guard to check if a value is a valid StorageKeyvalue):value is StorageKeyType
Parameters
value
unknown
Value to check
Returns
value is StorageKeyType
True if value is a valid StorageKey
See
https://voltaire.tevm.sh/primitives/state for State documentationSince
0.0.0Throws
Example
_toString()
_toString(Defined in: src/primitives/State/toString.js:23 Convert StorageKey to a string representation for use as Map key The string format is: address_hex + ”_” + slot_hexkey):string
Parameters
key
StorageKeyLike
Storage key to convert
Returns
string
String representation (address_hex + ”_” + slot_hex)
See
https://voltaire.tevm.sh/primitives/state for State documentationSince
0.0.0Throws
Example
StorageKeyFactory()
StorageKeyFactory(Defined in: src/primitives/State/index.ts:63 Factory function for creating StorageKey instancesaddress,slot):StorageKeyType
Parameters
address
AddressType
slot
bigint
Returns
StorageKeyType

