$SECONDHAND CA Buy on Pons Chart

SECONDHAND docs

Wrap a command, pay for the seconds it ran, get a signed receipt, and withdraw whatever you did not use.

Quickstart

Needs Node 18 or newer. The npm package is not published yet, so install from the repo source:

# in a clone of the repo
npm i -g .
# local run, simulated settlement
secondhand run -- echo hello

Locally the command runs on your machine. Seconds are metered and the receipt is signed for real, but no money moves (settlement: simulated). Use it to see how billing behaves before you fund anything.

$ secondhand run --budget 2.00 -- python scraper.py
session   0x7f3a…c21e
metered   412 s   0.1648 USDG
receipt   ~/.secondhand/receipts/0x7f3a….json
settled   0.1648 USDG, refund 1.8352 USDG (simulated)

Your account is an ed25519 key created on first use in ~/.secondhand (override with SECONDHAND_HOME). There is no sign-up and no API key.

Console

The web console does everything the CLI does without installing anything. It generates an ed25519 key in your browser and keeps it in local storage.

  1. Open the console. A key is created for you; its account id is shown at the top.
  2. Connect a wallet, approve USDG and deposit. Credit lands after the confirmations listed on Fund.
  3. Open a sandbox (shell, python or node) with a budget. Type commands in the terminal while the per-second meter runs.
  4. Stop the session to get the receipt. Use the Withdraw panel to pull unused credit back.

Move keys between the browser and the CLI with secondhand key export and secondhand key import <file>. Clearing browser storage deletes the browser key, so export it first if it holds credit.

Back up your key. The account is the key. Lose it and you lose access to the balance.

Run in the cloud

Add --cloud to send the command to a node. Each request is signed with your key.

# your account id and balance
secondhand account --cloud https://api.secondhandhq.xyz

secondhand run --cloud --worker python --budget 0.05 -- python -c "print(6*7)"

# or set the node once
export SECONDHAND_CLOUD=https://api.secondhandhq.xyz
  • Opening a session holds the budget from your balance. Stopping pays for the seconds used and returns the rest.
  • When the budget runs out the sandbox is destroyed and the receipt says budget_exhausted.
  • Workers: shell, python, node.
  • Each sandbox is a Docker container with --network none, a read-only root, all capabilities dropped and a non-root user. A node can run it under gVisor (runsc) for a user-space kernel.
  • To chain commands, wrap them in one shell: secondhand run --cloud --worker shell -- sh -c 'cmd1; cmd2'.

Fund

Balances are paid in USDG on Robinhood Chain (chain id 4663, 6 decimals) through the compute vault. The node credits your account after a few confirmations.

In the browser

Run secondhand account to get your account id, then open /fund, connect a wallet and deposit. The CLI prints a link with the account filled in.

From a wallet or explorer

Approve the vault for the amount on the USDG token, then call deposit(bytes20 account, uint256 amount) on the vault. 1 USDG is 1000000. The account is your 20-byte account id.

ItemValue
ChainRobinhood Chain (4663)
Vaultshown on /fund once the node has deposits enabled
TokenUSDG  

The values above are read live from GET /v1/node.

Withdraw

Unused credit is yours. The node signs an EIP-712 voucher, you submit it to the vault, and USDG goes to the address you chose.

secondhand withdraw 4.76 --to 0xYourAddress --cloud https://api.secondhandhq.xyz

This prints the voucher and ready calldata. Submit it from any wallet, or press Withdraw in the console.

  1. POST /v1/withdrawals debits your node balance and returns a voucher valid for one hour.
  2. Anyone can call vault.withdraw(account, to, amount, nonce, expiry, v, r, s). Money always goes to to.
  3. If the voucher is not used before expiry, the node sees the deadline pass on chain and re-credits the amount.
  4. One pending voucher per account at a time. Each nonce works once.

EIP-712 domain: {name: "ComputeVault", version: "1", chainId: 4663, verifyingContract: vault}. Type:

Withdrawal(bytes20 account, address to, uint256 amount, uint256 nonce, uint256 expiry)
Trust note. The operator can sweep earned revenue from the vault, so the vault is not trustless custody of everything in it. Vouchers are only signed after the ledger debit. Do not park more than you plan to spend soon, and keep the public node limits in mind.

Limits

On the public node:

0.0004 USDGper second
5 USDGmax budget per session
1 sessionopen per account
2 minidle, then closed
120 req/minper IP
1 MiBoutput per command

Self-hosted nodes set their own values. Exceeding a limit returns 429, or 409 if a session or withdrawal is already pending.

