Skip to main content
Conceptual Guide - For API reference and method documentation, see State API.
Ethereum state is a global key-value mapping of all accounts (EOAs and contracts) to their data (balance, nonce, code, storage). This guide teaches state fundamentals using Tevm.

What is Ethereum State?

Ethereum maintains a single, canonical world state - a mapping from 20-byte addresses to account data. This state changes with every transaction in every block.

Two Types of State

Ethereum distinguishes between account state (global) and storage state (per-contract):
  • Account State: Maps addresses to account objects (balance, nonce, storageRoot, codeHash)
  • Storage State: Maps 256-bit slots to 256-bit values within each contract
The StorageKey primitive combines these: {address, slot} uniquely identifies any storage location.

Account State

Two account types exist in Ethereum:

Storage State

Each contract account has its own storage trie mapping 256-bit slot numbers to 256-bit values:

Solidity Storage Layout

Solidity compiles variables to storage slots following specific rules:

Merkle Patricia Trie Structure

Ethereum stores state in a Merkle Patricia Trie - a cryptographic data structure combining:
  • Merkle Tree: Any change to data changes the root hash
  • Patricia Trie: Space-efficient prefix tree for key-value lookups

How It Works

Each node hashes its children, creating a merkle tree where:
  • The state root proves the entire account state
  • Each account’s storageRoot proves that contract’s storage

State Root

The state root is a single 32-byte hash proving the entire world state:

Storage Key Operations

Tevm provides utilities for working with storage keys:

State Transitions

Every transaction modifies state. The EVM applies state transitions:

Contract Storage Changes

Storage changes also trigger state root updates:

Merkle Proof Verification

Merkle proofs allow proving account or storage data without the full state:

Common Use Cases

Light Client Verification

Light clients verify state without downloading full blockchain:

Storage Proof for Token Balances

Prove token balance without trusting the RPC provider:

Optimistic Rollup Fraud Proofs

Rollups use state proofs for fraud detection:

Contract Storage Analysis

Analyze storage layout and usage:

Resources

Next Steps