> ## 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/AccountState

> Auto-generated API documentation

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

***

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

# primitives/AccountState

## Type Aliases

### AccountStateLike

> **AccountStateLike** = [`AccountStateType`](#accountstatetype) | \{ `balance`: [`WeiType`](../index/namespaces/BrandedWei.mdx#weitype); `codeHash`: [`HashType`](../index/namespaces/HashType.mdx#hashtype); `nonce`: [`NonceType`](Nonce.mdx#noncetype); `storageRoot`: [`StateRootType`](StateRoot.mdx#stateroottype); }

Defined in: [src/primitives/AccountState/AccountStateType.ts:51](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/AccountState/AccountStateType.ts#L51)

Inputs that can be converted to AccountState

***

### AccountStateType

> **AccountStateType** = `object`

Defined in: [src/primitives/AccountState/AccountStateType.ts:20](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/AccountState/AccountStateType.ts#L20)

AccountState represents the state of an Ethereum account as defined in the Yellow Paper.

Each account in Ethereum has four fields:

* nonce: Number of transactions sent from this address (for EOAs) or contracts created (for contracts)
* balance: Amount of Wei owned by this account
* storageRoot: Root hash of the account's storage trie (for contracts) or empty hash (for EOAs)
* codeHash: Hash of the account's EVM bytecode (for contracts) or hash of empty string (for EOAs)

The global state is a mapping from addresses to account states, represented as a
Merkle Patricia Trie. The root of this trie is the state root included in each block header.

#### See

Yellow Paper section 4.1 - World State

#### Properties

##### balance

> `readonly` **balance**: [`WeiType`](../index/namespaces/BrandedWei.mdx#weitype)

Defined in: [src/primitives/AccountState/AccountStateType.ts:31](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/AccountState/AccountStateType.ts#L31)

Account balance in Wei (10^-18 ETH).
Can be zero or any positive value up to the total ETH supply.

##### codeHash

> `readonly` **codeHash**: [`HashType`](../index/namespaces/HashType.mdx#hashtype)

Defined in: [src/primitives/AccountState/AccountStateType.ts:45](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/AccountState/AccountStateType.ts#L45)

Keccak256 hash of the account's EVM bytecode.
For EOAs, this is keccak256("") = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470.
For contracts, this is the hash of their deployed bytecode.

##### nonce

> `readonly` **nonce**: [`NonceType`](Nonce.mdx#noncetype)

Defined in: [src/primitives/AccountState/AccountStateType.ts:25](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/AccountState/AccountStateType.ts#L25)

Transaction count (EOA) or number of contract creations (contract account).
Starts at 0 and increments with each transaction/creation.

##### storageRoot

> `readonly` **storageRoot**: [`StateRootType`](StateRoot.mdx#stateroottype)

Defined in: [src/primitives/AccountState/AccountStateType.ts:38](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/AccountState/AccountStateType.ts#L38)

Root hash of the account's storage trie.
For EOAs (externally owned accounts), this is the empty trie hash.
For contracts, this is the root of the Merkle Patricia Trie containing storage slots.

## Variables

### EMPTY\_CODE\_HASH

> `const` **EMPTY\_CODE\_HASH**: `"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"` = `"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"`

Defined in: [src/primitives/AccountState/AccountStateType.ts:64](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/AccountState/AccountStateType.ts#L64)

Standard hash of empty string - used for EOA code hash
keccak256("") = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470

***

### EMPTY\_TRIE\_HASH

> `const` **EMPTY\_TRIE\_HASH**: `"0x56e81f171bcc55a6ff8345e692c0f86e5b47e5b60e2d8c5ab6c7c9fa0e32d3c5"` = `"0x56e81f171bcc55a6ff8345e692c0f86e5b47e5b60e2d8c5ab6c7c9fa0e32d3c5"`

Defined in: [src/primitives/AccountState/AccountStateType.ts:71](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/AccountState/AccountStateType.ts#L71)

Standard hash of empty trie - used for EOA storage root
keccak256(rlp(\[])) = 0x56e81f171bcc55a6ff8345e692c0f86e5b47e5b60e2d8c5ab6c7c9fa0e32d3c5

## Functions

### createEmpty()

> **createEmpty**(): [`AccountStateType`](#accountstatetype)

Defined in: [src/primitives/AccountState/createEmpty.js:28](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/AccountState/createEmpty.js#L28)

Creates an empty AccountState representing an EOA (Externally Owned Account)
with zero balance and nonce.

Empty accounts have:

* nonce: 0
* balance: 0 Wei
* storageRoot: empty trie hash
* codeHash: empty code hash

#### Returns

[`AccountStateType`](#accountstatetype)

* An empty AccountState

#### Example

```typescript theme={null}
const emptyAccount = AccountState.createEmpty();
```

***

### equals()

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

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

Compares two AccountStates for equality.
All four fields must match for accounts to be considered equal.

#### Parameters

##### a

[`AccountStateType`](#accountstatetype)

First AccountState

##### b

[`AccountStateType`](#accountstatetype)

Second AccountState

#### Returns

`boolean`

* True if all fields are equal

#### Example

```typescript theme={null}
const isEqual = AccountState.equals(state1, state2);
```

***

### from()

> **from**(`state`): [`AccountStateType`](#accountstatetype)

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

Creates an AccountState from an object with the required fields.

#### Parameters

##### state

[`AccountStateLike`](#accountstatelike)

Object containing nonce, balance, storageRoot, and codeHash

#### Returns

[`AccountStateType`](#accountstatetype)

* A validated AccountState

#### Example

```typescript theme={null}
const state = AccountState.from({
  nonce: Nonce.from(5n),
  balance: Wei.from(1000000000000000000n), // 1 ETH
  storageRoot: StateRoot.from("0x56e8..."),
  codeHash: Hash.from("0xc5d2..."),
});
```

***

### isContract()

> **isContract**(`state`): `boolean`

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

Checks if an AccountState represents a contract account.

A contract account is identified by having a non-empty code hash, meaning
it has associated bytecode that can be executed.

#### Parameters

##### state

[`AccountStateType`](#accountstatetype)

The AccountState to check

#### Returns

`boolean`

* True if the account is a contract

#### Example

```typescript theme={null}
const isContract = AccountState.isContract(account);
```

***

### isEOA()

> **isEOA**(`state`): `boolean`

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

Checks if an AccountState represents an EOA (Externally Owned Account).

An EOA is identified by having the empty code hash, meaning it has no
associated bytecode. EOAs can only send transactions and cannot execute code.

#### Parameters

##### state

[`AccountStateType`](#accountstatetype)

The AccountState to check

#### Returns

`boolean`

* True if the account is an EOA

#### Example

```typescript theme={null}
const isEOA = AccountState.isEOA(account);
```
