Skip to main content

Try it Live

Run Address examples in the interactive playground
View the complete executable example at playground/src/examples/primitives/address/checksum.ts.

Address.ToChecksummed({ keccak256 })

Factory function that creates an address-to-checksum converter with explicit crypto dependency.Parameters:
  • deps: { keccak256: (data: Uint8Array) => Uint8Array } - Crypto dependencies
Returns: (address: AddressType) => ChecksummedBundle size benefit: Crypto dependencies explicit - only bundled if you import them.Example:

EIP-55 Checksum Algorithm

The checksum encodes integrity verification in the case of hexadecimal characters:
  1. Convert address to lowercase hex (without 0x prefix)
  2. Compute keccak256 hash of lowercase hex string
  3. For each hex character:
    • If character is a letter (a-f):
      • If corresponding hash nibble >= 8: uppercase
      • Otherwise: lowercase
    • If character is a digit (0-9): unchanged
Pseudocode:

Example Walkthrough

Use Cases

User Display

Display addresses with integrity verification:

Validation

Users can manually verify addresses by comparing checksums:

QR Codes

Use checksummed addresses in QR codes for better error detection:

Wallet Integrations

Wallets expect checksummed addresses:

Cryptographic Dependencies

With the factory pattern, keccak256 is only bundled if you explicitly import it. Crypto dependencies are now explicit and tree-shakeable.
Uses keccak256 internally - Import keccak256 hash function and pass to factory. For minimal bundle size without crypto, use toHex() instead if checksums aren’t required.

Performance

Time complexity: O(n) where n = 20 bytes (constant time) Overhead: One keccak256 hash computation For repeated conversions, consider caching:

Validation

Validate checksum before using an address:

Comparison with Other Formats

See Also