Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

@tevm/state

State management for Tevm. Handles account state (balance, nonce, code, storage), state transitions/checkpoints, caching, persistence, and forked chain state.

Installation

npm install @tevm/state

API Reference

Enumerations

State Management

Storage Types

Caching

State Creation and Management

State Operations

State Root Management

Checkpointing

Cache Management

Genesis and Forking

Storage Operations

getProof requires fork mode because local state managers do not merkleize state.

Usage Examples

import { createAddress } from 'tevm/address'
import { createStateManager } from 'tevm/state'
import { createAccount, hexToBytes } from 'tevm/utils'
 
const stateManager = createStateManager({ loggingLevel: 'info' })
await stateManager.ready()
 
const address = createAddress('0x1234567890123456789012345678901234567890')
 
await stateManager.putAccount(address, createAccount({ nonce: 0n, balance: 100n }))
await stateManager.modifyAccountFields(address, { nonce: 1n, balance: 200n })
const account = await stateManager.getAccount(address)
 
const key = hexToBytes('0x0000000000000000000000000000000000000000000000000000000000000001')
await stateManager.putCode(address, new Uint8Array([1, 2, 3]))
const code = await stateManager.getCode(address)
await stateManager.putStorage(address, key, new Uint8Array([2]))
const value = await stateManager.getStorage(address, key)
await stateManager.clearStorage(address)