Paying

Paying with x402

x402 is the open HTTP payment standard: the server answers 402 with what to pay, the client pays and retries. HyperWafer uses the exact scheme on Solana with USDC, 0.0005 USDC per call.

01
POST /rpc
Free tier used, or ?lane=x402
02
402
accepts: exact, solana, USDC, payTo
03
Sign
transferChecked of the price
04
Retry
X-PAYMENT header
05
200
Answer and X-PAYMENT-RESPONSE

The 402 answer

{ "x402Version": 1, "error": "free tier of 200 calls a day is used",
  "accepts": [{ "scheme": "exact", "network": "solana", "maxAmountRequired": "500",
    "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "payTo": "<fee account>",
    "resource": "/rpc", "maxTimeoutSeconds": 120, "extra": { "decimals": 6 } }] }

The payment

Build a Solana transaction with a USDC transferChecked of at least maxAmountRequired to payTo, sign it with your wallet (you pay the Solana fee), base64 it, and send it back:

X-PAYMENT: base64({"x402Version":1,"scheme":"exact","network":"solana",
                    "payload":{"transaction":"<base64 signed transaction>"}})

What you get back

The server checks the transfer, sends the transaction, waits for confirmation (one to two seconds) and serves. X-PAYMENT-RESPONSE holds the signature, which you can open on Solscan. Paid calls do not use your free tier.