Quickstart
Needs Node.js 20 or newer.
# 1. make a signer key for your agent (kept in ~/.sandclock, never leaves your machine) npx sandclock init signer 0x93dec5B2A0409879875746f41cb8fa950f9f9Cd1 # 2. pick a node (sandclock nodes), open a channel to it at /fund with that signer, then: npx sandclock use --node https://<node> --channel 12 # pins the node's chain and contract # 3. run something npx sandclock run -- echo hello ▸ ses_OrsY… · shell · up to 125s / 0.050000 USDG hello ▸ 1s · 0.000400 USDG · receipt ~/.sandclock/receipts/ses_OrsY….json
Install it globally with npm install -g sandclock to drop the npx.
Channels
A channel is USDG locked in the SandclockChannels contract on Robinhood Chain. It names three addresses:
| Role | Who | Can |
|---|---|---|
| payer | your wallet | open, top up, start a close, withdraw what is left |
| signer | your agent's key | sign vouchers, nothing else (it never holds funds) |
| provider | the node | redeem vouchers, close at once with a refund |
To get your money back: start a close, wait one hour so the node can redeem its last voucher, then withdraw. Topping up cancels a pending close. The node can also settle and close immediately, which refunds you in the same transaction.
Vouchers
A voucher is an EIP-712 signature by the channel signer over Voucher(uint256 channelId, uint128 total), where total is the running amount owed on that channel across all sessions. Each one replaces the last; the node redeems only the newest it needs.
- The client reads the channel from the contract with its own RPC, pins the chain and contract it signs for, and keeps a local record of the highest total it ever signed, so a node cannot claim more than that.
- The client signs a few seconds ahead of the meter (5 by default, plus 8 MB of traffic when network is on) and never above the budget you set.
- When a session stops, the client signs the exact total, so prepaid seconds are never redeemed.
- If vouchers stop arriving, the node stops the sandbox. The contract lets it take any amount up to a voucher's total, so it takes exactly what was used, never the prepaid excess.
- If you start a close while a session runs, the node ends the session and redeems at once, inside the close window.
domain { name: "Sandclock", version: "1", chainId: 4663, verifyingContract: <SandclockChannels> }
types Voucher(uint256 channelId, uint128 total)Sandboxes
| Worker | Image |
|---|---|
shell | Alpine 3.20 |
python | Python 3.12 (Alpine) |
node | Node.js 22 (Alpine) |
browser | Headless Chromium with Playwright (Ubuntu); 1 GB, 1 CPU, priced at 3× the base rate |
| Price | 0.0004 USDG per started second (browser 0.0012) |
| Memory / CPU | 256 MB, 0.5 CPU, 128 processes |
| Disk | read-only root; writable /work (64 MB) and /tmp (16 MB) |
| Network | none, unless the session asks for it (see below) |
| Longest session | 30 minutes; stops after 2 idle minutes |
| Per channel | one running session at a time |
A session that runs out of budget is stopped and its command exits with code 124.
Network access
Sandboxes have no network by default. Open a session with network: true (CLI: --network) and it joins an isolated network whose only way out is the node's egress proxy:
- Only hosts on the node's allowlist (by default PyPI, npm, GitHub and the Alpine mirror), over ports 80 and 443.
- Never private, loopback or link-local addresses, checked after DNS resolution.
- Per-session proxy credentials, so one session cannot spend another's traffic.
- Billed at 0.001 USDG per MB in both directions, up to 512 MB per session, and counted inside your budget.
sandclock run --worker python --network -- pip install --user requests
Files & streaming
Upload inputs into /work before running and download results after, up to 8 MB per file. Every transfer is listed in the receipt with its SHA-256. Paths must be relative to /work; .. is rejected.
sandclock run --upload data.csv,model.py:src/model.py --download out.json -- python src/model.py data.csv
// SDK
await box.upload('data.csv', csv);
const r = await box.exec('python main.py', { onData: (stream, text) => process.stdout.write(text) });
const out = await box.download('out.json');With onData (and always in the CLI) output streams in as it is produced, so long jobs show progress.
CLI
sandclock init make a signer key (stored in ~/.sandclock, mode 600)
sandclock use [--node URL] [--channel ID] [--registry ADDR] [--rpc URL]
sandclock whoami signer address, node and channel
sandclock nodes listed nodes, cheapest healthy first
sandclock balance deposit, spent and left on your channel
sandclock quote <seconds>
sandclock run [--worker shell|python|node|browser] [--budget USDG] [--network]
[--upload local[:remote],...] [--download remote[:local],...] -- <command...>
sandclock receipts receipts kept on this machine
sandclock verify <receipt.json> [--onchain]
sandclock mcp MCP server over stdioEnvironment overrides: SANDCLOCK_NODE, SANDCLOCK_CHANNEL, SANDCLOCK_KEY, SANDCLOCK_HOME.
SDK
import { connect, verifyReceipt } from 'sandclock';
const sc = await connect({ node: 'https://node1.sandclockcloud.com', channel: 12, key: process.env.AGENT_KEY });
const box = await sc.open({ worker: 'python', budget: '0.05', network: true }); // or { seconds: 120 }
const r = await box.exec('python -c "print(6*7)"', { timeoutSec: 30 });
// r = { stdout, stderr, exit, timedOut, truncated, ms }
const receipt = await box.stop(); // signs the exact total and verifies the receipt
verifyReceipt(receipt, sc.info.nodeKey); // true
await sc.proveReceipt(receipt); // { anchored: true, epoch, root } once published on chain
await listNodes({ registry, chainId }); // the marketplace, from the registry contractMCP
Add Sandclock to Claude Code, Cursor or any MCP client. It uses the same ~/.sandclock config as the CLI.
{
"mcpServers": {
"sandclock": { "command": "npx", "args": ["-y", "sandclock", "mcp"] }
}
}sandbox_run | run commands in one fresh sandbox, optionally with files in, network and files out; returns output, cost and the receipt (default budget 0.05 USDG) |
sandbox_quote | price for a number of seconds |
sandbox_balance | deposit, spent and left on the channel |
Receipts
The node signs every finished session with its ed25519 key, over the canonical JSON of the receipt (keys sorted, no whitespace). outputSha256 hashes every command's stdout, stderr and exit code in order.
{
"v": 1, "session": "ses_8Kq2Xv", "channel": "12", "worker": "python", "status": "stopped",
"startedAt": "2026-11-27T09:14:02.118Z", "endedAt": "2026-11-27T09:14:10.904Z",
"seconds": 9, "pricePerSecond": "400", "cost": "3600", "costUSDG": "0.003600",
"channelOwed": "3600", "execs": 1, "outputSha256": "91c7…",
"provider": "0x…", "chainId": 4663, "contract": "0x…",
"node": "<ed25519 public key, hex>", "sig": "<ed25519 signature, hex>"
}status is one of stopped, budget, unpaid, deposit, idle or shutdown.
Receipts on chain
A node periodically publishes the Merkle root of the receipts it signed to the SandclockRegistry contract. A leaf is keccak256(keccak256(canonical JSON)), hashed twice so it can never be confused with an internal node; pairs are hashed in sorted order, and verifyReceipt checks a receipt's JSON directly. Once a root is published the node cannot quietly change its history, and anyone holding a receipt can prove it against the contract with their own RPC.
sandclock verify receipt.json --onchain valid · signed by node 1acd…aa56 anchored on chain · registry 0x… · epoch 12
Marketplace
Anyone can run a node. Listing one in the registry takes a stake (10 USDG minimum), the node's URL, its price and its ed25519 receipt key. Unlisting starts a 7-day unbonding period, after which the stake is withdrawable. Clients read the list from the contract, check each node live, and skip any whose announced key does not match its listing.
Channels are per node: open one to each node you want to use. The Nodes page and sandclock nodes show the current list.
HTTP API
Base URL: https://node1.sandclockcloud.com. JSON in, JSON out. Sessions are opened with a voucher (which proves you hold the signer key) and then used with the bearer token they return.
GET /v1/node | provider, node key, chain, contract, price, workers, limits |
GET /v1/channels/:id | deposit, owed, signed and redeemed totals |
GET /v1/channels/:id/receipts | the channel's receipts, newest first |
POST /v1/sessions | { channel, worker, maxSeconds, maxCost, network, voucher: { total, sig } } → session and token |
POST /v1/sessions/:id/exec | { cmd, timeoutSec?, stdin?, stream? } → stdout, stderr, exit (NDJSON when streaming) |
PUT /v1/sessions/:id/files?path= | raw body → bytes and SHA-256 |
GET /v1/sessions/:id/files?path= | raw bytes, x-sha256 header |
POST /v1/sessions/:id/voucher | { voucher } → committed and owed |
GET /v1/sessions/:id | live seconds and cost |
POST /v1/sessions/:id/stop | stops it and returns the signed receipt; send a final voucher after |
GET /v1/receipts/:id | a receipt by session id |
GET /v1/receipts/:id/proof | Merkle proof against the registry, once anchored |
Contract
| Network | Robinhood Chain (4663) |
| SandclockChannels | 0x66Cfb68af329cd6b40fd363BE04533b8c2F3fbBD |
| SandclockRegistry | 0x9710E5c06Fdc693bC00612396c4CfD1bd7168C22 |
| Token | 0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168 (USDG, 6 decimals) |
| Admin / upgrades / fees | none |
open(provider, signer, amount) → id topUp(id, amount) startClose(id) withdraw(id) // after 1 hour redeem(id, total, take, sig) settleAndClose(id, total, take, sig) // provider; take ≤ total getChannel(id) · available(id) · voucherDigest(id, total) · channelsOfPayer(a) · channelsOfProvider(a) // SandclockRegistry list(url, nodeKey, pricePerSecond, stake) update(url, nodeKey, pricePerSecond) addStake(amount) unlist() withdrawStake() // after 7 days anchor(root, count, total) verify(operator, epoch, leaf, proof) → bool
Not audited by a third party yet. Covered by unit, fuzz and invariant tests (every token is either held for a live channel, paid to a provider, or refunded; a provider never receives more than the highest voucher signed). Keep deposits small.
Run a node
A node is one Node.js process plus Docker. It meters sessions, keeps vouchers, redeems them on chain and signs receipts.
git clone <repo> && cd sandclock/node && npm install cp .env.example .env # CHANNELS_ADDRESS, PROVIDER_PRIVATE_KEY, PRICE_PER_SECOND, ... DRIVER=docker DOCKER_RUNTIME=runsc node src/server.mjs # runsc adds gVisor PUBLIC_URL=https://node.example.com node scripts/register.mjs # list it in the registry
Network access needs one host firewall rule: sandboxes on the internal sandclock-egress network must not reach the host itself. See node/README.md.
Redemptions batch until 0.5 USDG is pending or six hours pass, and happen at once when a payer starts a close.