Quick Start
Start accepting x402 payments with the OpenX402 facilitator
Server Setup
Install the x402 middleware for your framework and point it at the OpenX402 facilitator. No sign up required.
With Express
npm install express x402-expressimport express from "express";
import { paymentMiddleware } from "x402-express";
const app = express();
app.use(
paymentMiddleware(
"0xYourWalletAddress" as `0x${string}`,
{
"/api/premium": {
price: "$0.10",
network: "base",
config: { description: "Premium API access" },
},
},
{
url: "https://facilitator.openx402.ai",
}
)
);
app.get("/api/premium", (req, res) => {
res.json({ data: "premium content", payer: req.payer });
});
app.listen(3000);With Hono
npm install hono x402-honoimport { Hono } from "hono";
import { paymentMiddleware } from "x402-hono";
const app = new Hono();
app.use(
"/api/*",
paymentMiddleware(
"0xYourWalletAddress" as `0x${string}`,
{
"/api/premium": {
price: "$0.10",
network: "base",
config: { description: "Premium API access" },
},
},
{
url: "https://facilitator.openx402.ai",
}
)
);
app.get("/api/premium", (c) => {
return c.json({ data: "premium content" });
});
export default app;Client Setup
Use x402-fetch to make payments automatically from the client side:
import { wrapFetch } from "x402-fetch";
const x402Fetch = wrapFetch(fetch, {
privateKey: process.env.PRIVATE_KEY as `0x${string}`,
});
const response = await x402Fetch("https://your-server.com/api/premium");
const data = await response.json();When the server returns 402 Payment Required, x402-fetch automatically:
- Reads the payment requirements from the response
- Signs a
transferWithAuthorizationwith the client's private key - Resends the request with the signed payment headers
The client never sends a transaction — it only signs an authorization that the facilitator executes on-chain.
Solana Client
import { wrapFetch } from "x402-fetch";
import { svm } from "x402/shared";
const signer = await svm.createSignerFromBase58(process.env.SOLANA_PRIVATE_KEY);
const x402Fetch = wrapFetch(fetch, signer);
const response = await x402Fetch("https://your-server.com/api/premium");
const data = await response.json();Test on Base Sepolia
Use network: "base-sepolia" during development. Get testnet USDC from the Circle faucet.
Next Steps
- Building a Server — dynamic pricing, per-route config, and more patterns
- Facilitator API — what happens under the hood when verify and settle are called
- Supported Chains — networks and contract addresses