import express from "express";import { paymentMiddleware, x402ResourceServer } from "@x402/express";import { ExactEvmScheme } from "@x402/evm/exact/server";import { HTTPFacilitatorClient } from "@x402/core/server";const server = new x402ResourceServer(new HTTPFacilitatorClient({ url: "https://facilitator.heurist.xyz" }),).register("eip155:8432", new ExactEvmScheme());app.use(paymentMiddleware(routes, server));
Scale with confidence. Our transaction management system is built for high-frequency requests.
Address a global audience. One endpoint, multiple ecosystems.
Meet regulatory requirements. Our facilitator automatically screens and blocks transactions from OFAC-sanctioned addresses.
Eliminate onboarding friction. Integrate in seconds with no API key needed.
Track your onchain revenue with a real-time dashboard to monitor API health, transaction volume, and earnings. (Coming Soon)
Accrue value without intervention. Automatically convert USDC revenue into your native project token on every settlement. (Coming Soon)
Start accepting agentic crypto payments in minutes.
npm i express @x402/express @x402/evm @x402/core
import express from "express";import { paymentMiddleware, x402ResourceServer } from "@x402/express";import { ExactEvmScheme } from "@x402/evm/exact/server";import { HTTPFacilitatorClient } from "@x402/core/server";const app = express();// Your receiving wallet addressconst payTo = "0xYourReceivingAddress";// Create facilitator client (testnet)const facilitatorClient = new HTTPFacilitatorClient({url: "https://facilitator.heurist.xyz"});// Create resource server and register EVM schemeconst server = new x402ResourceServer(facilitatorClient).register("eip155:8432", new ExactEvmScheme());app.use(paymentMiddleware({"GET /weather": {accepts: [{scheme: "exact",price: "$0.001", // USDC amount in dollarsnetwork: "eip155:8432", // Base (CAIP-2 format)payTo,},],description: "Get current weather data for any location",mimeType: "application/json",},},server,),);app.get("/weather", (req, res) => {res.send({report: {weather: "sunny",temperature: 70,},});});app.listen(4021, () => {console.log(`Server listening at http://localhost:4021`);});
402 with accepted options ⇒ client retries with X-PAYMENT (base64 JSON) ⇒ server verifies via /verify, settles via /settle, then returns 200. See the seller quickstart and set the facilitator URL to https://facilitator.heurist.xyz.