Checksummed is a branded hex string type representing an Ethereum address with EIP-55 checksum encoding. Unlike AddressType (a Uint8Array), Checksummed is a string with mixed casing that encodes integrity verification in the character case.Key characteristics:
import * as ChecksumAddress from 'tevm/Address/ChecksumAddress'import { hash as keccak256 } from 'tevm/crypto/Keccak256'// Create factory function with crypto dependencyconst from = ChecksumAddress.From({ keccak256 })// Various input formatsfrom("0x742d35cc6634c0532925a3b844bc9e7595f51e3e")// "0x742d35Cc6634C0532925a3b844Bc9e7595f51e3e"from(69n)// "0x0000000000000000000000000000000000000045"from(addr) // AddressType// "0x742d35Cc6634C0532925a3b844Bc9e7595f51e3e"
Returns:(value: number | bigint | string | Uint8Array) => ChecksummedBundle size benefit: Crypto dependencies explicit - only bundled if you import them.Example:
Copy
Ask AI
import { From } from 'tevm/Address/ChecksumAddress'import { hash as keccak256 } from 'tevm/crypto/Keccak256'// Create factory with explicit crypto dependencyconst from = From({ keccak256 })// Use the created functionconst checksummed = from("0x742d35cc6634c0532925a3b844bc9e7595f51e3e")// "0x742d35Cc6634C0532925a3b844Bc9e7595f51e3e"
If all letters same case (all lower OR all upper), valid
If mixed case, each letter’s case must match keccak256-based checksum
Zero address with all same case always valid
Example:
Copy
Ask AI
import * as ChecksumAddress from 'tevm/Address/ChecksumAddress'import { hash as keccak256 } from 'tevm/crypto/Keccak256'// Create factory function with crypto dependencyconst isValid = ChecksumAddress.IsValid({ keccak256 })// Correct checksumisValid("0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed")// true// Wrong case on one characterisValid("0x5aaeb6053F3E94C9b9A09f33669435E7Ef1BeAed")// false (first 'A' should be uppercase)// All lowercase (no mixed case = no checksum requirement)isValid("0x5aaeb6053f3e94c9b9a09f33669435e7ef1beaed")// true// All uppercase (no mixed case = no checksum requirement)isValid("0x5AAEB6053F3E94C9B9A09F33669435E7EF1BEAED")// true
The checksum encodes integrity verification in hexadecimal character casing:
Convert address to lowercase hex (without 0x prefix)
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
Pseudocode:
Copy
Ask AI
lowercase = address.toHex().slice(2) // Remove 0xhash = keccak256(lowercase)result = "0x"for i in 0..39: char = lowercase[i] if char is letter: hashNibble = hash[i/2] nibble at position (i % 2) if hashNibble >= 8: result += char.toUpperCase() else: result += char.toLowerCase() else: result += char
With the factory pattern, keccak256 is only bundled if you explicitly import it. Crypto dependencies are now explicit and tree-shakeable.
Tree-shaking:
ChecksumAddress.From({ keccak256 }) → Crypto dependencies explicit - only bundled if imported
ChecksumAddress.IsValid({ keccak256 }) → Crypto dependencies explicit - only bundled if imported
Address.toLowercase() → No crypto dependencies
Address.toUppercase() → No crypto dependencies
Selective imports for optimal bundle size:
Copy
Ask AI
// Minimal bundle (no crypto)import { from, toHex } from 'tevm/Address'// With checksumming - explicit crypto importimport { From } from 'tevm/Address/ChecksumAddress'import { hash as keccak256 } from 'tevm/crypto/Keccak256'const from = From({ keccak256 })