Overview
Address is a brandedUint8Array type representing Ethereum addresses. It provides compile-time type safety while maintaining zero runtime overhead.
- Type Definition
- Constants
Quick Start
- Create Address
- Convert & Format
- Checksum (EIP-55)
Why keccak256 Must Be Passed Explicitly
Voltaire requires you to passkeccak256 explicitly for checksumming and contract address derivation. This is intentional:
Tree-shaking: Keccak256 adds ~5-10 KB to your bundle. By requiring explicit injection, bundlers can eliminate this code entirely if you never use checksum methods. Libraries that hardcode crypto dependencies force you to ship code you may never use.
No global crypto dependencies: Voltaire avoids global singletons and hidden imports. Every dependency is explicit in your code, making the dependency graph predictable and auditable.
Flexibility: You can inject any keccak256 implementation - the native Zig/WASM version, a pure JS fallback, or a Web Crypto wrapper. Your choice.
API Reference
Constructors
| Method | Description |
|---|---|
Address(value) | Primary constructor - create from hex string, bytes, or number |
Address.fromHex(hex) | Create from hex string |
Address.fromBytes(bytes) | Create from Uint8Array |
Address.fromNumber(n) | Create from number or bigint |
Address.fromBase64(b64) | Create from Base64 string |
Address.fromAbiEncoded(data) | Create from 32-byte ABI-encoded data |
Address.fromPublicKey(pubKey) | Derive from secp256k1 public key |
Address.fromPrivateKey(privKey) | Derive from secp256k1 private key |
Address.zero() | Create zero address (0x000…000) |
Address.of(...bytes) | Create from individual byte values |
Conversion Methods
| Method | Description |
|---|---|
toHex() | Convert to lowercase hex string |
toLowercase() | Convert to lowercase hex string |
toUppercase() | Convert to uppercase hex string |
toChecksummed() | Convert to EIP-55 checksummed hex (requires keccak256) |
toShortHex(start?, end?) | Abbreviated hex (e.g., “0x742d…1e3e”) |
toU256() | Convert to bigint (left-padded to 256 bits) |
toAbiEncoded() | Convert to 32-byte ABI encoding |
toBytes() | Get underlying Uint8Array |
clone() | Create a copy |
Comparison Methods
| Method | Description |
|---|---|
equals(other) | Check equality |
compare(other) | Compare (-1, 0, 1) for sorting |
lessThan(other) | Check if less than other |
greaterThan(other) | Check if greater than other |
isZero() | Check if zero address |
Validation Methods
| Method | Description |
|---|---|
Address.is(value) | Type guard for AddressType |
Address.isValid(value) | Check if value is valid address format |
Address.isValidChecksum(hex) | Validate EIP-55 checksum |
Address.assert(value) | Throw if invalid |
Contract Address Derivation
| Method | Description |
|---|---|
calculateCreateAddress(nonce) | Derive CREATE address (requires keccak256 + rlpEncode) |
calculateCreate2Address(salt, initCode) | Derive CREATE2 address (requires keccak256) |
Batch Operations
| Method | Description |
|---|---|
Address.sortAddresses(addresses) | Sort array of addresses |
Address.deduplicateAddresses(addresses) | Remove duplicates |
Constants
| Constant | Value | Description |
|---|---|---|
SIZE | 20 | Address size in bytes |
HEX_SIZE | 42 | Hex string length (with 0x) |
NATIVE_ASSET_ADDRESS | 0xEeee...EEeE | ERC-7528 native ETH address |

