Skip to main content
@tevm/voltaire
@tevm/voltaire / primitives/StorageValue

primitives/StorageValue

Type Aliases

StorageValueLike

StorageValueLike = StorageValueType | bigint | string | Uint8Array
Defined in: src/primitives/StorageValue/StorageValueType.ts:22 Inputs that can be converted to StorageValue

StorageValueType

StorageValueType = Uint8Array & object
Defined in: src/primitives/StorageValue/StorageValueType.ts:14 Branded StorageValue type - represents a 32-byte EVM storage slot value. In the EVM, each contract has 2^256 storage slots, and each slot stores a 32-byte (256-bit) value. Storage is the persistent key-value store used by smart contracts to maintain state between transactions. Storage slots start at zero and are lazily allocated - reading an uninitialized slot returns zero, and writing zero to a slot can trigger a gas refund.

Type Declaration

[brand]
readonly [brand]: "StorageValue"
length
readonly length: 32

Variables

SIZE

const SIZE: 32 = 32
Defined in: src/primitives/StorageValue/StorageValueType.ts:24

Functions

equals()

equals(a, b): boolean
Defined in: src/primitives/StorageValue/equals.js:18 Compares two StorageValues for equality. Uses constant-time comparison to prevent timing attacks.

Parameters

a
StorageValueType First StorageValue
b
StorageValueType Second StorageValue

Returns

boolean
  • True if equal

Example


from()

from(value): StorageValueType
Defined in: src/primitives/StorageValue/from.js:22 Creates a StorageValue from various input types. Accepts bigint, hex strings, Uint8Array, or existing StorageValue instances.

Parameters

value
StorageValueLike The value to convert

Returns

StorageValueType
  • A branded StorageValue

Example


fromHex()

fromHex(hex): StorageValueType
Defined in: src/primitives/StorageValue/fromHex.js:18 Creates a StorageValue from a hex string.

Parameters

hex
string Hex string (with or without 0x prefix)

Returns

StorageValueType
  • A branded StorageValue

Example


toHex()

toHex(value): string
Defined in: src/primitives/StorageValue/toHex.js:19 Converts a StorageValue to a hex string.

Parameters

value
StorageValueType The StorageValue to convert

Returns

string
  • Hex string with 0x prefix

Example


toUint256()

toUint256(value): bigint
Defined in: src/primitives/StorageValue/toUint256.js:18 Converts a StorageValue to a bigint (Uint256).

Parameters

value
StorageValueType The StorageValue to convert

Returns

bigint
  • The numeric value as bigint

Example