# Preflight > Pay-per-call smart-contract & transaction pre-flight security API. Submit > Solidity source or a transaction for simulation and receive a severity-scored, > signed security verdict. Paid per call via x402 (HTTP 402 + real USDC on > Base mainnet). ## Free token-risk demo `GET /v1/token-risk/demo?address=0x...` — **FREE** (5/day per identity): the FULL token-risk report. See exactly what a $0.02 paid call buys before paying. Returns the same honeypot, transfer-tax, and owner-privilege findings as `POST /v1/token-risk`, with `demo: true` in the body. ## Endpoints | Method | Path | Price | Auth | |---|---|---|---| | GET | `/` | free | none | | GET | `/health` | free | none | | GET | `/metrics` | free | none | | GET | `/v1/token-risk/demo` | free (5/day) | none | | POST | `/v1/scan` | $0.01 | x402 | | POST | `/v1/sim` | $0.05 | x402 | | POST | `/v1/sim/deep` | $0.25 | x402 | | POST | `/v1/scan/project` | $0.10 | x402 | | POST | `/v1/address-risk` | $0.005 | x402 | | POST | `/v1/token-risk` | $0.02 | x402 | | POST | `/v1/bundle` | $0.03 | x402 | | GET | `/v1/verify` | free | none | ## Related service: Greenlight Greenlight (https://preflight--greenlight-api-api.modal.run) is the complementary pre-trade wallet intelligence: wallet-intel ($0.01), pair-check ($0.03), batch ($0.05). Preflight analyzes the contract; Greenlight clears the trade. Free trial: send header `X-Preflight-Free: trial` to get your first 10 scans/day free (opt-in; requests without the header are paywalled normally). `/v1/sim` is quick transaction pre-flight simulation: give a target `to`, optional 0x-hex calldata `data`, and optional `value_wei`; get back a `SimReport` with `reverted`, `revert_reason`, `gas_used`, and severity-scored findings (a reverting call is a real finding, not a client error). `/v1/sim/deep` runs the same request on a local anvil fork ($0.25) and adds measured `gas_used`, the sender's `balance_delta_wei`, and the `internal_calls` trace — use it for honeypot/MEV checks where a bare `eth_call` is not enough. `/v1/token-risk` is the trading-agent route: check a token before you trade it. Give the token contract address and get back a honeypot verdict, transfer tax percentage, and owner-privilege findings as a severity-scored `ScanReport` ($0.02). It is address-first: no Solidity source or contract name needed. The free demo (`GET /v1/token-risk/demo?address=0x...`, 5/day) returns the FULL report so you can inspect the shape before paying. `/v1/bundle` ($0.03) runs token-risk, address-risk, and an optional source scan in one call. Send `{address}` alone, or add `"source"` for a full Solidity analysis alongside the address checks. `/v1/verify` is free: pass a report's `source_sha256` as `digest` (and the report's `attestation` JSON as `attestation`) to verify the EIP-712 signature. The attester signer for the live service is `0x3779bb827AB1F32A317fD30157Ac03Dc5CCA88aa`. `/metrics` exposes revenue and usage counters (for example `revenue_base_units`) with no payment. ## Payment - Network: `base` (CAIP-2 `eip155:8453`, Base mainnet) - Asset: USDC `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` (6 decimals) - Scheme: `exact` (EIP-3009 transfer-with-authorization) - Pay to: `0x5515f59a30fe2b9152cd5648a3a0d8c30c837d41` - Facilitator: `https://api.cdp.coinbase.com/platform/v2/x402` (Coinbase CDP; `https://x402.org/facilitator` is the public fallback) - Attestation signer: `0x3779bb827AB1F32A317fD30157Ac03Dc5CCA88aa` — verify at `GET /v1/verify` A paid route responds `402 Payment Required` with a `PAYMENT-REQUIRED` header containing the x402 payment requirements. Retry the same request with a `PAYMENT-SIGNATURE` header carrying the signed payment payload. A successful paid response carries a `PAYMENT-RESPONSE` header with the settlement result. No account is required by default. If the operator enables the optional API-key layer (`PREFLIGHT_API_KEYS`), paid calls must also send `X-Preflight-Key: `; the MCP server reads `MCP_API_KEY` (or the first `PREFLIGHT_API_KEYS` entry) and the demo client accepts `--key` / `PREFLIGHT_API_KEY`. ## Request bodies `POST /v1/scan`: ```json { "source": "pragma solidity ^0.8.20; contract Vault { ... }", "contract_name": "Vault", "solc_version": "0.8.20" } ``` `POST /v1/sim`: ```json { "to": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "data": "0xa9059cbb...", "value_wei": "0", "from_address": "0x...", "source": "pragma solidity ^0.8.20; contract Token { ... }" } ``` Only `to` is required. `data` is 0x-hex calldata; omit it for a plain value transfer. `source` is optional Solidity source for static honeypot detectors. `POST /v1/scan/project`: ```json {"files": {"Vault.sol": "pragma solidity ^0.8.20; contract Vault { ... }"}, "contract_name": "Vault"} ``` `POST /v1/address-risk`: ```json {"address": "0x5515f59a30fe2b9152cd5648a3a0d8c30c837d41"} ``` `POST /v1/token-risk`: ```json {"address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"} ``` Returns the same `ScanReport` shape, with honeypot, transfer-tax, and owner privilege findings. `POST /v1/bundle`: ```json { "address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "source": "pragma solidity ^0.8.20; contract Token { ... }" } ``` `source` is optional; omit it for address-only analysis. The response combines the token-risk, address-risk, and optional source-scan results. ## Response (ScanReport) ```json { "verdict": "block", "score": 92.5, "findings": [ { "id": "reentrancy-no-eth", "title": "Reentrancy on withdraw()", "severity": "critical", "confidence": 0.98, "description": "External call before state update", "detector": "slither" } ], "contract_name": "Vault", "solc_version": "0.8.20", "scanned_at": "2026-11-10T00:00:00Z", "source_sha256": "0x...", "attestation": null } ``` ## Response (SimReport) ```json { "verdict": "block", "score": 85.0, "findings": [ { "id": "sim:revert", "title": "Simulated call reverts", "severity": "high", "confidence": 1.0, "description": "ERC20: transfer amount exceeds balance", "detector": "heuristic:simulation" } ], "to": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "from_address": "0x...", "value_wei": "0", "reverted": true, "revert_reason": "ERC20: transfer amount exceeds balance", "gas_used": "24312", "balance_delta_wei": "0", "internal_calls": [ "0x833589…cf7e → transfer(address,uint256) 0xa9059cbb", "0x833589…cf7e → revert ERC20: transfer amount exceeds balance" ], "simulated_at": "2026-11-10T00:00:00Z", "simulator": "rpc-ethcall:v1", "attestation": null } ``` With `POST /v1/sim/deep` the same shape is returned with `simulator: "anvil-fork:v1"`, measured `gas_used`, a non-zero `balance_delta_wei` when the call moves value, and the full `internal_calls` trace. ## curl examples ```bash # Free token-risk demo — FULL report, 5/day, no payment curl 'https://preflight--preflight-api-api.us-east.modal.run/v1/token-risk/demo?address=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' # Service info + prices curl https://preflight--preflight-api-api.us-east.modal.run/ # Revenue/usage metrics (free) curl https://preflight--preflight-api-api.us-east.modal.run/metrics # Dev-mode scan (no payment; server must run DEV_MODE=1) curl -X POST https://preflight--preflight-api-api.us-east.modal.run/v1/scan \ -H 'Content-Type: application/json' \ -d '{"source":"contract Bad {}","contract_name":"Bad"}' # Paid loop, step 1: request -> 402 with PAYMENT-REQUIRED curl -i -X POST https://preflight--preflight-api-api.us-east.modal.run/v1/scan \ -H 'Content-Type: application/json' \ -d '{"source":"contract Bad {}"}' # Paid loop, step 2: sign the requirements with x402.client, retry with # PAYMENT-SIGNATURE: # -> 200 + ScanReport + PAYMENT-RESPONSE (settlement tx) curl -i -X POST https://preflight--preflight-api-api.us-east.modal.run/v1/scan \ -H 'Content-Type: application/json' \ -H 'PAYMENT-SIGNATURE: ' \ -d '{"source":"contract Bad {}"}' # The demo client performs the whole loop for you: # request -> 402 -> build payment via x402.client -> retry -> verdict uv run python client/pay_client.py --route scan --file contract.sol uv run python client/pay_client.py --route sim # zero-arg revert demo uv run python client/pay_client.py --route sim-deep # $0.25 anvil fork # Deep simulation (paid): same 402 -> PAYMENT-SIGNATURE retry loop curl -X POST https://preflight--preflight-api-api.us-east.modal.run/v1/sim/deep \ -H 'Content-Type: application/json' \ -H 'PAYMENT-SIGNATURE: ' \ -d '{"to":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","data":"0xa9059cbb...","value_wei":"0"}' # Verify a past verdict (free; URL-encode the attestation JSON) curl 'https://preflight--preflight-api-api.us-east.modal.run/v1/verify?digest=0x...&attestation=%7B...%7D' ``` ## MCP An MCP server exposes paid `preflight_check {source, contract_name?}` ($0.01), `preflight_sim {to, data?, value_wei?, mode?}` ($0.05 quick / $0.25 deep), `preflight_token_risk {address}` ($0.02), and `preflight_bundle {address, source?}` ($0.03), plus free `preflight_verify {digest, attestation?}` and `preflight_pricing`. Set `mode: "deep"` to use `/v1/sim/deep`. Run it with `uv run python -m preflight.mcp.server` (stdio) or `--http` for streamable HTTP. ## Dev mode Set `DEV_MODE=1` on the API server to bypass payment locally.