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:
protocol property is always "x402" for this adapter.
Methods
issueChallenge
ChallengePayload with protocol: "x402" and a raw object containing:
verifyProof
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
TheverifyProof 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.
Related Types
IssueChallengeParams
ChallengePayload
VerifyProofParams
VerificationResult
For full type definitions, see Data Models.

