Use this file to discover all available pages before exploring further.
Ethereum addresses are 20-byte identifiers for accounts and contracts. The Address primitive provides type-safe construction, validation, EIP-55 checksumming, and contract address derivation.
import * as Address from '@tevm/voltaire/Address';// From hex stringconst addr = Address("0x742d35Cc6634C0532925a3b844Bc9e7595f51e3e");// From bytesconst fromBytes = Address.fromBytes(new Uint8Array(20));// From number/bigintconst fromNumber = Address.fromNumber(0x123n);// Zero addressconst zero = Address.zero();
import * as Address from '@tevm/voltaire/Address';const addr = Address("0x742d35Cc6634C0532925a3b844Bc9e7595f51e3e");// Hex representationsaddr.toHex(); // "0x742d35cc6634c0532925a3b844bc9e7595f51e3e"addr.toLowercase(); // "0x742d35cc6634c0532925a3b844bc9e7595f51e3e"addr.toUppercase(); // "0x742D35CC6634C0532925A3B844BC9E7595F51E3E"addr.toShortHex(); // "0x742d...1e3e"// Numeric representationaddr.toU256(); // bigint (left-padded to 256 bits)// ABI encodingaddr.toAbiEncoded(); // 32-byte Uint8Array (left-padded)
import * as Address from '@tevm/voltaire/Address';import { keccak256 } from '@tevm/voltaire/Keccak256';// Create with crypto dependency for checksum methodsconst addr = Address( "0x742d35Cc6634C0532925a3b844Bc9e7595f51e3e", { keccak256 });// Get checksummed representationaddr.toChecksummed(); // "0x742d35Cc6634C0532925a3b844Bc9e7595f51e3e"// Validate checksumAddress.isValidChecksum("0x742d35Cc6634C0532925a3b844Bc9e7595f51e3e"); // trueAddress.isValidChecksum("0x742d35cc6634c0532925a3b844bc9e7595f51e3e"); // false
Voltaire requires you to pass keccak256 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.
import * as Address from '@tevm/voltaire/Address';import { keccak256 } from '@tevm/voltaire/Keccak256';// Methods that DON'T need keccak256 - no injection requiredconst addr = Address("0x742d35Cc6634C0532925a3b844Bc9e7595f51e3e");addr.toHex(); // worksaddr.toLowercase(); // worksaddr.equals(other); // works// Methods that DO need keccak256 - inject via optionsconst addrWithCrypto = Address( "0x742d35Cc6634C0532925a3b844Bc9e7595f51e3e", { keccak256 });addrWithCrypto.toChecksummed(); // worksaddrWithCrypto.calculateCreate2Address(); // works
import * as Address from '@tevm/voltaire/Address';// From 65-byte uncompressed public key (0x04 prefix + 64 bytes)const pubKey = new Uint8Array(65);pubKey[0] = 0x04;// ... set x and y coordinatesconst fromPubKey = Address.fromPublicKey(pubKey);// From 32-byte private keyconst privateKey = new Uint8Array(32);// ... fill with private key bytesconst fromPrivKey = Address.fromPrivateKey(privateKey);// From x,y coordinates as bigintsconst x = 0x1234...n;const y = 0x5678...n;const fromCoords = Address.fromPublicKey(x, y);
The branded type prevents mixing addresses with other byte arrays:
import * as Address from '@tevm/voltaire/Address';import * as Hash from '@tevm/voltaire/Hash';const addr: AddressType = Address("0x742d35Cc6634C0532925a3b844Bc9e7595f51e3e");const hash: HashType = Hash("0x" + "ab".repeat(32));// TypeScript error: Address and Hash are incompatible// even though both are Uint8Array at runtimefunction processAddress(a: AddressType) { ... }processAddress(hash); // Error!