Skip to main content

Try it Live

Run Chain examples in the interactive playground

BrandedChain

Tree-shakeable functional API for Chain operations with optimal bundle size.

Overview

BrandedChain is the functional layer underlying the Chain class. It provides:
  • Zero-overhead type wrapping for chain configuration objects
  • Tree-shakeable individual function exports
  • Data-first unopinionated methods taking chain as first parameter
  • Bundle optimization through selective imports
Primary benefit: When using tree-shakeable imports, you can include only the specific chain lookup functionality you need, or import individual chain objects to minimize bundle size.

Type Definition

Plain JavaScript object with chain configuration. No special branding beyond TypeScript type safety. Defined in: primitives/Chain/ChainType.ts

Available Functions

All Chain functionality available as tree-shakeable functions:

Constructors

See Constructors for details.

Chain Lookup

See Chain Lookup for details.

Data-First Pattern

All BrandedChain functions follow data-first pattern:
This enables functional composition and partial application:

Tree-Shaking Strategies

Strategy 1: Import Specific Chains (Smallest Bundle)

Best for: Applications using a fixed set of known chains.
Bundle size: ~1KB (only the chains you import)

Strategy 2: Import Registry Functions (Larger Bundle)

Best for: Applications with dynamic chain selection.
Bundle size: ~150KB (entire chain registry with 800+ chains)

Strategy 3: Hybrid Approach (Balanced)

Best for: Applications with common chains but occasional dynamic lookup.
Bundle size: ~150KB (but common chains fast-path)

Strategy 4: Code Splitting (Best of Both)

Best for: Large applications with route-based chain usage.
Bundle size:
  • Main bundle: ~1KB
  • Admin bundle: +150KB (loaded on demand)

Bundle Size Comparison

* Full registry included † Loaded on demand

Usage Examples

Minimal Bundle (Fixed Chains)

Dynamic Chain Loading

Multi-Chain Application

Functional Composition

Type-Safe Chain Operations

When to Use BrandedChain vs Chain

Use BrandedChain When:

  • Bundle size critical (mobile, embedded)
  • Fixed chain set (production apps)
  • Tree-shaking important
  • Functional style preferred
  • Direct imports from tevm/chains

Use Chain Class When:

  • Dynamic chains needed
  • Convenience over size
  • Traditional API preferred
  • Prototype methods desired

Interoperability

BrandedChain and Chain are fully compatible:

Re-exports from tevm/chains

BrandedChain re-exports all chains from tevm/chains:
This provides a single import path for all chain-related functionality.