MIRAI
Open app
x402 for sellers

Charge per call,
in USDG.

Put a price on an endpoint and get paid in USDG on Robinhood Chain by any x402 client, AI agents first. You keep your server and your address; MIRAI's facilitator verifies each payment, sends it on chain and pays the gas. No sign-up, no key, no fee.

§ 01What you need

An address on Robinhood Chain to receive USDG, and a Node server. Your buyers need USDG on Robinhood Chain and nothing else: they pay by signature, the facilitator pays the gas.

# the paywall, the payer and the facilitator client npm i @miraifi/x402 ethers

Facilitator status right now: checking…

§ 02Express

paywall() answers an unpaid request with 402 and your terms, and lets a paid one through once the payment has settled. It works as Express or Connect middleware.

import express from "express"; import { paywall } from "@miraifi/x402"; const app = express(); app.get("/report", paywall({ price: "0.05", // USDG per call payTo: "0xYourAddress", // where the USDG lands description: "One report", }), (req, res) => { res.json({ report: "…", paidBy: req.x402.payer, tx: req.x402.transaction }); }); app.listen(3000);

The 402 carries x402 v2 terms in the PAYMENT-REQUIRED header and the same JSON in the body: exact USDG on eip155:4663, the amount in base units (6 decimals), your payTo and USDG's EIP-712 domain. The paid response carries PAYMENT-RESPONSE with the settlement transaction.

§ 03node:http

import { createServer } from "node:http"; import { paywall } from "@miraifi/x402"; const gate = paywall({ price: "0.01", payTo: "0xYourAddress" }); createServer(async (req, res) => { if (!(await gate.check(req, res))) return; // it answered 402 or refused the payment res.end(JSON.stringify({ ok: true })); }).listen(3000);

Another facilitator: paywall({ …, facilitator: "https://your-facilitator/x402" }). A v1 client paying with X-PAYMENT is accepted too.

§ 04Any x402 stack

Already running an x402 server library? Keep it. Give it MIRAI's facilitator URL and price the route in USDG on Robinhood Chain. The facilitator speaks the public x402 HTTP API, versions 1 and 2.

// the terms, as any x402 server sends them { scheme: "exact", network: "eip155:4663", asset: "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168", // USDG amount: "50000", // 0.05 USDG payTo: "0xYourAddress", maxTimeoutSeconds: 120, extra: { name: "Global Dollar", version: "1" } } // the facilitator GET https://miraifi.family/x402/supported POST https://miraifi.family/x402/verify { x402Version, paymentPayload, paymentRequirements } → { isValid, invalidReason?, payer } POST https://miraifi.family/x402/settle { x402Version, paymentPayload, paymentRequirements } → { success, errorReason?, transaction, network, payer } GET https://miraifi.family/x402/health

§ 05What is checked

Before anything moves, and again right before it sends:

  • TermsScheme exact, network eip155:4663, asset USDG, and a payment made for these terms and no others.
  • AuthorizationPays your payTo, for exactly the amount, valid now and for a few more seconds, never payer to itself.
  • SignatureThe payer's own key over USDG's EIP-712 domain (65-byte EOA signatures).
  • ChainThe authorization is unused, the balance covers it, and USDG accepts the transfer in a simulation.
  • SettlementSuccess only when the transaction carries USDG's AuthorizationUsed for that payer and nonce and the exact Transfer to you. One authorization gets one success, however often it is sent.

§ 06Limits

  • Per payment0.001 to 1,000 USDG.
  • Per day100 settlements per payer, 300 per seller, 1,000 in all. Past that, settle answers 429 until the next day.
  • CostNo fee. MIRAI pays the gas from its own wallet.
  • Without gasIf the facilitator's gas wallet is not set, /verify still works and /settle answers 503 settlement_unavailable; /x402/health says which.

§ 07Confirm it yourself

A facilitator's word is not proof of payment. USDG does not revert every transfer that moves nothing, so the paywall can read the settlement's receipt itself before it serves:

paywall({ price: "0.05", payTo: "0xYourAddress", confirm: true }) // or confirm: { rpcUrl } // or on its own import { confirmSettlement } from "@miraifi/x402"; const { ok, reason } = await confirmSettlement({ transaction, payer, payTo, amount, nonce });

§ 08Get found

MIRAI's seller directory reads public x402 lists every hour (Dexter's discovery list, Spraay's gateway manifest, Agent402's manifest) and asks each endpoint for its 402 without paying. An endpoint is listed when that 402 takes exact USDG on eip155:4663 by EIP-3009, at a public https address, paid to the address the list names. Agents find it through /api/sellers and the find_sellers MCP tool.

If your seller is also an ERC-8004 agent, set payTo to its registry payment wallet: USDG paid there by EIP-3009 counts as its x402 income in the MIRAI Score.