@tevm/voltaire / primitives/AccountState
primitives/AccountState
Type Aliases
AccountStateLike
AccountStateLike =Defined in: src/primitives/AccountState/AccountStateType.ts:51 Inputs that can be converted to AccountStateAccountStateType| {balance:WeiType;codeHash:HashType;nonce:NonceType;storageRoot:StateRootType; }
AccountStateType
AccountStateType = object
Defined in: src/primitives/AccountState/AccountStateType.ts:20
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)
See
Yellow Paper section 4.1 - World StateProperties
balance
Defined in: src/primitives/AccountState/AccountStateType.ts:31 Account balance in Wei (10^-18 ETH). Can be zero or any positive value up to the total ETH supply.readonlybalance:WeiType
codeHash
Defined in: src/primitives/AccountState/AccountStateType.ts:45 Keccak256 hash of the account’s EVM bytecode. For EOAs, this is keccak256("") = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470. For contracts, this is the hash of their deployed bytecode.readonlycodeHash:HashType
nonce
Defined in: src/primitives/AccountState/AccountStateType.ts:25 Transaction count (EOA) or number of contract creations (contract account). Starts at 0 and increments with each transaction/creation.readonlynonce:NonceType
storageRoot
Defined in: src/primitives/AccountState/AccountStateType.ts:38 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.readonlystorageRoot:StateRootType
Variables
EMPTY_CODE_HASH
Defined in: src/primitives/AccountState/AccountStateType.ts:64 Standard hash of empty string - used for EOA code hash keccak256("") = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470constEMPTY_CODE_HASH:"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"="0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
EMPTY_TRIE_HASH
Defined in: src/primitives/AccountState/AccountStateType.ts:71 Standard hash of empty trie - used for EOA storage root keccak256(rlp([])) = 0x56e81f171bcc55a6ff8345e692c0f86e5b47e5b60e2d8c5ab6c7c9fa0e32d3c5constEMPTY_TRIE_HASH:"0x56e81f171bcc55a6ff8345e692c0f86e5b47e5b60e2d8c5ab6c7c9fa0e32d3c5"="0x56e81f171bcc55a6ff8345e692c0f86e5b47e5b60e2d8c5ab6c7c9fa0e32d3c5"
Functions
createEmpty()
createEmpty(): AccountStateType
Defined in: src/primitives/AccountState/createEmpty.js:28
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
- An empty AccountState
Example
equals()
equals(Defined in: src/primitives/AccountState/equals.js:22 Compares two AccountStates for equality. All four fields must match for accounts to be considered equal.a,b):boolean
Parameters
a
AccountStateType
First AccountState
b
AccountStateType
Second AccountState
Returns
boolean
- True if all fields are equal
Example
from()
from(Defined in: src/primitives/AccountState/from.js:22 Creates an AccountState from an object with the required fields.state):AccountStateType
Parameters
state
AccountStateLike
Object containing nonce, balance, storageRoot, and codeHash
Returns
AccountStateType
- A validated AccountState
Example
isContract()
isContract(Defined in: src/primitives/AccountState/isContract.js:22 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.state):boolean
Parameters
state
AccountStateType
The AccountState to check
Returns
boolean
- True if the account is a contract
Example
isEOA()
isEOA(Defined in: src/primitives/AccountState/isEOA.js:22 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.state):boolean
Parameters
state
AccountStateType
The AccountState to check
Returns
boolean
- True if the account is an EOA

