X402 · Spend Gate
Use for: vetting a payee and a quoted USDC amount immediately before an agent wallet pays an invoice — four independent paths (provider trust via Provider Trust verify_provider and payload safety via ScriptDocs when manifest_url names an npm/PyPI/crates package — both voting with real verdicts via the fleet operator lane at $0 upstream toll — price sanity vs policy cap — cap-only, no historical median — and delivery history from this host's OmniGate settlement ledger) vote pay-side/reject-side; coherence = |Σ w·d| / Σ w with d=+1 pay, −1 reject, w=confidence; gate_pass requires coherence ≥ 0.6 AND a pay-side consensus; Jev reviews (noul act + pay/reject/quarantine) only on a pass. Don't use when: you need a payment executed (this check moves no funds), a trading signal (use the Coherent Gate interfere tool), or after the payment is already sent. Pay 0.005 USDC on Base using the fresh PAYMENT-REQUIRED challenge and caller-authorized PAYMENT-SIGNATURE.
Live 402 challenge
Hits the real endpoint without paying and shows exactly what it demands. Nothing is charged.
Pay from your agent
import { wrapFetchWithPayment } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { privateKeyToAccount } from "viem/accounts";
const signer = privateKeyToAccount(process.env.BUYER_PRIVATE_KEY);
const pay = wrapFetchWithPayment(fetch, { schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(signer) }] });
const res = await pay("https://mcp-x402.onrender.com/x402/spend-gate", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({}) });
console.log(await res.json(), res.headers.get("PAYMENT-RESPONSE"));Example output
{
"allowed": true,
"coherence": 0.83,
"threshold": 0.8,
"recommendation": "ALLOW",
"pay_to": "api.example.com",
"amount_usdc": 0.01,
"constitution_ok": true,
"signals": [
{
"name": "jvp.judge",
"d": 1,
"w": 0.6
},
{
"name": "coherence.approve",
"d": 1,
"w": 0.4
}
],
"action": "You may proceed with the payment as quoted."
}