Skip to content

Your First Paid Request

There is no signup. The fastest way to understand this API is to pay it once — the whole flow is four steps, and the first two cost nothing.

Call any service with no payment attached. The response is the price list:

Terminal window
curl -i -X POST http://localhost:3000/services/token-risk \
-H "Content-Type: application/json" \
-d '{"chain":"base","tokenAddress":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"}'
# HTTP/1.1 402 Payment Required
# PAYMENT-REQUIRED: <base64 terms: scheme=exact, $0.01 USDC, network, pay-to address>

The PAYMENT-REQUIRED header names the exact amount, asset, network, and receiving address. Nothing is hidden in a pricing page — the resource quotes itself.

You need an EVM account holding a small amount of USDC on the network named in the quote. Any wallet works; agents typically use a dedicated hot wallet holding only spending money. A dollar covers one hundred requests.

Wrap fetch once; the 402 → sign → retry loop disappears from your code:

import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { wrapFetchWithPayment } from "@x402/fetch";
import { privateKeyToAccount } from "viem/accounts";
const account = privateKeyToAccount(
process.env.AGENT_PRIVATE_KEY as `0x${string}`
);
const client = new x402Client();
registerExactEvmScheme(client, { signer: account });
const fetchWithPayment = wrapFetchWithPayment(fetch, client);
const response = await fetchWithPayment(
"http://localhost:3000/services/token-risk",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
chain: "base",
tokenAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
}),
}
);
const result = await response.json();

Keep the private key in your own environment — it is never sent to the server. The signature authorizes exactly the quoted amount, nothing more.

The response carries the data plus settlement confirmation:

{
"service": "token-risk",
"requestId": "9f2c…",
"cache": { "hit": false },
"providers": [{ "name": "goplus", "status": "ok" }],
"warnings": [],
"data": { "riskLevel": "low", "": "" }
}

The PAYMENT-RESPONSE header confirms on-chain settlement, and requestId is your reference if anything needs investigating.

  • Service Catalog — all 14 services with inputs, outputs, and guardrails.
  • Agent Integration — discovery endpoints, schemas, and the full client loop.
  • Payments — what you are charged, when, and what happens on failure.