Skip to main content
Ssz implements Ethereum Consensus Layer Simple Serialize (SSZ) primitives: little-endian fixed-width basic type encoding/decoding and 32-byte chunk SHA-256 hashTreeRoot Merkleization.

Quick Start

Import Ssz from @tevm/voltaire.

Basic Type Wire Layout

Unlike execution-layer ABI and RLP (big-endian), SSZ encodes all unsigned integers in little-endian byte order with fixed widths and no length prefixes:

API Reference

Edge Cases & Errors

  • encodeBasic throws RangeError for out-of-range or non-integer values on uint8, uint16, and uint32, and Error for unsupported type names.
  • decodeBasic throws Error if byte length does not match the type width, or if a bool byte is neither 0x00 nor 0x01.
  • hashTreeRoot(new Uint8Array(0)) returns 32 zero bytes.
  • RLP — Execution-layer variable-length serialization
  • SHA256 — Consensus-layer hash function
  • Blob — EIP-4844 consensus/execution data blobs