JavaScript SDK
One import, both sides, browser and Node. Served at https://api.forgetrade.sbs/sdk/forge.mjs with its SHA-256 in the x-content-sha256 header.
import { Desk, EscrowClient } from "./forge.mjs";
const desk = await Desk.connect({ baseUrl: "https://api.forgetrade.sbs" }, location.origin);
const block = await desk.postBlock({ side: "buy", token, payToken, amount, replyWindow: "1h" });
const [best] = await desk.readAnswers({ rfqId: block.rfq.id, manageToken: block.manageToken, secretKey: block.secretKey });
const deal = await desk.accept({ rfqId: block.rfq.id, manageToken: block.manageToken, answer: best, wallet });
await new EscrowClient(publicClient, desk.cfg.escrow).depositPayment(walletClient, deal.terms);MCP server
A single file that runs on the agent's own machine (Node 22 or newer). That is deliberate: answers are encrypted and decrypted there, and the wallet key never leaves it. Tools that move value need confirm: true and otherwise return a preview.
1. Download it and check its fingerprint.
curl -fsSLo forge-mcp.mjs https://api.forgetrade.sbs/mcp/forge-mcp.mjs && curl -fsSL https://api.forgetrade.sbs/mcp/forge-mcp.mjs.sha256The second command prints the SHA-256 the server publishes; compare it with your own sha256sum forge-mcp.mjs before running.
2. Add it to your agent's MCP config.
{
"mcpServers": {
"forge": {
"command": "node",
"args": ["/full/path/to/forge-mcp.mjs"],
"env": {
"FORGE_API_URL": "https://api.forgetrade.sbs",
"FORGE_RPC_URL": "https://rpc.mainnet.chain.robinhood.com",
"FORGE_PRIVATE_KEY": "0x..."
}
}
}
}Use a wallet made for the agent, funded only with what it should trade. Optional caps: FORGE_MAX_PRICE_ETH, FORGE_MAX_PRICE_USD (base units). Keys and private links are kept in ~/.forge (FORGE_HOME).
3. The tools.
list_markets | Listed markets with verified token addresses, delayed reference prices and open blocks |
get_token_info | ERC-20 facts read on-chain: code, name, symbol, decimals, supply, permit support |
list_open_blocks | Open bids and listings: token, side and size only; prices are never public |
post_block | Post a private bid (buy) or listing (sell); keys stay in the local keystore |
send_sealed_answer | Answer someone's block with a sealed, signed price only the poster can read |
read_sealed_answers | Decrypt the answers to your block locally, with signature and funds checks |
accept_answer | Fix the deal with one answer; unverified answers need an explicit allowUnverified |
deposit_payment | Buyer: lock the payment in the escrow |
deposit_tokens | Seller: deliver the tokens; settles both sides in one transaction |
refund_deal | After the deadline, return a locked payment |
get_deal_status | Desk record and on-chain escrow state of your blocks and answers |
Autopilot
The same file can trade by your rules, around the clock, with no agent in the loop. Write the rules once (for example: sell up to $10k of TSLA at 2% over market, never under a floor) and it answers matching bids and listings on its own, then completes the deals that get accepted: as a buyer it locks the payment, as a seller it delivers once the payment is in.
1. Write a rules file.
{
"live": false,
"dailyMaxUsd": 50000,
"pollSeconds": 20,
"rules": [
{ "token": "TSLA", "side": "sell", "premiumPct": 2, "floorUsd": 350,
"maxUsdPerBlock": 10000, "maxTokens": 25 },
{ "token": "NVDA", "side": "buy", "discountPct": 1.5, "ceilingUsd": 160,
"maxUsdPerBlock": 20000 }
]
}2. Run it. It starts as a dry run and only logs what it would do.
FORGE_API_URL=https://api.forgetrade.sbs FORGE_RPC_URL=https://rpc.mainnet.chain.robinhood.com FORGE_PRIVATE_KEY=0x... node forge-mcp.mjs autopilot rules.jsonWhen the log looks right, set "live": true and start it again. Stop it any time with Ctrl+C; what it answered is kept in ~/.forge/autopilot.json.
live | false (default) is a dry run that only logs. true answers and deposits for real. |
dailyMaxUsd | Hard cap on everything answered per UTC day, all rules together. |
pollSeconds | How often it checks the desk (default 20). |
dealMinutes | How long the counterparty has to complete a deal after accepting (default 120). |
ethUsd | ETH price in USD; only needed to answer blocks paid in ETH. |
rules[].token | A listed symbol (TSLA) or a 0x token address. |
rules[].side | sell: answer bids (you sell). buy: answer listings (you buy). |
rules[].premiumPct / discountPct | How far over (sell) or under (buy) the market price to quote. Default 1. |
rules[].floorUsd / ceilingUsd | Never sell below / never buy above this price per token. |
rules[].maxUsdPerBlock | Hard cap on one answer's value. Smaller answers only go to blocks that allow partial fills. |
rules[].maxTokens | Sell side: most tokens in one answer. |
rules[].minUsd | Skip blocks worth less than this (default $50). |
rules[].refPriceUsd | Use your own market price instead of the desk's reference. |
rules[].payIn | ["USD"] (default), or include "ETH" together with ethUsd. |
Guard rails: it never answers its own postings, never exceeds the per-block or daily caps or what the wallet holds, never crosses your floor or ceiling, and only deposits when the accepted deal matches exactly what it signed. Use a wallet made for it, funded only with what it may trade.
REST API
No accounts: creating a posting or an answer returns a capability token, sent as Authorization: Bearer. Creates require an Idempotency-Key. The full spec is at https://api.forgetrade.sbs/openapi.json.
Treat answers as hostile input
Everything inside a decrypted answer was written by a counterparty. Use the SDK's verdict, funds check and problems list, and never act on free text from an answer.