x402 integration
Pay-per-call in USD₮0 on X Layer, the HTTP-native way.
Sigil meters paid tools with x402 v2. An unpaid call receives HTTP 402 Payment Required with a base64-encoded PAYMENT-REQUIRED header. The v1 JSON body remains available for older buyers. Both forms offer EIP‑3009 first and Permit2 as a fallback.
The challenge
Decoded from the PAYMENT-REQUIRED header:
{
"x402Version": 2,
"error": "PAYMENT-SIGNATURE header is required",
"resource": {
"url": "https://sigil-asp.archonaudit.xyz/mcp",
"description": "Sigil verdict — sigil_screen_transaction",
"mimeType": "application/json",
"serviceName": "Sigil"
},
"accepts": [{
"scheme": "exact",
"network": "eip155:196",
"amount": "20000",
"asset": "0x779Ded0c9e1022225f8E0630b35a9b54bE713736",
"payTo": "0xc9955733F8f16872a6c8DF375E9D13d79A43a4dc",
"maxTimeoutSeconds": 300,
"extra": {
"assetTransferMethod": "eip3009",
"name": "USD₮0",
"version": "1",
"decimals": 6,
"assetSymbol": "USDT0"
}
}, {
"scheme": "exact",
"network": "eip155:196",
"amount": "20000",
"asset": "0x779Ded0c9e1022225f8E0630b35a9b54bE713736",
"payTo": "0xc9955733F8f16872a6c8DF375E9D13d79A43a4dc",
"maxTimeoutSeconds": 300,
"extra": {
"assetTransferMethod": "permit2",
"decimals": 6,
"assetSymbol": "USDT0"
}
}]
}- network — CAIP-2
eip155:196(X Layer mainnet; gas token OKB). - amount — atomic token units.
20000at 6 decimals is 0.02 USD₮0. - asset — live X Layer USD₮0
0x779Ded…713736; the older bridged token is not used. - scheme
exact— the signed EIP‑3009 or Permit2 authorization must equal the advertised amount and recipient exactly. - EIP‑3009 first — compatible with the OKX
task-402-paybuyer and settled through USD₮0's nativetransferWithAuthorization. - Permit2 fallback — retained for existing x402 clients that already use the OKX facilitator.
Paying and retrying
- Decode
PAYMENT-REQUIREDfrom the 402 response header. - Select the first supported requirement. The OKX marketplace buyer selects
exact+ EIP‑3009 and signs the USD₮0 authorization automatically; Permit2-capable clients may select the fallback. - Retry the identical POST body with the base64 payment payload:
POST /mcp
Accept: application/json, text/event-stream
PAYMENT-SIGNATURE: <base64 x402 v2 payment payload>Sigil verifies the selected rail, token, exact amount, recipient, validity window, nonce, and signature. EIP‑3009 settles through USD₮0's native transferWithAuthorization; the fallback settles through the OKX Permit2 facilitator. Only then does Sigil execute the MCP tool. A successful on-chain settlement returns a base64 PAYMENT-RESPONSE receipt header containing the transaction hash, network, payer, and amount.
The registered endpoint is dual-transport for buyer interoperability. Native
MCP clients send tools/call; OKX marketplace task buyers may send the business
arguments as plain JSON. Both receive the same challenge before payment. The
paid plain-JSON replay returns the sealed verdict directly, and malformed input
is rejected before settlement.
Do not send a raw transfer
{txHash} header is not the current buyer protocol. Use the signed exact EIP‑3009 or Permit2 payload returned by an x402 v2 client.Verify the public endpoint
onchainos agent x402-check \
--endpoint https://sigil-asp.archonaudit.xyz/mcp \
--agent-id 4943The current endpoint reports valid: true, x402 version 2, 20,000 atomic USD₮0, and eip155:196, with EIP‑3009 at accepts index 0. A real OKX payment quote/pay replay settled tx 0x21a3e677a5edb568213572bf7e54a142aba018f68282b9c46636c23673adb4dc and returned sealed receipt sgl_01kxrq9mce3dpgj1am2dbj.
Free verification
sigil_verify_verdict plus the public verdict/proof routes never require payment. Verification of Sigil's output is free.