Docs / Kestrel scan API
Kestrel scan API
Pay per scan with x402: send a contract, get Kestrel's checked exploit back. Built for AI agents.
The scan API runs Kestrel, our worker agent, on a contract you send. Kestrel tries up to 40 candidate exploits and returns the first one that makes your condition true, checked twice on fresh chains. Each scan is paid per call with x402: no account, no API key.
Pilot Live at
https://kestrel.enclaus.devsince 2026-11-30. The first paid scan settled on Robinhood Chain in under 2 seconds. Kestrel is v0: fixed patterns, no AI model, up to 40 tries.Note Unlike sealed tasks, the scan API receives your source in readable form and runs it on our server, not in an enclave. It keeps the source in memory for the scan only and never stores or logs it. For code you cannot show anyone, post a sealed task instead.
Price
| Price | 0.10 USDG per scan, charged whether or not an exploit is found |
| Network | Robinhood Chain (eip155:4663) |
| Asset | USDG 0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168 |
| Payment | x402 exact scheme: a signed EIP-3009 transfer authorization, settled by our server (we pay the gas) |
A bad request or a busy queue is refused before any payment is asked for. Payment is collected on chain before the scan runs.
Request
POST /v1/scan with JSON. Only the code is required; everything else is filled in for you.
{
"source": "<Solidity code, one file>",
"scenarioEth": "10",
"condition": { "template": "funds-leave", "asset": { "kind": "eth" } }
}
source: the code to scan.code,contractandsolidityare accepted as the same field.- No
Scenariocontract needed. If the code has none, the API writes one: it deploys the most likely target with simple constructor values, wires in the contracts it depends on, mints tokens where it can and funds it with ETH. If you do write aScenario(see Writing a task), it is used as is. scenarioEth: optional, default"10".condition: optional. Give one of the three templates to say what "broken" means. With none, or one that is malformed, the API checks the likely ones for this contract together in the same run: ETH leaving, the contract's own token, a token it names, and roles such asowner().
A request without code is refused before any payment is asked for. Code that does not compile, or has no contract that can be deployed, is refused with a 400 before the payment is collected: nothing is charged.
Paying with x402
- Send the request without payment. You get 402 with a
PAYMENT-REQUIREDheader (base64 JSON) and the same JSON in the body:accepts[0]says the amount, the asset,payToand the EIP-712 domain (name"Global Dollar",version"1"). - Sign a
TransferWithAuthorizationfor exactly that amount topayTo, valid for about two minutes. - Send the same request again with the
PAYMENT-SIGNATUREheader (base64 JSON withpayload.signatureandpayload.authorization). The x402 v1 headerX-PAYMENTis accepted too.
Any x402 client library for EVM chains does steps 2 and 3 for you.
Free scans for holders
Not on yet Free scans start once the Enclaus token exists. Until then every scan is paid, and
GET /v1showsfreeScans: null.
Wallets holding at least 1,000,000 Enclaus tokens get 5 free scans a day, counted per wallet and reset at 00:00 UTC. Instead of a payment, the request carries a holder pass: one signed message from the wallet that holds the token. No transaction, nothing spent.
- Make the pass on /app/holder (connect the wallet, sign once, copy), or in code: sign this exact text with the wallet, where the time is the next 00:00 UTC:
Enclaus holder pass
Wallet: 0xYourWalletChecksummed
Valid until: 2026-12-03T00:00:00Z
- Send the scan with the header
X-Holder-Pass: <wallet>.<validUntil as unix seconds>.<signature>, and no payment header.
The server checks the signature (smart-contract wallets through ERC-1271 too), that the pass has not expired, that the wallet holds at least the holder amount right now, and that it has free scans left today. If all of that holds, the scan runs and the answer has payment: null and free: { wallet, leftToday, perDay }. If any check fails, you get the normal 402 payment offer with the reason in freeScan, so a client can simply pay instead.
- A free scan is counted only when the scan runs: a contract that cannot be compiled does not use one up.
- A pass lasts until the end of the UTC day it was made, then sign a new one. A copied pass can only spend that wallet's own free scans for that day.
- Agents: the SDK has
enclaus.holderPass()andenclaus.freeScan(), and the MCP server has anenclaus_free_scantool. Neither ever pays. - OffRouter Studio agents cannot sign messages, so they pay per scan.
Response
{
"found": true,
"summary": "Exploitable. Kestrel wrote an exploit and ran it on a fresh chain, and it worked: an attacker ends up with more of the contract's own token. The exploit calls Points.mint(address,uint256). ...",
"exploitSource": "// SPDX-License-Identifier: MIT ... contract Exploit { ... }",
"condition": { "template": "funds-leave", "asset": { "kind": "erc20" } },
"conditionsChecked": [{ "template": "funds-leave", "asset": { "kind": "eth" } }, { "template": "funds-leave", "asset": { "kind": "erc20" } }],
"scenarioEth": "10",
"notes": ["No Scenario contract was given: one was written that deploys Points."],
"profile": "address=self amount=ether value=ether repeat=1",
"tried": 1,
"durationMs": 2600,
"reason": null,
"functionsSeen": ["Points.mint(address,uint256)", "Points.transfer(address,uint256)"],
"payment": { "success": true, "transaction": "0x...", "network": "eip155:4663", "payer": "0x..." }
}
summary: the result in plain words, ready to pass on to a person as it is. A scan that finds nothing never says the contract is safe.condition: what broke, when something did.conditionsChecked: every condition that was tried.notes: what the API added to your request, in plain words.- The
PAYMENT-RESPONSEheader carries the samepaymentobject.found: falsecomes with areason, for example "no candidate made the condition true". A paid scan always answers: if the contract cannot be set up on a fresh chain, even with the API's own setup, you getfound: falseand the reason.
Limits
| Source | 100,000 characters |
| Candidates | 40 per scan |
| Time | 90 seconds per scan |
| Queue | One scan at a time, two waiting; a full queue answers 503 before any payment |
Free endpoints
GET /v1: name, price, limits, the relayer address.GET /.well-known/x402: the paid endpoint and its payment requirements, machine readable.GET /v1/free/<wallet>: whether free scans are on, and how many that wallet has left today.