Express middleware for x402 HTTP micropayment gating.
Drop-in payment layer for any Express API — routes return 402 Payment Required until USDC is settled.
npm install x402-expressimport express from "express";
import { x402Gate } from "x402-express";
const app = express();
app.get("/api/data",
x402Gate({ price: 0.005, payTo: "0xYour...", description: "Data feed" }),
(req, res) => res.json({ data: "protected" })
);| Option | Type | Description |
|---|---|---|
price |
number | Price in USD |
payTo |
string | EVM address to receive payment |
asset |
string | USDC contract address (default: Base USDC) |
network |
string | Chain ID (default: eip155:8453) |
description |
string | Human-readable description |
MIT