Skip to main content
X402Adapter is the default implementation of IPaymentAdapter for the x402 payment protocol. It issues challenges locally (no on-chain call) and verifies payment proofs by inspecting ERC-20 Transfer events on Base or Base Sepolia.

Constructor

"testnet" | "mainnet"
required
The Base network to use for on-chain verification. "testnet" targets Base Sepolia (chain ID 84532); "mainnet" targets Base (chain ID 8453).
string
Optional override for the blockchain JSON-RPC endpoint. When omitted, the adapter uses the default public RPC for the selected network.

Example

IPaymentAdapter Interface

X402Adapter implements the IPaymentAdapter interface, which any payment adapter must satisfy:
The protocol property is always "x402" for this adapter.

Methods

issueChallenge

Generates a challenge payload for the client. This is a purely local operation — no on-chain transaction is required. The returned payload includes the chain ID, USDC contract address, and facilitator URL so the client knows where and how to pay. Returns a ChallengePayload with protocol: "x402" and a raw object containing:

verifyProof

Verifies a payment proof by performing on-chain checks against the transaction receipt. Returns a VerificationResult indicating success or failure with a specific error code. This method delegates to verifyTransfer, which runs the full set of on-chain verification checks described below.

Network Configuration

Both networks use USDC (6 decimals). The adapter selects the correct contract address and chain configuration automatically based on the network parameter.

On-Chain Verification

The verifyProof method performs six sequential checks against the transaction receipt. If any check fails, it returns immediately with a verified: false result and the corresponding error code. These checks enforce the security properties required for safe on-chain payment verification.

IssueChallengeParams

ChallengePayload

VerifyProofParams

VerificationResult

For full type definitions, see Data Models.