Commands

CommandWhat it does
secondhand run [--budget 2.00] -- <cmd>Run locally, simulated settlement.
secondhand run --cloud [url] [--budget 0.24] [--worker shell|python|node] -- <cmd>Run in a cloud sandbox and settle against your balance.
secondhand account [--cloud [url]]Your account id, plus balance and recent sessions with a node.
secondhand quote <seconds>What that many seconds cost.
secondhand receipts [--json]Every receipt on this machine, newest first.
secondhand verify <file|session id>Checks a receipt signature. An edit to any field breaks it.
secondhand whoamiYour key id and public key.
secondhand withdraw <amount> --to 0xADDR --cloud [url]Prints a voucher and calldata. Submit it with any wallet or in the console.
secondhand key export / key import <file>Move the key between the CLI and the browser.

State lives in ~/.secondhand (SECONDHAND_HOME). SECONDHAND_CLOUD sets the default node.

Receipts

Every session ends in a JSON receipt saved under ~/.secondhand/receipts/ and, for cloud sessions, public at /r/<session id>.

{
  "v": 1, "mode": "cloud", "session": "0x7f3a…c21e", "account": "0x9f2c…",
  "worker": "python", "image": "…", "opened": 1764200000000, "closed": 1764200412000,
  "seconds": 412, "rate": "0.0004", "budget": "2.00",
  "paid": "0.164800", "refund": "1.835200",
  "status": "completed", "settlement": "ledger",
  "execs": [{ "cmd": "python scraper.py", "code": 0, "signal": null }],
  "output": "sha256:91c7…",
  "node": { "id": "0xb8f6…", "pub": "MCow…" },
  "sig": "5d0a…"
}
  • mode is local or cloud. settlement is simulated or ledger.
  • status is one of completed, budget_exhausted, idle_timeout, interrupted, node_shutdown, failed.
  • output is the sha256 of everything written to stdout and stderr.
  • sig is an ed25519 signature over the canonical JSON of every other field: keys sorted, no whitespace.

SDK

import secondhand from "secondhand";

const s = await secondhand.open({ cloud: "https://api.secondhandhq.xyz", budget: "0.5", worker: "python" });
const out = await s.exec("python main.py");
const receipt = await s.stop();

secondhand.quote(600);            // cost of 600 seconds
secondhand.verifyReceipt(receipt);
secondhand.receipts();
secondhand.cloud(url).withdraw({ amount: "1.00", to: "0xYourAddress" });

open takes budget or seconds. Leave out cloud to run locally.

MCP

Install from the repo source (npm i -g . in a clone), then add the server to Claude Desktop or Cursor:

{
  "mcpServers": {
    "secondhand": {
      "command": "secondhand-mcp",
      "args": [],
      "env": { "SECONDHAND_CLOUD": "https://api.secondhandhq.xyz" }
    }
  }
}
ToolInput
run{cmd, budget?, worker?, cloud?}
quote{seconds}
account{}
receipts{limit?}

HTTP API

All requests are signed except GET /v1/node and GET /v1/receipts/:id. The CLI, SDK and console sign for you.

HeaderValue
x-acct-keyed25519 public key, SPKI DER, base64
x-acct-tstime in milliseconds
x-acct-noncehex, 16 to 64 characters, single use
x-acct-sigbase64 ed25519 signature
sig = ed25519_sign(METHOD + "\n" + PATH + "\n" + TS + "\n" + NONCE + "\n" + sha256hex(body))

The window is 60 seconds and nonces cannot be reused. The account id is 0x plus the first 40 hex characters of sha256(spki).

EndpointReturns
GET /v1/nodeNode id, rate, limits, deposit details. Public.
GET /v1/accountBalance, held funds, deposits, recent sessions.
POST /v1/sessionsOpens a sandbox. Body {worker, budget | seconds}.
POST /v1/sessions/:id/execRuns {cmd}. Streams NDJSON: {t:"stdout"|"stderr", d:base64} lines, then {t:"exit", code, signal, ms, closed?, truncated?}.
POST /v1/sessions/:id/stop{receipt}
GET /v1/sessions/:idSession state.
GET /v1/receipts/:idA closed session's receipt. Public.
POST /v1/withdrawalsBody {amount, to}. Returns {withdrawal: {account, to, amount, nonce, expiry, v, r, s, vault, chainId, calldata, status}}.
GET /v1/withdrawalsYour vouchers and their status.

Errors

401Bad signature.
402Balance too low.
409Busy, or a withdrawal is pending.
429Limit reached or rate limited.