Skip to main content

Overview

Bytes provides variable-length and fixed-size byte array types used throughout Ethereum. The module includes:
  • Bytes - Variable-length byte arrays
  • Bytes1-Bytes8 - Small fixed-size types (1-8 bytes)
  • Bytes16 - 16-byte fixed type (UUIDs, nonces)
  • Bytes32 - 32-byte fixed type (storage, hashes)
  • Bytes64 - 64-byte fixed type (signatures, public keys)
All types are branded Uint8Array values with zero runtime overhead.
Bytes types are branded Uint8Array values. TypeScript enforces type safety through a unique Symbol brand, preventing accidental mixing with other Uint8Arrays.

Quick Start

Variable-Length Bytes API

Constructors

Conversions

Manipulation

Comparisons

Validation

Fixed-Size Types

Bytes32

32-byte fixed type for storage values, numeric representations, and general-purpose 32-byte data.

Bytes64

64-byte fixed type for signatures and uncompressed public keys.

Bytes16

16-byte fixed type for UUIDs and nonces.

Bytes1-Bytes8

Small fixed-size types for packed data.

Error Types

Usage Patterns

Working with Storage Values

Building Calldata

Random Data Generation

Tree-Shaking

Import only what you need for optimal bundle size:

Constants

  • Bytes (Effect) - Effect.ts integration with Schema validation
  • Hex - Hex string encoding/decoding
  • Address - 20-byte Ethereum addresses
  • Hash - Cryptographic hash types
  • Uint - Unsigned integer types