Castor Docs
← Website
Get started

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.

$CSTR is live on Robinhood Chain. Package names, contract addresses and final parameters are published on @castoronrbh and in this reference as each part goes live.

How it works

Castor never holds the agent's payment. The provider's bond is the guarantee, so small calls stay fast and cheap.

  1. 1
    Provider builds the dam. The provider deposits USDG into a bond account and registers its endpoints with their price, checks and output schema.
  2. 2
    Agent 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.
  3. 3
    Checks 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.

CheckConfigFires when
timeouttimeout:3sNo complete response inside the declared window
statusstatusAny 4xx or 5xx after the payment settled
schemaschema + JSON SchemaThe body fails validation against the published schema
emptyempty200 OK with an empty body, null or an empty object/array
stalestale:5sThe 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.

Leak rate
Share of paid calls that leaked
Bond size
How much water the dam holds
Vouchers
$CSTR delegated by stakers
Track record
Age and volume of protected calls

Provider SDK

castor.protect(options)

OptionTypeDescription
pricestringPrice per call in USDG, e.g. "0.02 USDG"
checksstring[]Leak checks for this endpoint
schemaJSONSchemaOutput schema; required with the schema check
bondaddress?Bond account to cover this endpoint; defaults to the provider's main bond

Agent SDK

withCastor(agentWallet, options)

OptionTypeDescription
onlyProtectedbooleanRefuse to pay endpoints without a live bond
minScorenumber?Skip endpoints below this Beaver Score
maxPricestring?Never pay more than this per call
onRefund(refund) => voidCalled 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]

Storage
  • ProviderBond USDG vault, coverage, withdrawal request
  • Endpoint URL hash, price, checks, schema hash
  • LeakReport payment tx, failed check, watcher signatures
Functions
  • initBond · deposit
  • requestWithdraw · withdraw
  • registerEndpoint
  • submitLeakReport → refund

$CSTR

Every beaver has a job. $CSTR contract address on Robinhood Chain: 0xc1758ad36a20b1108a34da9a77481d43ac465b4b

RoleWhat you doWhat you get
WatcherStake, run a node, co-sign leak reportsFees; slashed for false reports
ArbiterStake, judge disputes on big paymentsFees; slashed against the honest majority
Second damStake in the backstop poolCut of protection fees; covers dry bonds
VoucherDelegate to providers you trustShare of their fees; bitten if they leak
ProviderHold or stakeLower fees, catalog boost, faster badge
AgentStakeHigher coverage per call, premium checks
HolderVoteGovern checks, fees, bonds; buybacks from fees

FAQ

Can an agent fake a refund?
No. Refunds follow what watchers observed, never what the agent claims.
Do providers wait for their money?
No. Payments settle to the provider instantly; the bond is the guarantee.
What about large payments?
From Phase 03, payments above a threshold use escrow with a challenge window and staked arbiters.
Where do I report a bug?
Open an issue on GitHub or reach us on X.
← Back to castor website GitHubX @castoronrbh