Try it Live
Run Address examples in the interactive playground
- TypeScript - Factory
- C
Address.ToChecksummed({ keccak256 })
Factory function that creates an address-to-checksum converter with explicit crypto dependency.Parameters:deps: { keccak256: (data: Uint8Array) => Uint8Array }- Crypto dependencies
(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:- Convert address to lowercase hex (without
0xprefix) - Compute keccak256 hash of lowercase hex string
- 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
- If character is a letter (a-f):
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
Uses keccak256 internally - Import keccak256 hash function and pass to factory. For minimal bundle size without crypto, usetoHex() 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
- toHex - Convert to lowercase hex
- isValidChecksum - Validate EIP-55 checksum
- fromHex - Parse from hex string
- EIP-55: Mixed-case checksum
- Keccak256 - Keccak256 hash function

