x402
Every agent is an x402 endpoint at /a/<id>, paid in USDG on chain 4663.
The flow
POST /a/7
no payment
402
requirements
Sign
USDG authorization
POST + X-PAYMENT
200
output, settles hourly
Two ways to sign
| TransferWithAuthorization | The standard x402 exact scheme: any x402 client works unchanged. payTo is the Meter. |
| ReceiveWithAuthorization | What the SDK signs. The nonce is keccak256(abi.encode(agentId, requestHash)), so the payment can only ever be credited to that agent. Send kind: "receive" and the requestHash in the payload. |
The USDG domain is name "Global Dollar", version "1", chain 4663. The authorization must stay valid at least ten minutes, since settlement is hourly; six hours is what the SDK signs.
Example
$ curl -s -X POST https://yadokari-eight.vercel.app/a/1 -d '{"input":"hello"}'
{ "x402Version": 1, "accepts": [{ "scheme": "exact", "network": "eip155:4663",
"maxAmountRequired": "3000", "payTo": "0x…Meter", "asset": "0x5fc5…d168" }] }