Polygon facilitators on Amoy and
mainnet run x402 v2. Use the
@x402/*
packages shown below. If you have an existing V1 integration, see
Migration: V1 to V2.Prerequisites
Before you begin, ensure you have:- A crypto wallet with USDC on Polygon Amoy (or mainnet for production)
- Node.js 18+ with npm or Bun
- A service that requires payment via x402, or a local seller from the Quickstart for Sellers
Install dependencies
Install the x402 v2 client packages and viem for signing:Whereverbunis used, replace it withnpmor your preferred package manager.
- Fetch
- Axios
Create a wallet signer
Create a signer from your private key. In x402 v2, the client selects the correct network from the 402 response; you do not bind a chain-specific wallet client.Make paid requests automatically
- Fetch
- Axios
@x402/fetch extends the native fetch API to handle 402 responses and
payment headers for you.- Sends the request
- Receives 402 Payment Required with payment requirements
- Pays in USDC via the seller’s facilitator (Polygon Amoy:
https://x402-amoy.polygon.technology) - Retries with a
PAYMENT-SIGNATUREheader - Returns the unlocked response and a
PAYMENT-RESPONSEreceipt header
Payment schemes
Most Polygon endpoints use theexact scheme (fixed price per request).
Servers may also advertise upto (usage-based) or batch-settlement
(high-volume batched micropayments). Register the matching scheme when the server
requires it. See x402 payment schemes.
Error handling
Reference
Configuration, error codes, and guardrails.Schema
The facilitator URL is configured on the seller side. Buyers do not set it
directly; the 402 response includes payment requirements for the seller’s
facilitator.