The Two APIs
Constructor API (Recommended)
TheAddress() constructor returns instances with prototype methods:
Address brings in all methods (~18 KB). Use this API for applications where developer experience matters more than bundle size.
Functional API (Tree-Shakeable)
Import individual functions from theBranded* namespace exports:
How Methods are Written
All Voltaire methods are written as standalone functions first, then attached to constructors:- Instance method:
addr.toHex() - Static method:
Address.toHex(addr) - Standalone function:
toHex(addr)
Available Namespace Exports
Each primitive has aBranded* namespace export:
Comparison
| Import Style | Bundle Impact | Usage |
|---|---|---|
import { Address } | ~18 KB | Full API with methods |
import { BrandedAddress } | ~18 KB | Functional namespace |
import { toHex } from '@tevm/voltaire/Address' | ~500 bytes | Only specific functions |
Converting Between APIs
Converting from constructor API to functional API is mechanical - just move the object to the first parameter:When to Use Each
Use Constructor API when:- Building applications (DX matters)
- Bundle size is not critical
- You want autocomplete on instances
- Building libraries (minimize impact on users)
- Every KB matters (mobile, embedded)
- You only need a few functions
Crypto Dependencies
Some functions require crypto dependencies. The functional API exposes factory functions for these:toChecksummed, calculateCreateAddress) have crypto pre-injected for convenience.

