Try it Live
Run Address examples in the interactive playground
AddressType
Tree-shakeable functional API for Address operations with optimal bundle size.Overview
AddressType is the functional layer underlying the Address class. It provides:
- Zero-overhead branded type wrapping
Uint8Array(20 bytes) - Tree-shakeable individual function exports
- Data-first unopinionated methods taking address as first parameter
- Bundle optimization through selective imports
Type Definition
AddressType (Uint8Array)
The core Address type is a branded 20-byteUint8Array:
- Size: Always 20 bytes (160 bits)
- Branding: Uses Symbol branding via
brandsymbol - Conceptual relation: Represents a fixed 20-byte value (conceptually like
BrandedBytes<20>) - Type safety: Prevents accidental mixing with other Uint8Arrays
HexAddress Variants
Address also provides hex string variants that extendHex.Sized<20>:
- Base
Hex.Sized<20>: 20-byte hex string type from Hex primitive using symbol branding - ChecksumAddress: EIP-55 checksummed (mixed case for integrity)
- LowercaseAddress: All lowercase hex (e.g.,
"0x742d35cc...") - UppercaseAddress: All uppercase hex (e.g.,
"0x742D35CC...") - Symbol branding: Uses
brandsymbol (Symbol.for("type")) for nominal typing
Available Functions
All Address functionality available as tree-shakeable functions:Constructors
Conversions
toChecksummed includes keccak256.
Comparisons
Validation
isValidChecksum includes keccak256.
Contract Addresses
calculateCreateAddress also includes RLP.
Variants
AddressType (Uint8Array) to hex string variants (ChecksumAddress, LowercaseAddress, UppercaseAddress).
See Variants for details.
Data-First Pattern
All AddressType functions follow data-first pattern:Tree-Shaking Benefits
Primary benefit: Selective inclusion of crypto dependenciesExample 1: Minimal Bundle (No Crypto)
Example 2: With Checksum (Keccak256 Only)
Example 3: With CREATE (Keccak256 + RLP)
Example 4: Address Class (Everything)
Dependency Table
| Method/Function | Keccak256 | Secp256k1 | RLP | Notes |
|---|---|---|---|---|
from, fromHex, fromBytes, fromNumber | ✗ | ✗ | ✗ | Pure conversions |
fromPublicKey | ✓ | ✗ | ✗ | Derives address from pubkey |
fromPrivateKey | ✓ | ✓ | ✗ | Derives address from privkey |
toHex, toU256, toLowercase, toUppercase | ✗ | ✗ | ✗ | Pure conversions |
toChecksummed | ✓ | ✗ | ✗ | EIP-55 checksumming |
isValidChecksum | ✓ | ✗ | ✗ | EIP-55 validation |
ChecksumAddress.from, ChecksumAddress.isValid | ✓ | ✗ | ✗ | EIP-55 operations |
equals, compare, lessThan, greaterThan | ✗ | ✗ | ✗ | Byte comparisons |
isZero, isValid, is | ✗ | ✗ | ✗ | Basic validation |
calculateCreateAddress | ✓ | ✗ | ✓ | CREATE opcode |
calculateCreate2Address | ✓ | ✗ | ✗ | CREATE2 opcode |
| Address class | ✓ | ✓ | ✓ | All methods on prototype |
When to Use AddressType vs Address
Use AddressType When:
- Bundle size critical (mobile, embedded)
- Avoiding crypto dependencies
- Functional style preferred
- Selective imports desired
- Composing functions heavily
Use Address Class When:
- OOP style preferred
- Ergonomics over bundle size
- Using many methods (crypto already in bundle)
- Type safety with prototype methods
- Traditional API expected
Interoperability
AddressType and Address Class
AddressType and Address are fully compatible:AddressType and Hex Variants
AddressType (Uint8Array) and hex string variants are separate types with conversion functions:- AddressType: 20-byte Uint8Array (runtime data)
- HexAddress variants: Hex.Sized (20-byte) strings (display/serialization)
Constants
Related
Address Documentation:- Address - Main Address class documentation
- Constructors - Creating addresses
- Conversions - Format conversions
- Comparisons - Equality and ordering
- Validation - Input validation
- Contract Addresses - CREATE/CREATE2
- Variants - Checksummed/Lowercase/Uppercase

