Skip to main content
@tevm/voltaire
@tevm/voltaire / primitives/StateProof

primitives/StateProof

Type Aliases

StateProofLike

StateProofLike = StateProofType | { accountProof: readonly Uint8Array[]; address: AddressType; balance: WeiType; codeHash: HashType; nonce: NonceType; storageHash: StateRootType; storageProof: readonly StorageProofType[]; }
Defined in: src/primitives/StateProof/StateProofType.ts:73 Inputs that can be converted to StateProof

StateProofType

StateProofType = object
Defined in: src/primitives/StateProof/StateProofType.ts:28 StateProof represents an EIP-1186 account proof with storage proofs. EIP-1186 defines a standard for providing Merkle proofs of account state and storage values. This enables light clients and trustless systems to verify account data without executing transactions or trusting external providers. The proof structure includes:
  • Account proof: RLP-encoded Merkle Patricia Trie nodes from state root to account
  • Account fields: nonce, balance, codeHash, storageHash from the proven block
  • Storage proofs: Optional array of proofs for specific storage slots
Verification process:
  1. Verify account proof against known state root
  2. Reconstruct account state from proof
  3. Verify each storage proof against account’s storage root

See

Properties

accountProof
readonly accountProof: readonly Uint8Array[]
Defined in: src/primitives/StateProof/StateProofType.ts:39 Array of RLP-encoded Merkle Patricia Trie nodes. Forms the path from the state root to this account’s leaf node. Nodes are ordered from root to leaf.
address
readonly address: AddressType
Defined in: src/primitives/StateProof/StateProofType.ts:32 The address of the account being proven.
balance
readonly balance: WeiType
Defined in: src/primitives/StateProof/StateProofType.ts:44 Account balance in Wei at the proven block.
codeHash
readonly codeHash: HashType
Defined in: src/primitives/StateProof/StateProofType.ts:50 Keccak256 hash of the account’s bytecode. For EOAs, this is the empty code hash.
nonce
readonly nonce: NonceType
Defined in: src/primitives/StateProof/StateProofType.ts:55 Transaction count (EOA) or contract creation count.
storageHash
readonly storageHash: StateRootType
Defined in: src/primitives/StateProof/StateProofType.ts:61 Root hash of the account’s storage trie. Storage proofs must verify against this root.
storageProof
readonly storageProof: readonly StorageProofType[]
Defined in: src/primitives/StateProof/StateProofType.ts:67 Array of proofs for specific storage slots. Each proof demonstrates a key-value pair in the account’s storage.

Functions

equals()

equals(a, b): boolean
Defined in: src/primitives/StateProof/equals.js:26 Compares two StateProofs for equality. All fields must match including all storage proofs.

Parameters

a
StateProofType First StateProof
b
StateProofType Second StateProof

Returns

boolean
  • True if equal

Example

const isEqual = StateProof.equals(proof1, proof2);

from()

from(proof): StateProofType
Defined in: src/primitives/StateProof/from.js:28 Creates a StateProof from an object with all required fields.

Parameters

proof
StateProofLike Object containing all StateProof fields

Returns

StateProofType
  • A validated StateProof

Example

const proof = StateProof.from({
  address: Address.from("0x..."),
  accountProof: [node1, node2, node3],
  balance: Wei.from(1000000000000000000n),
  codeHash: Hash.from("0x..."),
  nonce: Nonce.from(5n),
  storageHash: StateRoot.from("0x..."),
  storageProof: [storageProof1, storageProof2],
});