x402

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? AI agents and API providers lack a native way to charge per-request without API keys, accounts, or billing systems, and LLMs frequently hallucinate outdated x402 details like wrong package names, header names, and nonce behavior. ## Core Features & Use Cases - Server Payment Middleware: Protect Express, Hono, or Next.js endpoints with per-route USDC pricing using @x402/express and the CDP facilitator. - Client Payment Flows: Wrap fetch in TypeScript or use the Python x402 package to automatically detect 402 responses, sign EIP-3009 authorizations, and retry with the X-PAYMENT header. - Agent-to-Agent Commerce: Discover paid agent services, enforce spending budgets, and orchestrate multi-step paid workflows across EVM chains and Solana. - Use Case: An AI agent needs weather data from a paid API. It sends a request, receives HTTP 402 with a $0.01 USDC price on Base, signs an EIP-712 transferWithAuthorization, retries with the X-PAYMENT header, and receives the data while the facilitator settles on-chain. ## Quick Start Use the x402 skill to add USDC payment middleware to my Express API endpoint on Base mainnet.

Frequently Asked Questions about x402

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

FAQPage Schema
How do I add USDC payments to my Express API with x402?

Install @x402/express, @x402/core, and @x402/evm, then apply paymentMiddleware with per-route pricing, network, and payTo address. Requests without a valid X-PAYMENT header receive HTTP 402 with payment requirements; valid payments are verified and settled via the facilitator.

How does x402 payment work without API keys?

Payment itself is authentication. The client signs an EIP-3009 transferWithAuthorization for USDC, includes it base64-encoded in the X-PAYMENT header, and the server verifies the signature and balance through a facilitator before serving the resource.

Which blockchains does x402 support?

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

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

The (from, nonce) pair was already consumed on-chain because a nonce was reused across payment attempts. Generate a fresh random 32-byte nonce for every authorization and check state with authorizationState on the USDC contract.

Does the client need ETH for gas when paying with x402?

No. The client only signs an off-chain EIP-712 authorization; the facilitator broadcasts transferWithAuthorization and pays gas. On Base mainnet, CDP's hosted facilitator absorbs gas costs for free-tier usage of 1,000 transactions per month.

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 requires a prior one-time approval transaction to the Permit2 contract, which needs native gas.