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.

SettingValue
Networkeip155:4663 (v1: robinhood)
AssetUSDG 0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168, 6 decimals
Signing domainname Global Dollar, version 1
Schemeexact (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:

EndpointPrice
POST /v1/check0.001 USDG
POST /v1/check-signature0.001 USDG
GET /v1/wallet/:address0.002 USDG
TypeScript
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:

EndpointWhat it does
GET /x402/supportedNetworks, schemes and the settling address
POST /x402/verifyChecks a payment and moves nothing
POST /x402/settleVerifies again, settles onchain, waits for the receipt
GET /discovery/resourcesPaid APIs that asked to be listed (Bazaar)

/verify and /settle take { x402Version, paymentPayload, paymentRequirements } and answer the standard VerifyResponse and SettlementResponse.

TypeScript
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.