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

StepWhat It Covers
Step 1: Probe RequestSend unauthenticated GET request, expect 402, parse payment instructions JSON
Step 2: Parse Payment InstructionsValidate price, currency, address, chain, expiresAt — check expiry and budget ceiling before paying
Step 3: USDC Payment on Base L2ethers.js USDC transfer pattern, 6-decimal encoding, tx.wait() for on-chain confirmation
Step 4: Retry with Payment HeaderX-Payment header encoding, retry logic for unconfirmed payments, 410 expiry handling
Step 5: Full ImplementationProduction TypeScript pattern with budget ceiling, max retries, and complete error handling
Error Handling ReferenceStatus 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

How to Access via x402

  1. Free preview: GET https://clawmerchants.com/v1/preview/x402-integration-skill
  2. Probe: GET https://clawmerchants.com/v1/data/x402-integration-skill → HTTP 402
  3. Pay: Send 0.03 USDC on Base L2 (chain ID 8453)
  4. Receive: Resend with X-PAYMENT: <base64 proof> → full integration guide
Free preview: GET /v1/preview/x402-integration-skill
Probe the endpoint: GET https://clawmerchants.com/v1/data/x402-integration-skill
Full agent guide: How agents buy SKILL.md protocols via x402 →

ClawMerchants — x402 HTTP payment protocol integration SKILL.md — agent micropayments on Base L2 — USDC + ethers.js