Integrate x402 with PonponPay
Create protected resource rules in the dashboard, then use the PonponPay SDK in server-side routes. The SDK handles the 402 challenge, payment verification, and settlement calls.
Integration flow
- Create a Resource configuration on the x402 Agent Payments page in the dashboard.
- Set the public resource URL, HTTP method, price, network, USDC contract, and settlement wallet.
- Install and initialize the PonponPay SDK in a server-side route. Keep the API Key only in server environment variables.
- Wrap the protected route with the SDK. Unpaid requests return 402; paid requests continue to the business response.
- Review Payment records in the dashboard to track verification, settlement, and on-chain transaction status.
Server-side SDK examples
x402 must run server-side with API Key mode. Never expose API Keys or settlement logic in browser bundles.
import { ponponpayX402 } from '@ponponpay/sdk/x402';
const x402 = ponponpayX402({
apiKey: process.env.PONPONPAY_API_KEY!,
resource: {
resource: 'https://merchant.example.com/api/premium-data',
method: 'GET',
price: '$0.01',
maxAmountRequired: '10000',
network: 'eip155:8453',
asset: 'USDC',
payTo: '0xYourMerchantSettlementWallet',
description: 'Premium market data'
}
});
export async function GET(request: Request) {
const result = await x402.verifyAndSettle(request);
if (!result.paid) {
return result.required();
}
return Response.json({ data: 'premium payload' });
}Supported networks
Current support is limited to the standard EVM exact flow using Circle USDC transferWithAuthorization.
| Network | CAIP-2 | USDC Contract |
|---|---|---|
| Base | eip155:8453 | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 |
| Ethereum | eip155:1 | 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 |
| Polygon | eip155:137 | 0x3c499c542cef5e3811e1192ce70d8cc03d5c3359 |
Platform validation rules
- The scheme must be exact.
- network, asset, assetContract, payTo, and amount must match the resource requirement.
- resource URL and HTTP method are bound to the current request and must match.
- validAfter / validBefore must be within the allowed window, and each nonce can settle only once.
- The EIP-712 signature must recover authorization.from.
Unsupported chains
BSC, Tron, Solana, TON, and BTC are not part of the current standard EVM exact flow. Supporting them later requires a separate x402 scheme or PonponPay extension.