API Reference X402 v#0.9.6

Copy Markdown View Source

Modules

Convenience API for working with x402 payment headers and wallet addresses.

The auth-capture payment scheme: flows, operations, deadlines, lifecycle payloads, and reason strings.

Volatile, serialized auth-capture store for development and tests.

EVM binding primitives for the auth-capture scheme: commerce-payments deployments, PaymentInfo hashing, authorizer typed data, and AuthCaptureEscrow calldata.

Explicit-consent auth-capture transaction execution and reconciliation.

Durable signer-scope fencing for auth-capture transactions.

Strict auth-capture receipt identity and escrow-event checks.

Durable hold-before-handler orchestration for auth-capture escrow resources.

Atomic storage contract for auth-capture execution and recovery.

Base58 encoding and decoding using the Bitcoin alphabet.

Utilities for working with Elixir behaviours and callback implementations.

Transport-agnostic payer client for x402 v2 payments.

A session spend budget shared by payer clients.

Finch-backed payer client with an automatic 402 → sign → retry flow.

Behaviour for lifecycle hooks around client payment creation.

Context passed between X402.Client.Hooks callbacks.

Default no-op implementation of X402.Client.Hooks.

Ready-made selection policies for X402.Client.select_requirements/2.

Client side of the sign-in-with-x extension: answering a challenge.

EIP-3009 TransferWithAuthorization building and EIP-712 signing.

Generic EIP-712 hashing primitives.

ERC-6492 signature wrapper parsing and building.

Behaviour for resource-server extension adapters run by X402.Plug.PaymentGate.

Encodes and decodes the EXTENSION-RESPONSES facilitator sidechannel.

The x402 auth-hints extension: per-requirement authentication hints.

X402.Extension adapter advertising the auth-hints extension.

Bazaar discovery extension for x402 v2: extension builder and discovery client.

Validation rules for bazaar service metadata and routeTemplate values.

The x402 builder-code extension: ERC-8021 on-chain attribution codes.

X402.Extension adapter advertising and validating the builder-code extension.

Builds, signs, and validates the eip2612GasSponsoring extension.

Builds and validates the erc20ApprovalGasSponsoring extension.

The x402 http-message-signatures extension: identity through RFC 9421.

X402.Extension adapter advertising the http-message-signatures extension.

Offer-and-receipt extension for x402: signed offers and signed receipts.

Compact JWS signing and verification for the offer-receipt extension.

The x402 payment-identifier extension: client-generated idempotency ids.

X402.Extension adapter advertising the payment-identifier extension.

Behaviour and adapter helpers for payment identifier idempotency caches.

ETS-backed cache adapter for payment identifier idempotency.

Redis-backed cache adapter for payment identifier idempotency.

The x402 sign-in-with-x extension: CAIP-122 wallet authentication.

Server-side Sign-In-With-X challenge advertisements.

ETS-backed SIWX storage with TTL-based expiration.

CAIP-122 message text for Sign-In-With-X challenges.

Server-side Sign-In-With-X: challenge issuance, proof verification, and payer records.

Behaviour for storing SIWX access records.

Behaviour for SIWX signature verification.

Default EVM SIWX signature verifier using ex_secp256k1.

SIWX signature verifier for Solana (solana:*) wallets.

Client for the x402 facilitator API: verify, settle, supported, discovery.

Behaviour for facilitator request authentication.

Authentication for the Coinbase Developer Platform (CDP) x402 facilitator.

Facilitator-role engine: verify and settle x402 payments yourself.

Structured error returned by facilitator client operations.

Multi-endpoint failover policy for X402.Facilitator.

HTTP transport for facilitator requests.

Serializes fee-payer transaction nonces for concurrent settlements.

Behaviour for pending-settlement reconciliation stores.

ETS-backed pending-settlement store adapter.

Facilitator-role engine for exact payments on Solana (solana:*).

RFC 9421 HTTP Message Signatures: sign and verify requests and responses.

Key material for RFC 9421 HTTP Message Signatures.

The RFC 8941 Structured Field subset used by HTTP Message Signatures.

Behaviour for lifecycle hooks around facilitator verify and settle operations.

Context passed between x402 lifecycle hook callbacks.

Default no-op implementation of X402.Hooks.

Context of a protected request passed to the resource-server lifecycle hooks.

x402 v2 payment flows over the Model Context Protocol (MCP transport).

Client half of the x402 MCP transport: pay for tool calls automatically.

Server half of the x402 MCP transport: gates a tool handler behind payment.

Encodes and decodes the x402 PAYMENT-REQUIRED header value.

Validation and matching helpers for x402 v2 payment requirements.

Encodes and decodes the x402 PAYMENT-RESPONSE header value.

Decodes and validates x402 v2 PAYMENT-SIGNATURE header values.

Behaviour for rendering browser-facing HTML paywall pages.

Self-contained HTML paywall page for browser-facing 402 responses.

Permit2 PermitWitnessTransferFrom building, EIP-712 signing, and proxy settlement calldata for the x402 exact (Permit2 transfer method) and upto schemes on EVM networks.

Plug scaffold exposing one or more facilitator engines as the facilitator HTTP API.

Plug serving a signature agent's key directory at /.well-known/http-message-signatures-directory.

Plug middleware that gates configured routes behind x402 v2 payment verification.

Minimal pure RLP (Recursive Length Prefix) encoding.

Minimal Ethereum JSON-RPC client over Finch.

Behaviour and option handling for per-wallet request rate limiting.

Per-node fixed-window rate limiter backed by a lazily created ETS table.

Behaviour for pluggable x402 payment schemes.

Built-in X402.Scheme for auth-capture payments on EVM (eip155:*) networks.

Shared local pre-checks for EVM authorization-style scheme payloads.

Built-in X402.Scheme for exact payments on EVM (eip155:*) networks.

Built-in X402.Scheme for exact payments on Solana (solana:*) networks.

Resolves (scheme, network) pairs to X402.Scheme modules.

Built-in X402.Scheme for upto payments on EVM (eip155:*) networks.

Behaviour for client-side payment signers.

X402.Signer backed by a raw secp256k1 private key held in memory.

X402.Signer backed by a raw Ed25519 private key held in memory.

Solana address primitives: program IDs, PDA and ATA derivation.

Minimal Solana JSON-RPC calls over an X402.RPC endpoint.

Solana v0 transaction message building, serialization, and decoding.

Telemetry event definitions and emission helpers for x402 operations.

Telemetry.Metrics definitions for every x402 telemetry event.

Dependency-free in-memory aggregator for x402 telemetry events.

Minimal EIP-1559 (type-2) transaction encoding and signing digests.

Shared utility functions for the X402 library.

Verification of auth-capture payments on EVM networks.

Local verification of EVM exact (EIP-3009 and Permit2) and upto (Permit2) payment payloads.

Local verification of SVM exact payment payloads.

Wallet address validation utilities for x402.