Skip to main content
Bytes (BytesType) is a branded arbitrary-length Uint8Array with safe construction, concatenation, padding, trimming, slicing, lexicographic comparison, and integer/hex/UTF-8 conversions.

Quick Start

Import from @tevm/voltaire or @tevm/voltaire/Bytes.

Fixed-Size Variants

@tevm/voltaire exports fixed-length branded byte types that enforce exact byte length at construction:

API Reference

Constructors & Factories

Transformations & Queries

Conversions

Edge Cases

  • Bytes.padLeft and Bytes.padRight throw SizeExceededError if bytes.length > size.
  • Bytes.fromBigInt and Bytes.fromNumber reject negative inputs and values that exceed an explicit size.
  • Bytes.toNumber throws on values above Number.MAX_SAFE_INTEGER (2^53 - 1); use Bytes.toBigInt for larger values.
  • Bytes32 — Fixed 32-byte EVM word primitive
  • Hex — 0x-prefixed hexadecimal string primitive
  • Hash — 32-byte cryptographic digest