Castor docs
Castor is buyer protection for AI agents paying per call on Robinhood Chain. Providers lock a USDG bond. When a paid call leaks (times out, errors, breaks its schema, comes back empty or serves a stale price) the agent is refunded from that bond in seconds. Providers are still paid instantly.
How it works
Castor never holds the agent's payment. The provider's bond is the guarantee, so small calls stay fast and cheap.
- 1Provider builds the dam. The provider deposits USDG into a bond account and registers its endpoints with their price, checks and output schema.
- 2Agent pays through a watcher. The agent sends a normal paid request from its wallet. A Castor watcher forwards it, settles the payment straight to the provider and receives the response.
- 3Checks run, leaks get refunded. The watcher runs the endpoint's leak checks. Clean responses go to the agent. A failed check produces a signed leak report, and the contract refunds the agent from the provider's bond.
Quickstart: providers
1. Install the middleware.
npm install @castor/provider
2. Protect an endpoint. Wrap any paid route. Declare a price, the checks you accept and, for schema, the JSON Schema of your response.
import { castor } from "@castor/provider"; import quoteSchema from "./quote.schema.json"; app.use("/quotes/:ticker", castor.protect({ price: "0.02 USDG", checks: ["timeout:2s", "status", "schema", "stale:5s"], schema: quoteSchema, }));
3. Build the dam. Connect any EVM wallet (Robinhood Wallet, MetaMask, Rabby) in the Castor app, open Provider dashboard → Bond and deposit USDG. Your endpoints get the Castor badge as soon as the bond covers the minimum.
Quickstart: agents
npm install @castor/agent
import { withCastor } from "@castor/agent"; const pay = withCastor(agentWallet, { onlyProtected: true, onRefund: (r) => console.log("refunded", r.amount, r.reason), }); const res = await pay.fetch("https://quotes.example.com/TSLA");
With onlyProtected on, the client refuses to pay endpoints without a live Castor bond. Refunds land in the paying wallet; no claim step.
Leak checks
Only checks a machine can prove. Providers choose which ones apply to each endpoint; agents see them in the catalog before paying.
| Check | Config | Fires when |
|---|---|---|
| timeout | timeout:3s | No complete response inside the declared window |
| status | status | Any 4xx or 5xx after the payment settled |
| schema | schema + JSON Schema | The body fails validation against the published schema |
| empty | empty | 200 OK with an empty body, null or an empty object/array |
| stale | stale:5s | The quote is older than the declared max age, or drifts too far from the on-chain reference price on Robinhood Chain |
Bonds & coverage
- Bonds are USDG. Protection never depends on a token price.
- Coverage is capped by the bond. A refund can never exceed what is left in the provider's bond. Agents see live coverage per endpoint in the catalog.
- Minimum bond. Below the minimum [VALUE TBD] the badge is removed until the provider tops up.
- Withdrawals have a cooldown. Providers request a withdrawal and wait [PERIOD TBD], so the dam can't be drained right before a run of leaks.
- Backstop. From Phase 04, the $CSTR backstop pool covers refunds a dry bond can't.
Watchers
A watcher is a payment facilitator that sits in the payment path. Because it sees both the payment and the response first-hand, a refund is triggered by what actually happened, not by what the agent claims.
- Phase 01: Castor runs the watcher and signs leak reports.
- Phase 02: anyone can run a watcher by staking $CSTR. A leak report needs a quorum of watcher signatures; signing a false report is slashed.
Beaver Score
Every protected endpoint gets a public score in the catalog. Agents use it to choose who to pay; providers use it to climb the rankings.
Provider SDK
castor.protect(options)
| Option | Type | Description |
|---|---|---|
| price | string | Price per call in USDG, e.g. "0.02 USDG" |
| checks | string[] | Leak checks for this endpoint |
| schema | JSONSchema | Output schema; required with the schema check |
| bond | address? | Bond account to cover this endpoint; defaults to the provider's main bond |
Agent SDK
withCastor(agentWallet, options)
| Option | Type | Description |
|---|---|---|
| onlyProtected | boolean | Refuse to pay endpoints without a live bond |
| minScore | number? | Skip endpoints below this Beaver Score |
| maxPrice | string? | Never pay more than this per call |
| onRefund | (refund) => void | Called with amount, reason and transaction when a refund lands |
On-chain contracts
Solidity contracts on Robinhood Chain (an Ethereum L2 built on Arbitrum). Contract address: [coming soon]
ProviderBondUSDG vault, coverage, withdrawal requestEndpointURL hash, price, checks, schema hashLeakReportpayment tx, failed check, watcher signatures
initBond·depositrequestWithdraw·withdrawregisterEndpointsubmitLeakReport→ refund
$CSTR
Every beaver has a job. $CSTR contract address on Robinhood Chain: 0xc1758ad36a20b1108a34da9a77481d43ac465b4b
| Role | What you do | What you get |
|---|---|---|
| Watcher | Stake, run a node, co-sign leak reports | Fees; slashed for false reports |
| Arbiter | Stake, judge disputes on big payments | Fees; slashed against the honest majority |
| Second dam | Stake in the backstop pool | Cut of protection fees; covers dry bonds |
| Voucher | Delegate to providers you trust | Share of their fees; bitten if they leak |
| Provider | Hold or stake | Lower fees, catalog boost, faster badge |
| Agent | Stake | Higher coverage per call, premium checks |
| Holder | Vote | Govern checks, fees, bonds; buybacks from fees |
FAQ
No. Refunds follow what watchers observed, never what the agent claims.
No. Payments settle to the provider instantly; the bond is the guarantee.
From Phase 03, payments above a threshold use escrow with a challenge window and staked arbiters.