Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RobinCompute contracts

The settlement layer of RobinCompute, the open AI inference network on Robinhood Chain (Ethereum L2). Everything the network promises in prose, these contracts enforce in code: workers stake and register, clients prepay in USDG, jobs post and get claimed, and finished work is paid out of escrow the moment a proof lands. Every step is a public transaction — the whole point of this layer is that nobody has to take our word for anything. Written with Foundry.

Browsing the source? src/ is the place to start. Deploying or poking at the testnet instances? Jump to Deployment and Live addresses.

The job lifecycle

Nine contracts make up the protocol, plus a USDG stand-in for testing. The deploy script broadcasts them together and wires their cross-contract permissions in one transaction, so no contract ever trusts an address configured after the fact.

A job moves through the system like this:

  1. A GPU operator registers in WorkerRegistry, locks $RCOMPUTE through Staking, and links that stake to their worker node. The stake is the worker's skin in the game — misbehavior gets it slashed.
  2. On the client side, USDG deposited into JobEscrow becomes prepaid credits. When a job locks, the credit price for its tier moves into escrow.
  3. The locked job appears on JobRouter, and a worker that meets its requirements claims it.
  4. The worker hands a proof to Settlement. Payout is immediate — the worker's cut releases, the treasury's cut stays escrowed — and a short dispute window opens.
  5. If the client disputes and the arbitrator finds against the worker, Settlement instructs Staking to slash the linked stake and WorkerRegistry to cut the worker's reputation.

Around that core loop sit Governance and RewardDistributor: the former decides protocol parameters through stake-weighted votes, the latter pays USDG to stakers one epoch at a time. ModelRegistry records which models the network serves and the hardware tier each demands.

Contract reference

Contract Role
RobinComputeToken $RCOMPUTE, the staking and governance token. Fixed supply of 1B, minted once at deployment. No inflation.
WorkerRegistry Registry of GPU workers, their supported tiers, and a reputation score maintained as an EMA over job outcomes.
Staking $RCOMPUTE locks of 30, 90, or 180 days weighted at 1.0x / 1.25x / 1.5x. Also handles linking stake to workers and slashing it.
JobEscrow Custodies USDG as prepaid credits and holds them per job. A credit is worth $0.01. The treasury's share of every job accumulates here.
JobRouter The on-chain job board: clients post once escrow is locked, and qualified workers claim atomically.
Settlement Checks proofs, pays out from escrow, manages the dispute window, and triggers slashing when a verdict goes against the worker.
Governance Stake-weighted proposals gated by a quorum, an approval threshold, and a timelock before anything executes.
RewardDistributor Epoch-based USDG rewards. The owner opens an epoch against a stake snapshot and stakers claim their share.
ModelRegistry Owner-maintained catalog of served models and the minimum hardware tier each needs.
MockUSDG Freely mintable six-decimal USDG for tests only. It substitutes for real USDG on testnet.

Shared interfaces are collected under src/interfaces/.

Repository layout

contracts/
  src/                Contracts and their interfaces
  script/             Foundry deploy, seed, and demo-traffic scripts
  scripts/            Bash wrappers and keeper crons
  tests/              Forge test suite (167 tests) and MockUSDG
  foundry.toml        Solc 0.8.30, optimizer on, RPC endpoints

Building and testing

Foundry is the only prerequisite:

curl -L https://foundry.paradigm.xyz | bash && foundryup

Then build and run the tests:

forge build
forge test

The suite can also run against live testnet state instead of a clean EVM:

forge test --fork-url https://rpc.testnet.chain.robinhood.com

Deployment

script/Deploy.s.sol puts up every contract and configures each cross-contract authority within a single broadcast. On testnet it also spins up a fresh MockUSDG and a fresh $RCOMPUTE token, unless you point it at existing deployments.

The recommended route is the wrapper script, which verifies the chain ID and your balance before broadcasting anything:

export DEPLOYER_KEY=0x...        # a funded testnet key
./scripts/deploy.sh              # add --dry-run to simulate only

Invoking Forge directly works too:

forge script script/Deploy.s.sol \
  --rpc-url https://rpc.testnet.chain.robinhood.com \
  --private-key "$DEPLOYER_KEY" \
  --broadcast

Because Robinhood Chain is an Arbitrum-style L2, gas estimates sometimes land short. If a script dies with an out-of-gas revert, retry with a higher gas multiplier such as -g 300.

Deploy honors two optional environment variables:

  • USDG_ADDRESS points at an existing USDG so MockUSDG is skipped. Required on mainnet.
  • ROBINCOMPUTE_ADDRESS points at an existing $RCOMPUTE token so a new one is not minted.

Once the broadcast finishes, copy the printed addresses into the table below.

Live addresses

Robinhood Chain testnet, chain ID 46630. RPC https://rpc.testnet.chain.robinhood.com, explorer https://explorer.testnet.chain.robinhood.com. These are the receipts — every claim in this README resolves to one of them.

Contract Address
RobinComputeToken 0x9E5CF6cbe3f9c72F19e7242d5bdb9c4a2F475763
WorkerRegistry 0xDF23d353a23210491905b79036BA748ac856a93d
Staking 0x3a81ad1Aef5eFf47E1DD02be1565882E8e2Ed75D
JobEscrow 0x08C6A185D72D9809cA3898135d4d2057F47072C7
Settlement 0xFAB536639239936631C1f12FCe487bb043e66Ff8
Governance 0x59D78467C0cE63d2cB95c051D970Aa5e1A3cADCA
JobRouter 0xe636daDAaE280035c7bf93D02345165164B4BC5b
ModelRegistry 0xED37e8b76c3D142b94Ba79075a0dC0A5f981Ea5C
RewardDistributor 0xCc5b80E1fC7B0762F162F789B17a66956777f8b2
MockUSDG (test only) 0x5864625984ea8246daE8789a5C0E0cd6E70F70Eb

Helper scripts

Foundry scripts under script/:

  • Deploy.s.sol broadcasts and wires the full suite.
  • Seed.s.sol populates a fresh deployment with one worker, several models, and a single settled job so nothing starts empty.
  • BatchTx.s.sol, BatchTx2.s.sol, BatchTx2b.s.sol generate demo traffic touching every contract — useful for filling the explorer or walking the flows end to end.

Bash utilities under scripts/:

  • deploy.sh wraps the deploy script with safety checks.
  • airdrop_testnet.sh shows your balance and points you at the faucet.
  • distribute_rewards.sh opens a reward epoch funded from the operator's USDG, intended for scheduled runs.
  • refund_crank.sh is a permissionless keeper that refunds any still-locked job older than its 120s timeout.

Mainnet checklist

Swap out two placeholder authorities before any mainnet deployment:

  • ARBITRATOR in src/Settlement.sol must point at the production dispute arbitrator, ideally a Safe multisig.
  • CRANK_OPERATOR in src/Staking.sol must point at the production reward crank operator.

And set USDG_ADDRESS to the genuine USDG at deploy time, so the mintable MockUSDG never reaches mainnet.

About

Smart contracts

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages