Wallet address validation utilities for x402.
This module supports EVM and Solana address formats and can detect the wallet type from a single string value.
Summary
Functions
Detects the wallet type.
Returns true when the value is a valid EVM or Solana wallet address.
Returns true for addresses in the format 0x + 40 hexadecimal characters.
Returns true for Base58 strings with length 43 or 44 (the valid range for 32-byte Solana public keys).
Functions
@spec type(term()) :: :evm | :solana | :unknown
Detects the wallet type.
Examples
iex> X402.Wallet.type("0x1111111111111111111111111111111111111111")
:evm
iex> X402.Wallet.type("9xQeWvG816bUx9EPfQmQTYnC16hHhV6bQf8kX6y4YB9")
:solana
iex> X402.Wallet.type("not-a-wallet")
:unknown
Returns true when the value is a valid EVM or Solana wallet address.
Examples
iex> X402.Wallet.valid?("0x1111111111111111111111111111111111111111")
true
iex> X402.Wallet.valid?("not-a-wallet")
false
Returns true for addresses in the format 0x + 40 hexadecimal characters.
Examples
iex> X402.Wallet.valid_evm?("0x1111111111111111111111111111111111111111")
true
iex> X402.Wallet.valid_evm?("0x123")
false
Returns true for Base58 strings with length 43 or 44 (the valid range for 32-byte Solana public keys).
Examples
iex> X402.Wallet.valid_solana?("9xQeWvG816bUx9EPfQmQTYnC16hHhV6bQf8kX6y4YB9")
true
iex> X402.Wallet.valid_solana?("invalid0base58")
false