x402 payments
x402 lets an HTTP API ask for a payment with a 402 Payment Required answer, and lets the client pay with a signature. On Robinhood Chain, Heimdall uses USDG with EIP-3009 (transferWithAuthorization): the payer signs, the facilitator submits the transfer and pays the gas.
| Setting | Value |
|---|---|
| Network | eip155:4663 (v1: robinhood) |
| Asset | USDG 0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168, 6 decimals |
| Signing domain | name Global Dollar, version 1 |
| Scheme | exact (the payment equals the price) |
Pay for Shield#
The free tier works as before. When it is used up, instead of 429 Too Many Requests Shield answers 402 with a PAYMENT-REQUIRED header. Pay and retry with PAYMENT-SIGNATURE:
| Endpoint | Price |
|---|---|
POST /v1/check | 0.001 USDG |
POST /v1/check-signature | 0.001 USDG |
GET /v1/wallet/:address | 0.002 USDG |
import { payX402, HeimdallShield } from "@heimdallfund/sdk";
// pays only when asked, never above 0.01 USDG per call; the wallet needs USDG, not ETH
const shield = new HeimdallShield({ fetch: payX402(fetch, agentWallet, { maxAmount: 10_000n }) });MCP: set HEIMDALL_X402_PRIVATE_KEY (a wallet holding USDG) and optionally HEIMDALL_X402_MAX (raw units per call, default 5000).
One payment buys one call. Shield refuses a replayed payment header, and validates the request body before charging, so a malformed request is never paid for.
Use the facilitator for your API#
Heimdall runs a standard x402 v2 facilitator for Robinhood Chain:
| Endpoint | What it does |
|---|---|
GET /x402/supported | Networks, schemes and the settling address |
POST /x402/verify | Checks a payment and moves nothing |
POST /x402/settle | Verifies again, settles onchain, waits for the receipt |
GET /discovery/resources | Paid APIs that asked to be listed (Bazaar) |
/verify and /settle take { x402Version, paymentPayload, paymentRequirements } and answer the standard VerifyResponse and SettlementResponse.
const r = await fetch("https://api.heimdall.fund/x402/settle", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ x402Version: 2, paymentPayload, paymentRequirements }),
}).then((r) => r.json()); // { success, transaction, payer, network }What the facilitator checks, in order: version, scheme, network and asset; that to is your payTo; that the value equals the price; the validity window; the signature (EOA or smart wallet); that the recipient is not on Heimdall's blocklist (heimdall_recipient_blocked); the payer's balance; and that the nonce is unused. Settlement is idempotent per payer and nonce.
Limits: payments under 0.001 USDG are not settled, and /settle is rate-limited per IP. Payments are settled from Heimdall's facilitator wallet, which never holds USDG.
Get listed#
Add the Bazaar extension to your PAYMENT-REQUIRED object (extensions.bazaar) and include resource in the payment payload. After the first payment settles through Heimdall, the endpoint appears in GET /discovery/resources, which directories crawl.