Skip to main content

Try it Live

Run Address examples in the interactive playground

Address Variants

Branded hex string types representing different address formats with compile-time guarantees.

Overview

Address variants provide type-safe hex strings with specific casing guarantees:
  • Checksummed - EIP-55 mixed-case format for display and verification
  • Lowercase - All lowercase hex for canonical storage
  • Uppercase - All uppercase hex for specific protocols
Each variant is a branded hex string type extending Hex.Sized<20>, not a Uint8Array.

ChecksumAddress

EIP-55 checksummed address format with mixed casing based on keccak256 hash.

Address.Checksummed.from(addr)

Create checksummed hex string from Address.
const addr = Address("0x742d35cc6634c0532925a3b844bc9e7595f51e3e")

// Get checksummed string
const checksummed = Address.Checksummed(addr)
// "0x742d35Cc6634C0532925a3b844Bc9e7595f51e3e" (mixed case)

// Type is branded Checksummed, not AddressType
typeof checksummed // "string"
Parameters:
  • addr: AddressType - Address to checksum
Returns: Checksummed - Branded checksummed hex string Type:
import type { Hex } from 'tevm'

type Checksummed = Hex.Sized<20> & {
  readonly __variant: 'Address'
  readonly __checksummed: true
}
Defined in: primitives/Address/AddressType/ChecksumAddress.js:23 Note: Uses keccak256 internally.

Address.Checksummed.isValid(str)

Validate EIP-55 checksum of address string.
// Valid checksummed
Address.Checksummed.isValid("0x742d35Cc6634C0532925a3b844Bc9e7595f51e3e") // true

// Invalid checksum (wrong casing)
Address.Checksummed.isValid("0x742d35cc6634c0532925a3b844bc9e7595f51e3e") // false
Address.Checksummed.isValid("0x742D35CC6634C0532925A3B844BC9E7595F51E3E") // false

// All lowercase/uppercase passes (no mixed case = no checksum)
Address.Checksummed.isValid("0x742d35cc6634c0532925a3b844bc9e7595f51e3e") // true
Address.Checksummed.isValid("0x742D35CC6634C0532925A3B844BC9E7595F51E3E") // true
Parameters:
  • str: string - Address string to validate
Returns: boolean Defined in: primitives/Address/AddressType/ChecksumAddress.js:55 EIP-55 Logic:
  • If all letters same case (all lower or all upper), valid
  • If mixed case, each letter’s case must match keccak256-based checksum

LowercaseAddress

All lowercase hex format for canonical representation.

Address.Lowercase.from(addr)

Create lowercase hex string from Address.
const addr = Address("0x742D35CC6634C0532925A3B844BC9E7595F51E3E")

const lowercase = Address.Lowercase(addr)
// "0x742d35cc6634c0532925a3b844bc9e7595f51e3e"
Parameters:
  • addr: AddressType - Address to convert
Returns: Lowercase - Branded lowercase hex string Type:
import type { Hex } from 'tevm'

type Lowercase = Hex.Sized<20> & {
  readonly __variant: 'Address'
  readonly __lowercase: true
}
Defined in: primitives/Address/AddressType/LowercaseAddress.js:20

UppercaseAddress

All uppercase hex format.

Address.Uppercase.from(addr)

Create uppercase hex string from Address.
const addr = Address("0x742d35cc6634c0532925a3b844bc9e7595f51e3e")

const uppercase = Address.Uppercase(addr)
// "0x742D35CC6634C0532925A3B844BC9E7595F51E3E"
Parameters:
  • addr: AddressType - Address to convert
Returns: Uppercase - Branded uppercase hex string Type:
import type { Hex } from 'tevm'

type Uppercase = Hex.Sized<20> & {
  readonly __variant: 'Address'
  readonly __uppercase: true
}
Defined in: primitives/Address/AddressType/UppercaseAddress.js:20

Variant Comparison

VariantCasingUse CaseKeccak256 Needed
ChecksummedMixedDisplay, verificationYes
LowercaseAll lowerCanonical storage, comparisonNo
UppercaseAll upperSpecific protocolsNo