> ## Documentation Index
> Fetch the complete documentation index at: https://voltaire.tevm.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# primitives/StorageValue

> Auto-generated API documentation

[**@tevm/voltaire**](../index.mdx)

***

[@tevm/voltaire](../index.mdx) / primitives/StorageValue

# primitives/StorageValue

## Type Aliases

### StorageValueLike

> **StorageValueLike** = [`StorageValueType`](#storagevaluetype) | `bigint` | `string` | `Uint8Array`

Defined in: [src/primitives/StorageValue/StorageValueType.ts:22](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/StorageValue/StorageValueType.ts#L22)

Inputs that can be converted to StorageValue

***

### StorageValueType

> **StorageValueType** = `Uint8Array` & `object`

Defined in: [src/primitives/StorageValue/StorageValueType.ts:14](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/StorageValue/StorageValueType.ts#L14)

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](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/StorageValue/StorageValueType.ts#L24)

## Functions

### equals()

> **equals**(`a`, `b`): `boolean`

Defined in: [src/primitives/StorageValue/equals.js:18](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/StorageValue/equals.js#L18)

Compares two StorageValues for equality.
Uses constant-time comparison to prevent timing attacks.

#### Parameters

##### a

[`StorageValueType`](#storagevaluetype)

First StorageValue

##### b

[`StorageValueType`](#storagevaluetype)

Second StorageValue

#### Returns

`boolean`

* True if equal

#### Example

```typescript theme={null}
const isEqual = StorageValue.equals(val1, val2);
```

***

### from()

> **from**(`value`): [`StorageValueType`](#storagevaluetype)

Defined in: [src/primitives/StorageValue/from.js:22](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/StorageValue/from.js#L22)

Creates a StorageValue from various input types.
Accepts bigint, hex strings, Uint8Array, or existing StorageValue instances.

#### Parameters

##### value

[`StorageValueLike`](#storagevaluelike)

The value to convert

#### Returns

[`StorageValueType`](#storagevaluetype)

* A branded StorageValue

#### Example

```typescript theme={null}
const val = StorageValue.from(123n);
const val2 = StorageValue.from("0x1234...");
const val3 = StorageValue.from(new Uint8Array(32));
```

***

### fromHex()

> **fromHex**(`hex`): [`StorageValueType`](#storagevaluetype)

Defined in: [src/primitives/StorageValue/fromHex.js:18](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/StorageValue/fromHex.js#L18)

Creates a StorageValue from a hex string.

#### Parameters

##### hex

`string`

Hex string (with or without 0x prefix)

#### Returns

[`StorageValueType`](#storagevaluetype)

* A branded StorageValue

#### Example

```typescript theme={null}
const val = StorageValue.fromHex("0x1234...");
```

***

### toHex()

> **toHex**(`value`): `string`

Defined in: [src/primitives/StorageValue/toHex.js:19](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/StorageValue/toHex.js#L19)

Converts a StorageValue to a hex string.

#### Parameters

##### value

[`StorageValueType`](#storagevaluetype)

The StorageValue to convert

#### Returns

`string`

* Hex string with 0x prefix

#### Example

```typescript theme={null}
const hex = StorageValue.toHex(val);
// "0x0000000000000000000000000000000000000000000000000000000000000123"
```

***

### toUint256()

> **toUint256**(`value`): `bigint`

Defined in: [src/primitives/StorageValue/toUint256.js:18](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/StorageValue/toUint256.js#L18)

Converts a StorageValue to a bigint (Uint256).

#### Parameters

##### value

[`StorageValueType`](#storagevaluetype)

The StorageValue to convert

#### Returns

`bigint`

* The numeric value as bigint

#### Example

```typescript theme={null}
const val = StorageValue.from(123n);
const num = StorageValue.toUint256(val);
// 123n
```
