Skip to main content

Try it Live

Run Address examples in the interactive playground

WASM Implementation

WebAssembly-accelerated implementations of Address methods, compiled from Zig using ReleaseSmall mode.

Overview

WASM implementations provide performance-critical operations using compiled Zig code targeting WebAssembly. These are purely opt-in replacements for the JavaScript implementations with identical APIs. All WASM methods are compiled from address.zig with ReleaseSmall optimization targeting minimal bundle size.

Quick Start

// Import WASM implementation instead of JS version
import { Address } from 'tevm/Address.wasm'

// API is identical to JS version
const addr = Address("0x742d35Cc6634C0532925a3b844Bc9e7595f51e3e")
addr.toChecksummed() // Uses WASM acceleration
addr.equals(other)    // Uses WASM acceleration

Performance

WASM implementations provide significant speedup for computationally intensive operations:
  • Hex parsing - Native byte manipulation vs JavaScript string operations
  • Checksumming - keccak256 hashing in compiled code
  • Comparisons - Memory-efficient byte-by-byte comparison
  • Contract address calculation - RLP encoding and hashing in Zig
Use WASM when processing large numbers of addresses (bulk validation, sorting, checksum verification). For single operations, JS overhead may outweigh WASM benefits.

API Reference

WASM implementations match the standard Address API. See main documentation:
  • Constructors - fromHex, fromBytes, fromNumber, fromPublicKey, fromAbiEncoded
  • Conversions - toHex, toChecksummed, toLowercase, toUppercase, toU256, toAbiEncoded, toShortHex
  • Validation - isValid, isValidChecksum, is
  • Comparisons - equals, compare, lessThan, greaterThan, isZero
  • Contract Addresses - calculateCreateAddress, calculateCreate2Address