What are you building?
Configuration
Default testnet: https://x402.org/facilitator
Payment Routes
Route #1
Install Dependencies
npm install @x402/core @x402/express @x402/evmGenerated Codetypescript
import express from "express";
import { paymentMiddleware } from "@x402/express";
import { x402ResourceServer, HTTPFacilitatorClient } from "@x402/core";
import { ExactEvmScheme } from "@x402/evm/exact/server";
const app = express();
const facilitatorClient = new HTTPFacilitatorClient({
url: "https://x402.org/facilitator",
});
const server = new x402ResourceServer(facilitatorClient);
server.register("eip155:*", new ExactEvmScheme());
app.use(
paymentMiddleware(
{
"GET /api/weather": {
accepts: [
{
scheme: "exact",
price: "$0.001",
network: "eip155:84532",
payTo: "0xYourWalletAddress",
},
],
description: "Get weather data",
mimeType: "application/json",
},
},
server,
),
);
app.get("/api/weather", (req, res) => {
res.json({ message: "Get weather data" });
});
app.listen(4021, () => {
console.log("x402 server running on http://localhost:4021");
});How to Generate x402 Payment Middleware
- 1
Choose your role
Select Server (Seller) if you want to accept payments for your API endpoints, or Client (Buyer) if you need to pay for API access programmatically. - 2
Pick your framework or SDK
For servers, choose from Express, Hono, Next.js, Fastify, Gin, FastAPI, or Flask. For clients, choose Fetch, Axios, Go, Python httpx, or Python requests. - 3
Configure payment routes
Add one or more routes with an HTTP method, path, price (e.g. $0.001), payment scheme (exact or upto), blockchain network, and your wallet address. - 4
Select extensions
Optionally enable Bazaar for API discovery by AI agents, or Payment Identifier for idempotent request retries. - 5
Copy the install command and code
Copy the generated install command into your terminal, then paste the production-ready middleware code into your project. The code includes all imports, configuration, and route handlers.
Common Use Cases
1
Micropayment APIs
Charge fractions of a cent per API request for weather data, AI inference, or dataset queries. x402 makes sub-cent pricing viable with zero protocol fees.
2
AI Agent Payments
Enable autonomous AI agents to discover and pay for your API through the Bazaar extension. Agents parse payment requirements and pay programmatically without human intervention.
3
Content Paywalls
Protect premium content behind per-access payments. Users pay with USDC from their wallet and get instant access without creating accounts or managing subscriptions.
4
Multi-Framework Migration
Quickly generate equivalent x402 middleware code for different frameworks when migrating between Express, Fastify, Hono, or switching from TypeScript to Go or Python.
Why Use x402 Config Generator?
x402 is an open payment standard that enables services to charge for API access directly over HTTP using the 402 Payment Required status code. Setting up x402 requires configuring middleware, payment routes, network identifiers, and wallet addresses across different frameworks and languages.
This generator eliminates boilerplate by producing production-ready code for 7 server frameworks (Express, Hono, Next.js, Fastify, Gin, FastAPI, Flask) and 5 client SDKs (Fetch, Axios, Go, Python httpx/requests). Configure your routes, pricing, and networks visually, then copy the generated code directly into your project.
Whether you are building paid APIs, micropayment-based services, or enabling AI agent-to-agent payments, this tool gets you from zero to working x402 integration in seconds.
The x402 Config Generator produces production-ready payment middleware code for the x402 open payment protocol, which activates the HTTP 402 Payment Required status code for programmatic, on-chain API payments. Developed by Coinbase as an open-source standard under the Apache 2.0 license, x402 enables services to charge for API access using stablecoins like USDC across multiple blockchains including Base, Polygon, Solana, Aptos, and Stellar, with zero protocol fees. This tool supports code generation for seven server frameworks (Express, Hono, Next.js, Fastify, Gin, FastAPI, Flask) and five client SDKs (Fetch, Axios, Go, Python httpx, Python requests). You configure payment routes visually by specifying HTTP methods, paths, prices, payment schemes, blockchain networks, and wallet addresses. Optional extensions include Bazaar for API discovery by autonomous AI agents and Payment Identifier for idempotent request retries. The generated code includes all necessary imports, configuration blocks, middleware setup, and route handlers ready to paste into your project. Use cases range from micropayment APIs charging fractions of a cent per request, to AI agent-to-agent payment flows, to content paywalls with per-access pricing. The configurator runs entirely in the browser with no server-side processing, and the generated code follows each framework's idiomatic patterns.
Frequently Asked Questions
1
What is x402?
x402 is an open-source payment protocol by Coinbase that activates the HTTP 402 Payment Required status code for programmatic, on-chain payments. It supports stablecoins like USDC across multiple blockchains including Base, Polygon, Solana, Aptos, and Stellar.
2
What frameworks does x402 support?
x402 has official SDKs for TypeScript (Express, Hono, Next.js, Fastify), Go (Gin, net/http), and Python (FastAPI, Flask). Client SDKs are available for fetch, axios, Go net/http, and Python httpx/requests.
3
What is a facilitator in x402?
A facilitator is a service that verifies and settles payments on behalf of your server. It handles blockchain complexity so your server does not need direct blockchain connectivity. The default testnet facilitator is at x402.org/facilitator.
4
What networks and tokens does x402 support?
x402 supports EVM chains (Base, Polygon, Avalanche, Sei) with any ERC-20 token via EIP-3009 or Permit2, Solana with SPL tokens, Aptos with fungible assets, and Stellar with Soroban tokens. USDC is the default payment token.
5
Is x402 free to use?
Yes, x402 is open-source under the Apache 2.0 license with zero protocol fees. The Coinbase CDP facilitator offers 1,000 free transactions per month, then $0.001 per transaction after that.
Related Tools
Loadbalancer Design
Developers
Json Formatter
Developers
Json Minifier
Developers
Json Escaper
Developers
Url Params To Json
Developers
Json To Url Params
Developers
Json Path Finder
Developers
Json To Html Form
Developers
Json To Tailwind Form
Developers
Json To Bootstrap Form
Developers
Json To React Form
Developers
Form To Json Schema
Developers