x402

Implements HTTP 402 stablecoin payments for APIs using ERC-3009 gasless USDC transfers.

6|20|Updated Mar 14, 2026
One-click install
npx skills add https://github.com/andresdefi/cryptoskills --skill x402-andresdefi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: x402
Source: https://github.com/andresdefi/cryptoskills/tree/main/skills/x402
Command: npx skills add https://github.com/andresdefi/cryptoskills --skill x402-andresdefi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? AI agents and developers lack accurate, current knowledge of the x402 payment protocol, leading to hallucinated package names, wrong header formats, incorrect nonce handling, and broken payment integrations when monetizing HTTP endpoints with stablecoins. ## Core Features & Use Cases - Server Integration: Add payment middleware to Express, Hono, or Next.js endpoints using @x402/express with per-route pricing in USDC on Base, Ethereum, Arbitrum, Optimism, Polygon, or Solana. - Client Implementation: Build payment-aware clients in TypeScript (@x402/fetch) or Python that automatically detect 402 responses, sign EIP-3009 authorizations, and retry with the X-PAYMENT header. - Agent-to-Agent Commerce: Enable autonomous agent workflows with service discovery, price-aware provider selection, multi-step paid pipelines, and budget enforcement. - Use Case: An AI agent needs to call a paid weather API. The skill guides correct setup of a wrapped fetch client that signs a gasless USDC authorization, pays $0.01 per request, and handles settlement via the CDP facilitator without the agent ever paying gas. ## Quick Start Set up an Express server with x402 payment middleware that charges $0.01 USDC per request on Base using the CDP facilitator.

Frequently Asked Questions about x402

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add crypto payments to an Express API with x402?

Install @x402/express, @x402/core, and @x402/evm, then apply paymentMiddleware with per-route pricing, network, and payTo address. Connect an HTTPFacilitatorClient pointing to the CDP facilitator endpoint for verification and settlement.

How does x402 enable gasless USDC payments?

x402 uses EIP-3009 transferWithAuthorization, where the client signs an off-chain EIP-712 authorization and the facilitator broadcasts the on-chain transaction. The client never needs native gas, and CDP's facilitator absorbs gas costs on Base mainnet.

Which blockchains does x402 support for payments?

x402 supports Base, Ethereum, Arbitrum, Optimism, and Polygon via USDC with EIP-3009, plus Solana. Networks are identified with CAIP-2 format, such as eip155:8453 for Base mainnet.

Why does x402 settlement fail with authorization is used or canceled?

This error means the nonce was already consumed on-chain. x402 nonces are random 32-byte values, not sequential counters, so generate a fresh random nonce for every payment attempt and never reuse one.

Can x402 accept tokens other than USDC?

The primary path uses USDC via EIP-3009 for gasless transfers. A Permit2 fallback supports arbitrary ERC-20 tokens, but it requires a prior one-time approval transaction to the Permit2 contract, which needs native gas.

What is the correct payment header name in x402?

The header is X-PAYMENT, containing a base64-encoded JSON payload with the authorization, signature, scheme, and network. The server responds with X-PAYMENT-RESPONSE after settlement.