Skip to main content
Tree-shakeable functional API for CallData operations with optimal bundle size.

Overview

CallDataType is the functional layer underlying the CallData class. It provides:
  • Zero-overhead branded type wrapping Uint8Array
  • Tree-shakeable individual function exports
  • Data-first unopinionated methods taking calldata as first parameter
  • Bundle optimization through selective imports
Primary benefit: When using tree-shakeable imports, only the functions you use are included in your bundle.

Type Definition

CallDataType (Uint8Array)

The core CallData type is a branded Uint8Array:
Properties:
  • Size: Variable length (minimum 4 bytes for selector)
  • Branding: Uses Symbol branding via brand symbol
  • Conceptual relation: Subtypes Hex (variable-length hex-encoded byte data)
  • Type safety: Prevents accidental mixing with other Uint8Arrays or arbitrary Hex values
Defined in: primitives/CallData/CallDataType.ts

Relationship to Hex

CallData is conceptually a Hex subtype with additional semantics:
While CallData uses Uint8Array internally for performance, it represents hex-encoded data that:
  1. Starts with a 4-byte function selector
  2. Follows with ABI-encoded parameters
  3. Validates to proper calldata structure

CallDataDecoded Structure

The decoded form represents parsed calldata:
Fields:
  • selector - Required 4-byte function identifier
  • signature - Optional human-readable function signature
  • parameters - Decoded parameters as structured ABI values
  • allocator - Memory management (Zig implementation)

Available Functions

All CallData functionality available as tree-shakeable functions:

Constructors

Conversions

Selectors

Validation

Comparisons

Usage Patterns

Tree-Shakeable Imports

Import only what you need:

Functional Style

Data-first API for composition:

With Class API

Mix with class API when convenient:

Dual API Pattern

CallData provides both functional and class-based APIs:
Benefits:
  • Tree-shakeable
  • Functional composition
  • Minimal bundle impact

TypeScript vs Zig

See Also