x402 Conformance Tools
v0.1.2Non-custodial x402 checks: decode 402s, verify settlements on-chain, lint specs, test facilitators.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
decode_402
Parse and validate an x402 PaymentRequired (HTTP 402) response and explain every field. Flags missing economic fields (scheme/network/asset/payTo/amount), number-typed or human-decimal amounts (must be atomic-integer strings), and missing explicit decimals. Provide ONE of: `url` (does an unpaid GET and decodes the 402), `raw` (a JSON or base64-encoded-JSON body string), or `json` (an object). Deterministic; the only network is the optional unpaid GET.
| Parameter | Type | Description |
|---|---|---|
json | object | A PaymentRequired as an object. |
raw | string | A PaymentRequired as a JSON string or base64-encoded JSON. |
url | string | Resource URL to GET unpaid; expects a 402 with a PaymentRequired body. |
inspect_payment_response
Decode and validate an x402 PAYMENT-RESPONSE, surfacing success, settlement id, payer, network, and amount. Optionally recomputes the on-chain truth: pass `rpcUrl` + `expectedPayTo` for a sui:* network (queries sui_getTransactionBlock balanceChanges), or `observedBalanceChanges` + `expectedPayTo` for any chain, and it confirms the net balance change to payTo equals the advertised atomic amount (the "recomputed, not trust-the-operator" check). Provide the response via `raw` (JSON/base64) or `json`.
| Parameter | Type | Description |
|---|---|---|
expectedAmount | string | Optional. Expected atomic amount; defaults to the response amount. |
expectedAsset | string | Optional. Asset/coin type to filter on (defaults to 0x2::sui::SUI for Sui). |
expectedPayTo | string | Optional. The recipient address to sum net balance change for. |
json | object | PAYMENT-RESPONSE as an object. |
observedBalanceChanges | array | Optional. A balanceChanges array (any chain) to recompute net-to-payTo from, instead of an RPC call. |
raw | string | PAYMENT-RESPONSE as a JSON string or base64-encoded JSON. |
rpcUrl | string | Optional. Chain RPC URL; used for the on-chain net-balance check on sui:* networks. |
check_compliance
Heuristically scan x402 code (a file or directory) for the high-severity classes: hardcoded chain id, hardcoded decimals, magic-number decimal scaling (10**N, 1eN, *1_000_000), human-decimal/float amounts, and literal asset/token addresses. Returns findings with file:line and severity. Heuristic — a documented default may be a false positive; every finding cites a location for human judgement. No network.
| Parameter | Type | Description |
|---|---|---|
path * | string | A file or directory to scan. |
maxFiles | number | Cap on files scanned (default 2000). |
maxFindings | number | Cap on findings returned (default 300). |
lint_scheme_spec
Lint a draft scheme spec (markdown) against the bundled scheme_template.md: reports missing/extra template sections and whether the draft pins down the load-bearing concepts a scheme must specify (value/recipient assertion, settlement identifier, replay protection, atomic+decimals amount encoding, verify/settle flow). Reads the bundled corpus; no network.
| Parameter | Type | Description |
|---|---|---|
path * | string | Path to the draft scheme markdown. |
template | string | Optional template path relative to the plugin root (default .x402-specs/scheme_template.md). |
validate_extension
Structurally validate an x402 extension payload: checks the typed { info, schema } envelope and runs light known-extension field checks (offer-and-receipt, payment_identifier, gas-sponsoring, sign-in-with-x, builder_code). Pass `payload` as a single entry (with `name`), an extensions map keyed by name, or an array. Full JSON-schema validation needs the extension’s published schema; this is the structural gate plus a spec pointer. No network.
| Parameter | Type | Description |
|---|---|---|
payload * | An extension entry, an extensions map, or an array of entries. | |
name | string | Optional extension name when `payload` is a single entry. |
run_conformance
Drive the x402 conformance sequence against a facilitator. Holds NO keys: automates the 402 negotiation (with `resourceUrl`), facilitator reachability (GET /supported), and malformed-verify rejection. The keyed steps (verify happy-path, tampered-reject, settle, idempotent re-settle) run ONLY when you supply a pre-signed `paymentPayload` + `paymentRequirements`; settle additionally requires `allowSettle: true` (it settles real testnet value). Assumes the standard facilitator API (POST /verify, POST /settle). Returns a pass/fail/skip line per step.
| Parameter | Type | Description |
|---|---|---|
facilitatorUrl * | string | Base URL of the facilitator (POST /verify, /settle). |
allowSettle | boolean | Optional. Must be true to actually settle (settles real testnet value). Default false. |
paymentPayload | object | Optional. A pre-signed payment payload (produced by your keyed SDK) to run the happy/tampered paths. |
paymentRequirements | object | Optional. The paymentRequirements the payload pays. |
resourceUrl | string | Optional. A payment-gated resource URL to test 402 negotiation. |