x402 Payment Protocol Integration Skill — SKILL.md for Agent HTTP Payments
$0.03 / access
SKILL.md protocol
The x402-integration-skill is a step-by-step integration guide for implementing x402 HTTP micropayments in AI agents. Covers the full flow: probe request, 402 response parsing, USDC payment execution on Base L2, X-Payment header retry, stale payment detection, and error handling — with production-ready TypeScript patterns. Endorsed by Google, Coinbase, Cloudflare, and Stripe.
From zero to paying agent in one session: The protocol covers every step of the x402 integration — probe, parse, pay, retry, error handle. Unlike the
x402-agent-commerce-skill (which covers marketplace discovery and spend tracking), this skill is focused purely on the payment protocol layer: the HTTP 402 flow, USDC transfer, and confirmation handling.
Protocol Overview
| Step | What It Covers |
| Step 1: Probe Request | Send unauthenticated GET request, expect 402, parse payment instructions JSON |
| Step 2: Parse Payment Instructions | Validate price, currency, address, chain, expiresAt — check expiry and budget ceiling before paying |
| Step 3: USDC Payment on Base L2 | ethers.js USDC transfer pattern, 6-decimal encoding, tx.wait() for on-chain confirmation |
| Step 4: Retry with Payment Header | X-Payment header encoding, retry logic for unconfirmed payments, 410 expiry handling |
| Step 5: Full Implementation | Production TypeScript pattern with budget ceiling, max retries, and complete error handling |
| Error Handling Reference | Status code matrix: 402 (first), 402 (after pay), 200, 410, 400 — with correct action for each |
Protocol Excerpt
## Step 3: Execute USDC Payment on Base L2
import { ethers } from 'ethers';
const USDC_BASE = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913';
const USDC_ABI = ['function transfer(address to, uint256 amount) returns (bool)'];
const provider = new ethers.JsonRpcProvider('https://mainnet.base.org');
const wallet = new ethers.Wallet(process.env.AGENT_PRIVATE_KEY!, provider);
const usdc = new ethers.Contract(USDC_BASE, USDC_ABI, wallet);
// USDC has 6 decimal places
const amount = ethers.parseUnits(paymentInstructions.price, 6);
const tx = await usdc.transfer(paymentInstructions.address, amount);
const receipt = await tx.wait();
...
[full protocol requires $0.03 access via x402 — free preview at /v1/preview/x402-integration-skill]
Use Cases
- x402 integration bootstrapping — fastest path to a working agent payment implementation; covers every step from first 402 to confirmed receipt
- Agent payment hardening — add budget ceiling enforcement, stale payment detection (410), and retry backoff to an existing x402 implementation
- Multi-API agents — reusable
fetchWithX402(url, wallet) pattern works with any x402-compliant API, not just ClawMerchants
- CI/CD payment agents — integrate x402 data fetches (security intel, dependency CVEs) into pipeline agents with per-call budget controls
How to Access via x402
- Free preview:
GET https://clawmerchants.com/v1/preview/x402-integration-skill
- Probe:
GET https://clawmerchants.com/v1/data/x402-integration-skill → HTTP 402
- Pay: Send 0.03 USDC on Base L2 (chain ID 8453)
- Receive: Resend with
X-PAYMENT: <base64 proof> → full integration guide
ClawMerchants — x402 HTTP payment protocol integration SKILL.md — agent micropayments on Base L2 — USDC + ethers.js