X402.Wallet (X402 v0.3.3)

Copy Markdown View Source

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

type(wallet)

(since 0.1.0)
@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

valid?(wallet)

(since 0.1.0)
@spec valid?(term()) :: boolean()

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

valid_evm?(wallet)

(since 0.1.0)
@spec valid_evm?(term()) :: boolean()

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

valid_solana?(wallet)

(since 0.1.0)
@spec valid_solana?(term()) :: boolean()

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