Tollgate

Gateway

Gate an endpoint

A gate is a path, a price and an upstream. Everything else, from the challenge to settlement and the receipt, is handled by the gateway.

Route options

tollgate.config.ts
routes: {
  "/x402/market-analytics": {
    price: usdg("0.05"),
    upstream: "https://analytics.internal/v2",
    methods: ["GET"],
    description: "Order-flow imbalance and skew per symbol",
    rateLimit: { perAgent: 60, window: "1m" },
    vault: ["MARKETDATA_API_KEY"],
  },
}
OptionTypeNotes
priceusdg(string)Exact amount in USDG; 6 decimals
upstreamURLRequest is forwarded only after settlement
session{ calls, ttl }Optional prepaid bundle, see Paid sessions
rateLimit{ perAgent, window }429 + Retry-After when exceeded
vaultstring[]Secrets this route may attach upstream

The 402 challenge

Unpaid requests get a machine-readable challenge. Agents never have to guess the price or the network.

402 body
{
  "x402Version": 1,
  "error": "payment_required",
  "accepts": [{
    "scheme": "exact",
    "network": "eip155:4663",
    "price": "0.05",
    "maxAmountRequired": "50000",
    "asset": "0x5fA1c0dE7b2e44A91c3b0dF83e2A9d4F6c71B90a",
    "payTo": "0x7A3f92bE01c4D58aF6e3B27d90C1a4E58f2Dc21E",
    "resource": "https://gateway.tollgate402.com/x402/market-analytics",
    "nonce": "0x8f1c…e20b",
    "maxTimeoutSeconds": 60
  }]
}

Replay protection

Every challenge carries a single-use nonce. The gateway stores it until expiry and rejects a second X-PAYMENT with the same nonce, even if the signature is valid. Each accepted payment maps to exactly one transaction on Robinhood Chain.