verify402-mcp
# verify402
> **Token safety check for AI agents before they swap: quote-based sellability, round-trip cost, TRUST / CAUTION / AVOID. $0.02 per call, free pre-signing gate included.**
> Supporting x402 checks cover arbitrage reality, execution book, quote fairness and trade capacity at one pinned block. `/preflight` is the free pre-signing gate: PASS / CAUTION / BLOCK with typed reasons and a short-lived receipt. No API key, no account, no wallet for the gate. `/safety` is quote-based, not a honeypot proof: transfer restrictions and unconfigured venues stay in `notChecked`.
[](https://www.npmjs.com/package/verify402-mcp)
[](https://vex402.online/mcp)
[](https://registry.modelcontextprotocol.io/)
[](https://vex402.online/openapi.json)
[](https://github.com/x402-foundation/x402)
[](LICENSE)
[](https://glama.ai/mcp/servers/a32116150-ctrl/verify402)
> **Status (2026-11-22):** this service is live on **Base + Solana mainnet** at **[vex402.online](https://vex402.online)** — real USDC via the Coinbase CDP facilitator. Receipts are at [vex402.online/proof](https://vex402.online/proof). The public Base Sepolia testnet demo was retired on 2026-11-19 — the product is the mainnet service. The paid analysis reads live mainnet prices on 7 networks (Ethereum, Base, Arbitrum, OP Mainnet, BNB Chain, Polygon, Avalanche) from 13 exchanges; see [Exchanges read on-chain](#exchanges-read-on-chain).
---
[](https://mcprush.com/to/verify402-mcp?ref=badge)
## What verify402 can do
verify402 answers one question before an agent signs, pays or swaps: *is this
what it claims to be?* It never signs or sends a trade.
**Free (no wallet, no key):**
| tool | what it does |
|---|---|
| `preflight_gate` | Checks a payment request, swap or approval before signing: PASS / CAUTION / BLOCK with typed reasons, plain-words advice, dollars at risk, and a short-lived signed receipt. 22 EVM networks plus Solana x402 payments. |
| `inspect_402` | Reads a 402 payment challenge without paying: price, token, network, payee, bound resource, and a verdict. |
| `directory_402` | Lists the public x402 endpoints verify402 watches, with their verdicts and recorded changes. |
**Paid per call in USDC via x402, no subscription** (the MCP bridge pays on Base; the HTTP API also takes Solana):
| tool | price | what it does |
|---|---|---|
| `check_token_safety` | $0.02 | Can this token be sold back at a realistic size, and what does the round trip cost? TRUST / CAUTION / AVOID. |
| `get_best_route` | $0.03 | Which exchange pays the most for this swap right now, with the quote from each exchange it reads and the price impact. |
| `verify_quote_fairness` | $0.05 | Is the price a broker, bot or aggregator offered honest? fair / overpaying / too_good_to_be_true. |
| `get_trade_depth` | $0.05 | How big can I trade before the round trip eats me? Per-size impact and capacity. |
| `verify_arbitrage` | $0.05 | Is this claimed arbitrage real after fees, gas and flash-loan cost? |
| `get_assurance` | $0.10 | Bundles any of the checks above into one evidence record at one pinned block, with a recomputable hash. |
| `watch_contract` | $0.50 | Watches one contract for 30 days; about once an hour re-reads its code, proxy implementation, upgrade admin, owner and paused state, and POSTs a signed event to your webhook when any of them changes. |
Paid answers read live prices on **7 networks**: Ethereum, Base, Arbitrum,
OP Mainnet, BNB Chain, Polygon and Avalanche.
## Exchanges read on-chain
The paid price checks ask each exchange's own on-chain quoter or router
directly, at one pinned block, with no outside price feed in between.
**13 exchanges** are read:
| network | exchanges read |
|---|---|
| Ethereum | Uniswap V2, V3, V4 · SushiSwap V2, V3 · Curve (main pools: 3pool, tricrypto, TriCRV) |
| Base | Uniswap V2, V3, V4 · PancakeSwap V3 · Aerodrome classic and Slipstream · WOOFi |
| Arbitrum | Uniswap V2, V3, V4 · SushiSwap V2 · PancakeSwap V3 · Camelot V3 · WOOFi |
| OP Mainnet | Uniswap V2, V3, V4 · Velodrome classic and Slipstream · WOOFi |
| BNB Chain | PancakeSwap V2, V3 · Lista V3 · Uniswap V3, V4 · WOOFi |
| Polygon | QuickSwap V2, V3 · SushiSwap V2 · Uniswap V2, V3, V4 · WOOFi |
| Avalanche | Trader Joe V1 · Pangolin · Pharaoh V3 · Uniswap V3, V4 · WOOFi |
**Not read yet:** DODO, Balancer, Trader Joe Liquidity Book, THENA, the newest
Velodrome pools, Uniswap V4 pools with hooks, and private market makers or RFQ
desks. Every paid answer names the venues it did not read in `notChecked`, so
an agent never mistakes "not read" for "checked".
---
## 30-Second Quickstart
### 1. Free Preflight Gate (No wallet, no key)
Verify an x402 payment challenge before signing it:
```bash
curl -sS -X POST https://vex402.online/preflight \
-H 'content-type: application/json' \
-d '{
"kind": "payment",
"payment": {
"scheme": "exact",
"network": "eip155:8453",
"asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"amount": "10000",
"payTo": "0xAeEF086DD4e436c69d6d0F684b4c9F43392df9cb",
"resource": "https://vex402.online/verify"
},
"policy": { "maxAmountUsd": 0.25, "allowedResourceHosts": ["vex402.online"] }
}'
# The payTo above is the service's own payee (for the demo shape). Replace it
# with the real target's payee when you run this against your own 402.
```
This example uses the **live Base mainnet USDC rail** (`eip155:8453`). The free gate is only validating the request shape; it is not a payment. The public Base Sepolia testnet demo was retired on 2026-11-19; every paid call on the live service settles on mainnet in real USDC.
Returns `PASS` / `CAUTION` / `BLOCK`, typed reasons, exact `checked` and `notChecked` lists, pinned block number, and a verifiable 90-second HMAC receipt. For transactions it also returns `advice`: a plain-language explanation, a preview of what leaves and enters the wallet, and fixes for anything flagged.
A `PASS` means the listed checks passed at that block. It does **not** mean the
transaction is safe or cannot drain funds, and the paid token check is a
quote-based sellability check, not a honeypot proof. Read `notChecked` in the response.
### Test the free gate (3 testers wanted)
I’m looking for three developers building AI agents, MCP tools, or x402 payment integrations to run 3–5 real intents and report what breaks. The free gate needs no wallet. Paid calls settle in real USDC on Base mainnet at [vex402.online](https://vex402.online); the public testnet demo was retired on 2026-11-19, so try it on mainnet instead. Analysis reads mainnet chain data; no wallet or paid test is required.
- [Open the tester kit](https://vex402.online/testers) — three intents: one expected pass, one uncertain, one expected block
- [Run it in the browser](https://vex402.online/preflight#try) — paste a token address, or run the raw intent; no terminal needed
- [5-minute testing guide](TESTING.md)
- [Open a tester feedback issue](https://github.com/a32116150-ctrl/verify402/issues/new?template=tester-feedback.yml)
- [Field notes](https://vex402.online/blog) — scope, receipts, and failure modes
- [Full onboarding notes](examples/ONBOARDING.md)
The most useful finding is a **false PASS**: an intent the gate allowed that you believe is unsafe.
---
## 🤖 Using verify402 with AI Agents (Step-by-Step)
The MCP server is live on npm as **[`verify402-mcp`](https://www.npmjs.com/package/verify402-mcp)** and indexed on the official [Model Context Protocol Registry](https://registry.modelcontextprotocol.io/) (`io.github.a32116150-ctrl/verify402-mcp`).
It works with **Claude Desktop**, **Cursor**, **Windsurf**, **Cline**, **OpenCode**, and any MCP client over stdio.
### Step 1: Add the MCP Server to Your Agent
#### Option A: Free Mode (Zero Config, No Wallet, No Key)
Gives your AI agent the three free tools immediately — all nine tools are listed, but the six paid ones refuse until you add a wallet: **`preflight_gate`** (check payment challenges, token approvals, payee/amount, and transaction calldata at a fresh block before signing), **`inspect_402`** (read a 402 challenge before paying it), and **`directory_402`** (the watched list of public x402 endpoints). The paid `check_token_safety` check adds a quote-based sellability check; it does not execute a transfer and is not a honeypot guarantee.
Paste this into your client config file:
- **Claude Desktop**: `~/Library/Application Support/Claude/claude_desktop_config.json` (Mac) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows)
- **Cursor**: `.cursor/mcp.json` or Cursor Settings → MCP
- **Windsurf**: `~/.codeium/windsurf/mcp_config.json`
- **Cline**: `cline_mcp_settings.json`
```json
{
"mcpServers": {
"verify402": {
"command": "npx",
"args": ["-y", "verify402-mcp@latest"],
"env": {
"VERIFY402_URL": "https://vex402.online"
}
}
}
}
```
#### Option B: Paid Mode (Unlocks 7 Paid Checks)
Unlocks the seven paid x402 checks (`verify_arbitrage`, `check_token_safety`, `get_best_route`, `verify_quote_fairness`, `get_trade_depth`, `get_assurance`, `watch_contract`). The agent pays per call via x402 in **real USDC on Base mainnet** — $0.02 to $0.05 per call for individual checks, $0.10 for the assurance bundle, or $0.50 for a 30-day contract watch (set `MAX_PAYMENT_USD=0.50` for that one), capped by `MAX_PAYMENT_USD`. The analysis reads mainnet chain data.
```json
{
"mcpServers": {
"verify402": {
"command": "npx",
"args": ["-y", "verify402-mcp@latest"],
"env": {
"VERIFY402_URL": "https://vex402.online",
"EVM_PRIVATE_KEY": "0xYOUR_HOT_WALLET_PRIVATE_KEY",
"MAX_PAYMENT_USD": "0.25",
"MAX_DAILY_USD": "1.00",
"VERIFY402_NETWORKS": "eip155:8453",
"VERIFY402_PAY_TO": "0xAeEF086DD4e436c69d6d0F684b4c9F43392df9cb"
}
}
}
}
```
`VERIFY402_NETWORKS=eip155:8453` is the live Base mainnet rail, and it is the bridge's runtime default. Paying is bounded by `MAX_PAYMENT_USD`, `MAX_DAILY_USD`, the pinned payee and the canonical-USDC check, all enforced before a signature exists. The public Base Sepolia testnet demo was retired on 2026-11-19. There is no public testnet endpoint; the live service is the mainnet rail at https://vex402.online.
---
### Step 2: How to Set Up the Agent's Hot Wallet
If you want your agent to use the paid truth tools, follow these 4 steps to set up its wallet safely:
1. **Create a Dedicated Hot Wallet**:
- Generate a brand new EVM address using MetaMask, Rabby, or CLI (`cast wallet new`).
- ⚠️ **NEVER USE YOUR MAIN WALLET OR COLD VAULT.** Treat this wallet like physical petty cash.
2. **Fund with a small amount of USDC on Base mainnet (EIP-155:8453)**:
- Send only what you are willing to spend — the tools cost fixed amounts per call: `$0.02` (token safety), `$0.03` (route), `$0.05` (arbitrage/quotecheck/depth).
- The public testnet demo was retired on 2026-11-19; paid calls are on mainnet, in real USDC, capped per your wallet configuration.
3. **Fund with a little ETH on the same chain for gas** if your client needs it.
4. **Export the Private Key**:
- Copy the wallet's private key (hex string starting with `0x`) into the `EVM_PRIVATE_KEY` field in your MCP config.
- *Client-Side Guardrails*: The bridge enforces `MAX_PAYMENT_USD` (hard cap per call, default $0.25) and `MAX_DAILY_USD` (daily budget cap) before any signature can be created. This caps what the bridge can authorize; it is **not** protection against a compromised private key.
#### One rail: mainnet
The service is live on Base + Solana mainnet — real USDC via the Coinbase CDP facilitator, an always-on host, and a mainnet payee. The bridge defaults to Base mainnet (`eip155:8453`), so the only required paid-mode setting is the wallet key:
```bash
VERIFY402_URL=https://vex402.online # default
VERIFY402_NETWORKS=eip155:8453 # default
VERIFY402_PAY_TO=0xAeEF086DD4e436c69d6d0F684b4c9F43392df9cb
MAX_PAYMENT_USD=0.25 # default cap on one payment
```
The public testnet demo was retired on 2026-11-19. There is no public testnet endpoint.
A testnet-only 402 is refused when the policy allows mainnet, and a mainnet-only 402 is refused when it allows testnet; the bridge never crosses rails silently.
---
### Step 3: Prompting the AI Agent to Use the Tools
Once configured, restart your AI client. The agent automatically has access to the tools. You can prompt it naturally:
| What you want to do | Example Prompt to your AI Agent | Tool Called | Cost |
| :--- | :--- | :--- | :--- |
| **Verify a transaction before signing** | *"Before signing, run `preflight_gate` on the calldata to check payee, amount, approvals, and block freshness. If it returns BLOCK, stop; a PASS is not a guarantee."* | `preflight_gate` | **Free** |
| **Read a 402 before paying it** | *"Before paying this x402 endpoint, run `inspect_402` on its URL. Show me the price, token, and payee, and stop if it is BLOCK."* | `inspect_402` | **Free** |
| **See what the ecosystem charges** | *"Call `directory_402` and show me the watched x402 endpoints with their prices and verdicts."* | `directory_402` | **Free** |
| **Check measured token safety / sellability** | *"Run `check_token_safety` on token `0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE` and tell me whether it is sellable at a realistic size, what the round-trip cost is, and whether the result is TRUST / CAUTION / AVOID. This is not a code audit."* | `check_token_safety` | $0.02 |
| **Verify an arbitrage opportunity** | *"Use `verify_arbitrage` to check if the claimed arb between Uniswap V3 and Sushiswap on WETH/USDC is real right now on chain 1."* | `verify_arbitrage` | $0.05 |
| **Audit a swap quote** | *"I was quoted 0.35 WETH for 1,000 USDC. Call `verify_quote_fairness` to see if this quote is honest or if I'm being overcharged."* | `verify_quote_fairness` | $0.05 |
| **Check market depth & slippage** | *"Check `get_trade_depth` for WETH on Uniswap V3 to see how much slippage I would take on a $25,000 swap."* | `get_trade_depth` | $0.05 |
| **Find true on-chain swap route** | *"Query `get_best_route` to find the exact net payout for swapping 2,000 USDC to WETH across all DEX pools."* | `get_best_route` | $0.03 |
| **Get one evidence bundle** | *"Run `get_assurance` with the safety and route inputs you need, and show me the evidence bundle at one pinned block."* | `get_assurance` | $0.10 |
---
### Step 4: Install the preflight skill
The free agent skill lives at [`skills/verify402-preflight`](skills/verify402-preflight/SKILL.md). It is the operating manual for the gate: exact payment and transaction payloads, how to read `PASS` / `CAUTION` / `BLOCK`, how to verify the receipt before an executor signs, and when the six paid checks are worth a call. It is built around the MCP server above; the references document the non-MCP fallback.
The skill is explicit about the limits: a `PASS` is not a guarantee, the token check is not a honeypot proof, and no result is a profit forecast.
---
## Machine-Readable Discovery
- **Service Manifest:** [`/.well-known/verify402.json`](https://vex402.online/.well-known/verify402.json) ([Documentation](docs/service-manifest.md))
- **OpenAPI 3.1 Specification:** [`/openapi.json`](https://vex402.online/openapi.json)
- **MCP Registry Manifest:** [`server.json`](server.json)
- **x402 Bazaar Discovery:** [`docs/x402-discovery.md`](docs/x402-discovery.md)
- **Plain Text Contract:** [`/llms.txt`](https://vex402.online/llms.txt)
**Human Pages:** [Home](https://vex402.online/) · [Start](https://vex402.online/start) · [Tester Kit](https://vex402.online/testers) · [Blog](https://vex402.online/blog) · [Preflight Gate](https://vex402.online/preflight) · [MCP Server](https://vex402.online/mcp) · [Checks](https://vex402.online/checks) · [Live Findings](https://vex402.online/live) · [Proof & Receipts](https://vex402.online/proof) · [Docs](https://vex402.online/docs) · [Donate](https://vex402.online/donate)
---
## Why an agent would pay for this
Models hallucinate profit. Most arb "opportunities" an LLM surfaces are stale, ignore
fees, or come from a quote that was never checked against the venue that would
execute the trade. This service exists to be the check an agent cannot do itself.
## The measurement discipline
Quotes come from the canonical on-chain sources — **never our own reimplementation
of venue math**:
- V3: Uniswap's deployed `QuoterV2` (its answers are the router's answers by construction)
- V2: each router's own `getAmountsOut`
Both legs are measured against **one block number**, so the round trip reflects a
single instant rather than two prices that never coexisted.
Three bugs were caught by the test suite before this ever served a paid response,
and they are the reason the tests exist:
1. **Invented profit (the big one).** `decodeFunctionResult` on `getAmountsOut` — a
single declared output, which viem unwraps — was indexed with `decoded[0]`,
silently grabbing the array's first element: the *input* amount. On the sell leg
that turned 41 WETH into 41 **trillion** USDC of "profit". Now the decoder finds
the `uint256[]` structurally and refuses a result equal to the input.
2. **Basis points off by 100x.** −292 USDC on a 100,000 USDC round trip rendered as
−0.29 bps instead of −29. A rounding trick multiplying by `10_000n` instead of
`1_000_000n` when keeping two decimals of precision.
3. **Venue that doesn't exist still gets reported.** Started as an unasserted
assumption; `all configured venues exist on-chain` is now a test.
```bash
node test/measure.test.mjs # 5 checks, needs a mainnet RPC
```
One check is the headline property: *a 100k USDC round trip on Ethereum must NOT
come out profitable.* If it ever does, the engine is wrong until proven otherwise.
## Run it
```bash
npm install
npm test # full suite (RPC checks need network)
node src/server.mjs # boots the testnet sandbox (local dev; public demo retired 2026-11-19)
BYPASS_PAYMENT=1 node src/server.mjs # local dev only - loud warning, no billing
X402_MODE=mainnet FACILITATOR_URL=... AGENT_URL=https://verify402.example node src/server.mjs
```
Mainnet refuses to start without `AGENT_URL`: the agent card is a public
identity document and must not derive its origin from the request's `Host`
header. In testnet/local mode the card falls back to a Host allowlist
(`TRUSTED_HOSTS`, plus `localhost` / `127.0.0.1`); an unlisted Host gets
`400 untrusted_host` instead of being reflected.
Paid checks are computed only by the private `verify402-engine` service. The
public modules are thin, license-gated clients: direct imports from a clone
need a signed `VERIFY402_LICENSE_KEY` and a configured private service, and
fail closed otherwise. Hosted paid endpoints, free `/preflight`, payment,
recovery and receipts are unchanged. See `docs/LOCAL-LICENSE.md`.
## Endpoints
| Route | Price | What it does |
|---|---|---|
| `POST /preflight` | free | pre-signing gate: validate a payment request or transaction, return PASS / CAUTION / BLOCK + a short-lived receipt |
| `POST /preflight/verify` | free | verify a preflight receipt (HMAC, expiry, optional intent + request bindings) |
| `POST /verify` | $0.05 (x402) | the measurement, with verdict + evidence |
| `POST /safety` | $0.02 (x402) | pre-trade token check: TRUST / CAUTION / AVOID + evidence; not a code audit |
| `POST /route` | $0.03 (x402) | what would the chain ACTUALLY pay for this swap? best route + every quoted venue |
| `POST /quotecheck` | $0.05 (x402) | audit a quote someone else gave you: fair / overpaying / too_good_to_be_true |
| `POST /depth` | $0.05 (x402) | position sizing: how big can I trade before the round trip eats me? |
| `GET /findings` | free | live no_edge verdicts on Ethereum majors |
| `GET /info` | free | machine-readable service description |
| `GET /usage` | free | anonymous tool, gate and inspect-host call counts (persisted when a durable path is configured) |
| `GET /usage/site` | free | aggregate HTML page views of the human site: no cookies, no IP, no query strings |
| `GET /health` | free | liveness |
`POST /depth` is the pre-trade sizing question nothing on-chain answers.
Pool-reserve "liquidity: $2.7M" tells an agent nothing about the block it
will actually trade in. The depth engine buys the target with the best route
at each rung of a USD ladder, immediately sells the exact position back, and
reports per-rung impact %, round-trip cost %, and `capacityUsd` — the largest
size that stays under the caller's cost tolerance. Live example (SHIB,
2.5% tolerance): "$2.7M liquidity" resolves to a real capacity of **$1,000**
($100 → 1.20% round trip, $10k → 6.57%). The ladder is the honest answer.
## The preflight gate
`POST /preflight` is the free control an agent runs immediately before signing.
It accepts one of two intents:
- **payment** — an x402 402 challenge (EVM or Solana): scheme, CAIP-2 network,
asset, raw amount, `payTo`, resource, timeout, authorization window.
- **transaction** — `chainId`, `to`, `data`, `value`, optional `from` (EVM:
Ethereum 1, Arbitrum 42161, Base 8453, OP Mainnet 10, BNB Chain 56, Polygon 137,
Avalanche 43114, plus 15 gate-only networks: Unichain 130, Monad 143, Arc 5042,
HyperEVM 999, Plasma 9745, Linea 59144, MegaETH 4326, Ink 57073, World Chain 480,
Soneium 1868, Gnosis 100, Cronos 25, Sonic 146, ZKsync Era 324, Robinhood Chain 4663).
Paid checks run on the first seven; payment rails stay on Ethereum, Arbitrum and Base.
The response also says who can upgrade the contract being called (`upgradeControl`).
Response: `PASS` / `CAUTION` / `BLOCK`, `reasons[]`, `checked[]`,
`notChecked[]`, and a receipt:
```json
{
"verdict": "CAUTION",
"sign_allowed": true,
"requires_ack": true,
"reasons": [{ "code": "unlimited_approval", "severity": "caution", "message": "..." }],
"checked": ["scheme", "network", "asset", "amount", "payee", "resource_url", "resource_host", "payer_balance", "block_freshness"],
"notChecked": ["recipient reputation", "sanctions screening", "payment signature / signed payload", "facilitator settlement", "off-chain promises", "counterparty identity / tool metadata", "payTo ownership / proven seller payout wallet", "obligation state (idempotency key, cumulative spend, grant balance)", "prompt injection / hidden Unicode in tool output"],
"receipt": {
"spec": "verify402/preflight-receipt@1",
"intentHash": "…",
"requestHash": "…",
"blockNumber": 48277717,
"blockHash": "0x…",
"expiresAt": "2026-10-19T…Z",
"signature": "…"
}
}
```
- The receipt is HMAC-SHA256 signed, bound to the canonical normalized intent,
the exact request body the gate received, a fresh pinned block where the
chain is readable, and an expiry (default 90s, max 300s). `POST /preflight/verify`
recomputes the signature and, when supplied, the caller's `intent` and
`request` hashes. Pass `request` to bind the receipt to the original fields
without reimplementing normalization. `requestHash` is an additive field
within `verify402/preflight-receipt@1`; receipts issued before it existed
remain signature-valid but are **not caller-bound**, and verify with
`missing_request_hash` when `request` is supplied. A receipt with no
`intentHash` returns `missing_intent_hash`. Receipt-only verification stays
compatible but reports `intentBound:false` and `requestBound:false`; the
reference executor requires both bindings.
- **Fresh block, not just any block:** on EVM chains, a latest block older than
**30s** is `CAUTION`; older than **120s** is `BLOCK`. The response carries
`block.timestamp` and `block.ageSeconds`. A block with no timestamp is a
`503`, not a PASS.
- **Fail-closed:** if the chain cannot be read, the endpoint returns `503` and
no receipt. An executor must refuse to sign without a verifiable receipt.
- **Advice (transactions):** the response also carries `advice`, which explains
the transaction and how to repair it. It never changes the verdict and is
not covered by the receipt.
- `explanation`: one plain sentence, e.g. *"Swap 100 USDC for at least
0.0589 WETH via uniswap-v3, paid to your wallet. It must execute within
about 5 minutes. No problems found in the checks that ran."*
- `preview.effects`: what leaves and enters the wallet (`send`,
`receive_at_least`, `receive_expected` from a supplied quote, `allow`), in
raw and human units, with dollars for known stables; `preview.networkFee`
when the call was simulated for `from`.
- `fixes`: one entry per flagged problem, with the action to take and, where
possible, suggested values (`amountOutMinimum`, `recipient`) or the exact
fields that differ from the quote.
- `upgrades`: optional paid checks that fit this transaction (for example
`check_token_safety` for an output token verify402 does not know).
- Optional `quote` (the quote a transaction came with: `spender`,
`input {amount, token}`, `output {amount, minimumAmount, token}`,
`expiresAt`) binds the transaction to it; any difference is `BLOCK`.
- The hosted service may add `involved` (who the transaction touches) and
`risk` (dollar exposure) from operator plug-ins.
- **Risk limit (`policy.maxRiskUsd`):** the owner's dollar limit for one
transaction. The gate measures what is at risk (what leaves the wallet, or
what an approved spender could take) and compares it to the limit: within
adds `risk_limit` to `checked`; over is `BLOCK` (`risk_over_limit`); not
measurable (no reliable price) is `CAUTION` (`risk_unmeasured`), never a
guess. `advice.riskLimit` shows `limitUsd`, `atRiskUsd`, `basis` and
`within`. Prices are estimates at that moment; this is a limit on what the
agent may sign without asking, not insurance or a guarantee.
- **Optional caller-supplied state:** the gate has no cross-process payment
ledger, so it can only check obligation state the caller supplies:
- `payment.idempotencyKey` plus `policy.obligation.settledKeys` catches a
re-presented key (`obligation_already_settled`).
- `policy.obligation.spentUsd` plus `grantUsd` catches cumulative spend over
the grant (`cumulative_spend_over_grant`).
- `policy.sellerPayoutWallets` is a **caller-supplied allowlist**, not
provenance. A match adds `payee_payout_allowlist`; a mismatch is
`payee_not_payout_wallet`. It never adds `payee_payout_binding`.
- `policy.sellerPayoutManifest` fetches a seller-signed manifest from a
caller-pinned HTTPS origin outside the 402. Only a verified manifest whose
`payTo` list contains the payment payee adds `payee_payout_binding`. The
response includes `payeeBinding` with `source`, `origin`, `signer`,
`expiresAt`, and `manifestHash`. A manifest that is missing, expired,
invalid, for another chain, or signed by the wrong key is CAUTION/BLOCK.
These are caller bindings, not a server-side ledger and not independent proof
that the seller controls the wallet. Without them, the response says so in
`notChecked`.
Seller manifest shape (`verify402/seller-payout@1`):
```json
{
"spec": "verify402/seller-payout@1",
"seller": "seller.example",
"chainId": 8453,
"payTo": ["0xSellerPayout..."],
"issuedAt": "2026-10-24T00:00:00Z",
"expiresAt": "2026-11-24T00:00:00Z",
"signer": "0xSellerSigner...",
"signature": "0x..."
}
```
The signature is EIP-191 `personal_sign` over `canonicalStable` of the
manifest without `signature` (keys sorted recursively, no whitespace). The
URL must be HTTPS and public; credentials, localhost, private hosts, private
DNS resolutions, and redirects are rejected. Pin `expectedSigner` when the
seller key is known. The gate cannot tell whether the caller copied the
manifest URL from the 402; the URL must come from the caller's own seller
configuration, and that remaining trust assumption is named in `notChecked`.
- **Not checked, on purpose:** recipient reputation, sanctions, contract
audits, full balance-delta simulation, MEV, the payment signature/signed
payload, gas price/limit chosen by the signer, raw signed-transaction binding,
facilitator settlement, counterparty identity/tool metadata, and prompt
injection or hidden Unicode in tool output. They are named in every response
instead of being implied. A PASS is not a counterparty audit.
- Free is rate-limited (60/min per IP, 8 concurrent) so it cannot become a
public RPC proxy.
- `GET /usage` is an anonymous call counter. The MCP bridge sends
`X-Verify402-Client: verify402-mcp/<version>` so its calls can be separated
from generic HTTP probes. The label is self-declared, spoofable, and never an
identity; `/usage` also reports whether each label came from the header or the
User-Agent. The number of distinct labels is capped so a caller cannot grow
the counter without bound. When `VERIFY402_USAGE_PATH` is set (or a durable
path exists next to `RECOVERY_DB_PATH`), the counters are written to a small
JSON file and survive restart and deploy; otherwise they are process-local and
reset on restart or deploy. The bridge can also opt into an anonymous usage
ping (`VERIFY402_TELEMETRY=1`) that reports only the tool name and whether it
worked, never arguments or intents.
The MCP server exposes it as `preflight_gate`. It runs with no wallet (free gate
only); add `EVM_PRIVATE_KEY` for the six paid tools. If `sign_allowed` is
false, do not sign; if `requires_ack` is true, surface the reasons to the
operator. Client configs and the install command are at
[`/mcp`](https://vex402.online/mcp).
### Reference executor
`examples/preflight-guard.mjs` is a small repo-local, deny-by-default wrapper
(its only import is verify402's own canonical request-hash helper):
it calls the gate, refuses `BLOCK`, requires an explicit acknowledgement for
`CAUTION`, verifies the receipt, and only then calls **your** signer. It holds
no key and sends nothing itself. The intent is cloned and deep-frozen before the
gate, and that same object is passed to the signer. If you do not want to trust
the public instance, run your own and pin `baseUrl`.
For x402 clients, `createX402PreflightHook()` is the automatic version. Add one
line to `onBeforePaymentCreation`; it maps the selected requirement to a payment
intent, blocks on `BLOCK`, refuses unacknowledged `CAUTION`, verifies the
receipt, and attaches it to `context.verify402` before the SDK can sign. See
[`examples/README.md`](examples/README.md).
`POST /verify` request:
```json
{ "chainId": 1, "target": "WETH", "base": "USDC", "size": 100000, "minNet": 0 }
```
Response (abridged):
```json
{
"verdict": "no_edge",
"blockNumber": 26214368,
"buy": { "venue": "uni-v3-0.05%", "amountOutHuman": 41.366 },
"sell": { "venue": "uni-v3-0.05%", "amountOutHuman": 99707.9 },
"gross": { "human": -292.08, "bps": -29.23 },
"net": { "human": -342.14, "bps": -34.23 },
"costs": { "flashLoanPremiumBps": 5, "gasUsd": 0.0561 },
"venues": { "quoted": 12, "buySide": [...], "sellSide": [...], "unavailable": [...] },
"caveats": ["..."]
}
```
`verdict` is one of `edge` (net cleared `minNet`), `no_edge_costs_ate_it` (gross
positive, costs larger), or `no_edge` (unprofitable before costs).
`POST /safety` request (accepts any ERC-20 address, not just registry symbols):
```json
{ "chainId": 1, "tokenAddress": "0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE", "intendedUsd": 500 }
```
Response (abridged):
```json
{
"verdict": "TRUST",
"quote_status": "ok",
"checked": ["contract", "market", "quote-based sellability", "liquidity"],
"notChecked": ["actual token transfer or sell execution", "transfer tax / fee-on-transfer",
"blacklist / pause / max-tx restrictions", "venues not in config"],
"notes": ["quoteable sell via uni-v3-0.3% via hop, uniswap-v2 via hop, ...",
"round trip in and out of $500 costs 1.42%"],
"evidence": { "contract": {...}, "market": {...},
"sellability": { "canSell": true, "probedInUsd": 25,
"caveat": "quote-based only: a quote does not prove a transfer will succeed" },
"liquidity": { "roundTripCostPct": 1.42 } },
"elapsedMs": 1434
}
```
`verdict` is one of:
- `AVOID` — positively dangerous: no configured venue can quote an exit at a
realistic size, or the contract is not a token at all
- `CAUTION` — tradable, but with a stated cost or problem (thin pool,
manufactured price, expensive round trip)
- `TRUST` — every check that ran passed; still not a promise of profit, only a
record that nothing measured was wrong
This is a **quote-based sellability check**. It asks the configured venues'
own routers for a price; it does not execute or simulate a transfer, so
transfer tax, blacklist, pause, and max-transaction restrictions are listed in
`notChecked`, not silently assumed away. Venues that are not configured on the
chain are also named in `notChecked`.
Probes are USD-sized on purpose: an earlier version probed "half a token" and
flagged SHIB — a $1B token — as unexitable, because half a SHIB is dust no pool
can quote. The test suite and live calls caught that before it launched; every
future verdict change must be explainable, not silent.
A request without payment gets `402Payment Required` with instructions in the
`PAYMENT-REQUIRED` header; the client pays and retries with proof — that is the
entire x402 flow, and it is what makes the caller a program rather than a person.
## Deploying
See `DEPLOY.md` — free-tier container deployment, ERC-8004 identity mint
(`npm run register`, owner's key, on-chain data URI), mainnet facilitator
wiring, and the distribution order.
## MCP: how AI agents consume this
`mcp-bridge/` is packaged as **`verify402-mcp`** (stdio). It exposes the free
pre-signing gate (`preflight_gate`), the 402 inspector and directory, and the seven paid endpoints
(`verify_arbitrage`, `check_token_safety`, `get_best_route`,
`verify_quote_fairness`, `get_trade_depth`, `get_assurance`, `watch_contract`) to Claude Desktop, Cursor, OpenCode,
or any MCP client.
- **Free gate:** omit `EVM_PRIVATE_KEY`; the server lists all ten tools, the
three free ones work as before, and the seven paid ones refuse with a clear error.
Nothing can be charged.
- **Paid tools:** add a dedicated hot wallet with a small amount of USDC on
Base mainnet at https://vex402.online (the public testnet demo was retired on 2026-11-19). The bridge signs the x402
payment only — never a trade — and enforces `MAX_PAYMENT_USD` (default $0.25)
in the pre-signature guard before any signature exists. It also requires an
allowlisted EVM network, the verify402 payee, and a known paid resource on the
configured server, and refuses redirects. `MAX_DAILY_USD` is optional.
- **New in `1.1.0` (unchanged in `1.1.2`):** the bridge no longer depends on the `@x402/axios` or
`@x402/evm` SDK. The x402 v2 payer is implemented locally on `viem`
(`mcp-bridge/x402-client.mjs`), so a clean install reports **0 audit
vulnerabilities** instead of the nested-zod advisory carried by the SDK.
The wire protocol, spend guard, and paid-tool behavior are unchanged.
- **`1.0.8` added:** payout provenance is no longer inferred from a
caller-supplied wallet list. `policy.sellerPayoutWallets` is an allowlist;
only a verified, seller-signed `policy.sellerPayoutManifest` adds
`payee_payout_binding`. It also adds
`createX402PreflightHook()` / `guardX402Payment()` to the example executor,
and sends `X-Verify402-Client: verify402-mcp/<version>` so `/usage` can
separate MCP bridge calls from generic HTTP. Labels are self-declared and
spoofable, not identities.
- **Install:** `npx -y verify402-mcp@latest` from the public npm registry
(currently `3.6.0`). For a pinned install of the published package, use
`npx -y verify402-mcp@3.6.0`; its npm tarball is
`https://registry.npmjs.org/verify402-mcp/-/verify402-mcp-3.6.0.tgz`. `1.1.6`
moved the paid-call default to the live Base mainnet rail (`eip155:8453`,
real USDC), with the same spend caps; the retired Base Sepolia testnet demo
(`eip155:84532`) is an explicit opt-in via `VERIFY402_URL` and
`VERIFY402_NETWORKS`. `3.6.0` adds the `watch_contract` tool ($0.50 watches one contract for 30 days; set `MAX_PAYMENT_USD=0.50` to use it); `3.5.0` describes the 22 networks, upgrade control and the improved route and quote checks in its tool help; `3.1.0` adds `advice` (explanation, wallet preview, fixes) to preflight_gate; `3.0.1` adds optional quote binding to preflight_gate and ships with Solana payment recovery on the live service; `2.6.1` aligns the bridge's price defaults and public copy with the live service; `2.6.0` lists all nine tools for every install — paid tools refuse without a wallet; `2.5.0` retired the testnet demo — paid calls are mainnet-only (real USDC); `2.0.0` added the paid assurance endpoint and the hash-bound evidence bundle; `1.1.7` was a metadata-only correction so the MCP
Registry advertises that same mainnet default. No npm account is required to
run the published package. Client configs, the exact OpenCode V2 shape, and
the release command are at [`/mcp`](https://vex402.online/mcp). The immutable
`1.1.6` and earlier packages remain published; `1.1.5` and below defaulted
to testnet, and `1.0.4` used Base mainnet. The official MCP Registry lists
the published entry as active (`isLatest: true`).
## Settlement, response delivery, and recovery (honest contract)
> **Recovery state (read this before relying on it):** with `RECOVERY_DB_PATH` set, the
> recovery store is a write-ahead SQLite file — a staged payment is journaled to disk
> *before* the facilitator settlement call — so a settled verdict and its replay counter
> survive a restart, a redeploy, or a SIGKILL, and a caller retrying after a lost response
> is not charged again. Without the variable the service keeps the historical memory-only
> behavior: a restart loses the records, and a previously settled key may be charged again.
> `/usage` counters are process-local unless `VERIFY402_USAGE_PATH` is set, or `RECOVERY_DB_PATH` is set and a `usage.json` sits beside it; then they are durable file counters. The store is **single-instance by
> construction**: one server process per database file (see `DEPLOY.md` §3.1).
- **Delivery:** the verdict is returned inside the settlement response — the paid answer
arrives together with the payment confirmation (historical testnet receipt, before the demo retired: tx
`0x11121007bafec47f132763f42e2f58af6ebba7fba9c7ed1b5980d3f595a9324a`).
- **Recovery — implemented (`x-idempotency-key`):** send the header on the FIRST call of an
operation, minting ONE key per operation. If the response is lost after settlement,
retrying with the same key returns the SAME verdict without requiring payment again:
10 minutes (max 3 replays). Caveats stated plainly: the key is the caller's secret
(whoever presents it replays for free), the window is short by design so the 402 paywall
stays intact, and replayed responses carry `recovery: { replayed: true, responseHash, replays }`.
- **Key strength (required):** use `crypto.randomUUID()` or at least 32 URL-safe
characters (`A-Z`, `a-z`, `0-9`, `_`, `-`) with at least 16 distinct characters.
Short, repeated, sequential, or low-entropy keys are rejected with
`400 weak_idempotency_key` and guidance to generate a key. Requests without a key
keep working exactly as before; they simply do not get recovery.
- **The key is a secret.** A leaked key allows anyone to replay the settled verdict
until the 10-minute window closes or the 3-replay cap is reached. Do not put it in
logs, URLs, screenshots, or public issue reports. If it leaks, use a new key for the
next operation; the old key cannot be revoked except by the short TTL/cap.
- **What recovery does not guarantee:** it does not prove payment, refund a failed call, replay
after the TTL or cap, or recover a response if the caller lost the key. Durability (with
`RECOVERY_DB_PATH`) covers the verdict and its replay budget only — not `/usage` counters —
and it is not a cross-instance ledger: one database file, one server process. Without the
variable, recovery does not survive a restart at all.
- **Concurrent retries:** the first same-key request reserves the key before the
paywall. A second request gets a typed `409 recovery_conflict` with
`code: operation_in_flight`, or `settlement_pending` while a staged settlement is
unresolved. Without a durable store the reservation is in-process and lost on restart;
with `RECOVERY_DB_PATH` the staged row survives the restart and stays unreplayable until
reconciliation resolves it (on-chain `authorizationState(payer, nonce)` check — see
`DEPLOY.md` §3.1). If the store cannot journal a payment, the paid route answers
`503 recovery_unavailable` instead of settling unrecorded; `/health` reports the store as
`ok`, `unavailable`, or `memory-only`.
- **Settlement-gated (fail-closed):** a verdict record only becomes replayable
**after the facilitator confirms the settlement** (official x402 `onAfterSettle`
hook). Promotion is keyed on a server-generated `operationId` carried in the
response (`recovery.operationId`, excluded from the projection) and requires a
confirmed settle result with a non-empty transaction reference; the projection hash
of the served bytes is an additional check. **Equal output does not identify an
operation** — two requests that both resolve to `{"verdict":"no_match"}` are still
distinct, and settling one never promotes the other. A failed, aborted or pending
settlement promotes nothing. The replay cap (3) is per operation, bound to the key.
- **The key is the only credential.** The service does **not** derive a payer identity
from `x-payment`, `payment-signature`, or `payload.authorization.from`; those headers are
unverified at the recovery layer. The facilitator-confirmed payer is stored as
`verified_payer` for audit only. A forged `authorization.from` cannot replay anything.
- **No companion alias.** An earlier design also recorded a verdict under a hash of the
canonical request content. That made a settled verdict readable by anyone who could
reproduce the body, so it was removed. A secret token returned only in the original
response cannot help a lost-response retry; the original key is the only secret that
survives, so it is the only one accepted. Reusing a key with **changed request content**
returns `409 recovery_conflict` (`conflict: "request_mismatch"`) *before* the paywall —
never the other operation's verdict, never a charge.
- **After the window (typed, not silent):** expired verdicts leave a tombstone carrying the
previous `responseHash` for 6 hours. A retry within the tombstone window re-measures with
the paywall re-armed (there is no free measure after the window — anything else would be a
loophole), but the response carries `recovery: { remeasured: true, previousResponseHash,
expiredAt }`, so the calling agent can branch on "this operation was charged before and
could not be replayed" instead of guessing.
- **Regression controls:** `test/recovery.test.mjs` covers forged `authorization.from`,
a different key with a known body, the victim's replay budget under forged traffic, and
legitimate replay. Two staged operations with byte-identical output do not cross-promote;
promotion is refused on failed/pending settle, a missing/empty transaction, or a missing
`operationId`. `test/recovery-durable.test.mjs` does the same across **fresh processes and
real SQLite files**: SIGKILL after staging, a corrupt database, a locked database, restart
reconciliation of a staged record, and the mainnet start guard that refuses to boot without
`RECOVERY_DB_PATH`.
- **Evidence bundle — implemented (`verify402/evidence-bundle@1`):** every paid response
carries `evidence_bundle: { requestHash, responseHash, pinnedBlock, mode, createdAt,
payment.in }`. Both hashes are sha256 over canonical JSON (keys sorted recursively, no
whitespace). `requestHash` covers `{ route, body }`; `responseHash` covers the response
body excluding `evidence_bundle`, `recovery`, `cache`, `elapsedMs`, and `operationId`. Reference
implementation of the canonical form: `src/recovery.mjs` (`canonicalStable`), tests in
`test/recovery.test.mjs`.
- **Payment caps (bridge/client):** `MAX_PAYMENT_USD` caps one payment at signature time;
`MAX_DAILY_USD` (optional, `mcp-bridge/budget.mjs`) caps the whole UTC day across
restarts via a local ledger. Attempted charges are counted before the payment is built —
a spending guard should over-count, never under-count.
## Errors, honesty, chainId, and readiness
- **Honesty contract:** every `200` and every typed failure on `/verify`, `/safety`,
`/route`, `/quotecheck`, and `/depth` includes non-empty `checked[]` and
`notChecked[]`. `notChecked` names the real limits (unconfigured venues, transfer
restrictions, execution, MEV) rather than implying coverage that doesn't exist.
- **Typed quote outcomes:** `quote_status` is `ok | partial | no_pool | failed`.
`transport` and `decode` failures return `ok:false` with HTTP `503` and never
become `AVOID`, `no_edge`, `unknown`, or `illiquid`. Only a genuine `no_pool` or
venue `revert` may make a leg unavailable.
- **No settlement on failure:** the installed `@x402/express` middleware cancels
settlement for any response `>= 400`. A `503` (transport/decode/RPC) is not charged.
- **Errors never leak:** responses carry a stable public code (`bad_request`,
`rpc_unavailable`, `rpc_rate_limited`, `internal_error`, …) plus a `requestId`.
Provider messages, RPC URLs, and API keys stay in the server log under the same id.
- **chainId is required:** every paid route and every transaction preflight requires an
integer `chainId`. Missing => `400 missing_chain`; wrong type => `400 invalid_chain`;
unsupported => `400 unsupported_chain`. There is no silent Ethereum default.
- **Readiness:** `/health` is liveness; `/ready` is a deep check that reads the latest
block with a 3-second timeout.
- **Security headers:** every response sets `X-Content-Type-Options: nosniff`,
`Referrer-Policy: strict-origin-when-cross-origin`, `X-Frame-Options: DENY`, and a
Content-Security-Policy written for the static site (self-hosted scripts, Google
Fonts, no framing). `x-powered-by` is disabled.
- **CORS:** free read-only discovery (`GET`/`HEAD`/`OPTIONS` on `/info`, `/health`,
`/ready`, `/openapi.json`, `/llms.txt`, and `/.well-known/*`) allows any origin.
`POST /preflight` and paid routes send no `Access-Control-Allow-Origin`; browser-based
agents must use a server-side client, the MCP bridge, or an SDK.
- **Shutdown:** `SIGTERM`/`SIGINT` stop new connections immediately, drain in-flight
requests for up to `SHUTDOWN_TIMEOUT_MS` (default 10000), then exit `0`. A drain
timeout force-closes connections and exits `1` so a stuck deploy is visible.
## First paid call, in ten lines
1. `GET https://vex402.online/info` — prices, endpoints, recovery contract.
2. `GET https://vex402.online/findings` — free verdicts on majors; see the honest `no_edge` baseline.
3. `POST /verify` with your question (`{"chainId":1,"target":"WETH","size":100000}`) and no payment → HTTP 402.
4. Read the payment instructions from the `PAYMENT-REQUIRED` response header.
5. Build an x402 payment for ≤ the stated price (Node example: `mcp-bridge/first-payment.mjs`; MCP users: `mcp-bridge/`). The live challenge is Base mainnet (`eip155:8453`).
6. Re-send the same request with the proof in the `PAYMENT-SIGNATURE` header (x402 v2; the legacy `x-payment` header is also accepted). The verdict arrives with the settlement response.
7. On a retry/restart, add `x-idempotency-key: <crypto.randomUUID()>` to step 3 so lost responses replay free instead of paying twice. The key is a secret; a leaked key allows replay until the TTL/cap.
8. Verify the receipt: `evidence_bundle.responseHash` must equal sha256(canonical JSON of the body minus `evidence_bundle`, `recovery`, `cache`, `elapsedMs`).
9. Cap your own wallet: `MAX_PAYMENT_USD` (per call) and `MAX_DAILY_USD` (per day) in the bridge `.env`.
10. Repeat the call in the same block and compare `evidence_bundle.responseHash` — determinism of the measurement. An `edge` verdict should be raced, not trusted.
## Honesty
- No profit is promised. The measured answer for mainstream pairs is almost always
`no_edge` — that is the market's fee boundary, not a failure of the tool.
- The service reports what it measured, not what it guarantees.
- Not financial advice.
## Hosting status
The mainnet instance (https://vex402.online) is always-on and is the package default. The public testnet demo was retired on 2026-11-19.
## License
Apache License 2.0. See `LICENSE` and `NOTICE`.
This repository is open-core: the free gate, receipts and MCP client are Apache-2.0; the paid check engines are hosted and are not included in the public source.
You may use, modify, and distribute these open-source parts, including in commercial agent
systems and bots. If you redistribute it or a product containing it, keep the
copyright notice, the license text, and the `NOTICE` file. The `verify402` name
and logo are not licensed for endorsement.
TDQS
Scored across 10 tools
The tools cover genuinely distinct actions: preflight gating, token safety, route discovery, quote auditing, depth measurement, arbitrage detection, and x402 challenge inspection. The three price-oriented tools (get_best_route, verify_quote_fairness, verify_arbitrage) sit close together, but the descriptions sharply delineate 'my own swap', 'someone else's quote', and 'cross-venue edge'. get_assurance intentionally duplicates the individual paid checks as a bundle, which is a mild ambiguity but clearly framed as a bundle.
Most tools follow a verb_noun pattern (verify_arbitrage, verify_quote_fairness, check_token_safety, get_best_route, get_trade_depth, get_assurance, watch_contract, inspect_402), which is predictable. Deviations are minor: directory_402 is a noun-style name and preflight_gate is noun_compound, and the _402 suffix is applied inconsistently (only two tools).
10 tools is well within the sweet spot and each one earns its place: a coherent suite of read-only verification primitives plus a bundle aggregator. No filler tools, and the free/paid tiering (preflight, directory, inspect) adds value rather than redundancy.
The surface covers the pre-signing lifecycle well: gate, token safety, routing, quote audit, depth, arbitrage, contract watching, and x402 challenge inspection/directory. Gaps are minor and mostly intentional (read-only by design, no execution), though there is no allowance/approval inspection or revoke tool and check_token_safety explicitly leaves transfer-tax/blacklist untested, which agents must work around.