Build
Pay per call (x402 style)
x402 revives HTTP 402 Payment Required so a client can pay for a single request. Batin adds a scheme, batin-link, where the payment comes out of the shielded pool.
How it works
- The client calls the API with no payment. The server answers
402with what it wants:
{ "x402Version": 1, "error": "payment required",
"accepts": [{ "scheme": "batin-link", "network": "sei-atlantic-2", "chainId": "1328",
"pool": "0x5ccd…7e72", "tokenId": "2", "maxAmountRequired": "10000",
"resource": "https://batin.vercel.app/api/x402/v1/quote", "maxTimeoutSeconds": 180 }] }
- The client funds a one-time claim link for that amount, from its hidden balance, through the relayer. It retries with the link in the
X-PAYMENTheader (base64 JSON). - The server checks the asset and amount. It then claims the link into its own hidden balance before it answers. A link that was already claimed, or that the payer took back, is refused.
- The answer carries
X-PAYMENT-RESPONSEwith the claim transaction.
What the server learns
The price it asked for. The link holds a fresh one-time key, and the paying transfer was a private transfer sent by the relayer, so nothing ties it to the payer's wallet. The server still sees the request itself and the IP address it came from, like any web server. A payer who wants more distance can use a VPN or Tor.
The claim is a real transaction. It costs the sponsor gas and takes a few seconds, so this suits calls worth a few cents or more, not micro-fractions of a cent.
Try it
GET https://batin.vercel.app/api/x402/v1/quote returns the 402. Paid, it returns a live snapshot of the pool (block, root, leaf count) read from Sei. The price is 0.01 testnet USDC.
From an agent: batin_paid_fetch in batin-mcp. From code, with batin-sdk 0.2:
import { pickRequirements, payRequirements, batinSubmitter } from "batin-sdk";
const first = await fetch(url);
if (first.status === 402) {
const req = pickRequirements(await first.json());
const { header } = await payRequirements(wallet, batinSubmitter(), req!, { maxAmount: 50_000n });
const paid = await fetch(url, { headers: { "x-payment": header } });
}
A seller uses paymentRequired(...) for the 402 body and settlePayment(wallet, submitter, header, price) before it serves.
Related work on private x402 payments includes zBase, TACEO, z402 and Veil. Batin's version reuses the pool's ordinary claim links, so it needs no new circuit.
Source: apps/web/content/docs/x402.md