§ 09 — API reference

JSON over REST, events over /ws, a guide at /llms.txt.

The Fastify API is the single backend for the web app and for agents. The contract is typed in packages/shared/src/api.ts, ws.ts and custody.ts.

Public REST + WS · tests passingCustody routes

§ 9.1Conventions

  • Base URL: your API host (local http://localhost:4000). REST under /api.
  • Amounts are UI units (JS numbers already divided by decimals); on-chain code uses bigint atoms. Prices are quote per whole token; tokens have 6 decimals.
  • Timestamps are unix seconds. Use serverTimeTs to correct your clock before computing countdowns.
  • Errors: { "error": string, "details"?: unknown } with a 4xx/5xx status. Unknown routes return 404 route not found.
  • CORS from CORS_ORIGIN; body limit 256 KB (32 KB on the privacy proxy).

§ 9.2Public endpoints

MethodPathReturns
GET/api/healthHealthResponse — network, isDemo, db, cache, redacted rpc, programId, uptime, version. Also /health.
GET/api/statsProtocolStats — volume, fees, credit deployed/repaid, solvency, burns, payouts, counts.
GET/api/launches?status=&quote=&limit=LaunchListResponse. status: a LaunchStatus or auctions | vaults | graduated; quote: a symbol, stocks or all; limit 1–200 (50).
GET/api/launches/:idOrMintLaunchSummary, 404 if unknown.
GET/api/launches/:idOrMint/trades?limit={ trades: Trade[] }
GET/api/launches/:idOrMint/chart?interval=1m|5m|1h{ points: PricePoint[] }
POST/api/launchesDemo: creates an in-memory launch (200). Non-demo: 501 "sign client-side" with create_launch args in atoms. 400 on invalid input (e.g. > 200 bps).
GET/api/auctions/:idOrMint{ launch, serverTimeTs } — public aggregates only.
POST/api/auctions/:idOrMint/demo-bidDemo only (403 otherwise). { commitment, deposit, wallet? }; 409 if the commit window is closed.
GET/api/vaults/:mint{ launch, recentBuybacks (30), serverTimeTs }
GET/api/rewards/:mint/:walletHolderReward — staked, claimable, claimed, eligible (false for snipers).
GET/api/revenue{ stats, recentBuybacks, ledger, daily (14 days) }
GET/api/relayer/pubkey{ pubkey (base64 x25519), relayerAddress }
POST/api/relayer/revealsSealedRevealEnvelope → { accepted, id }. 400 malformed / wrong key / bad payload, 401 bad signature, 404, 409 window closed.
GET/api/privacy/statusPrivacyStatusResponse — available, simulated, ringId, escrowFunding, reason.
POST/api/privacy/rpc{ method, params } → raw Helius JSON-RPC (8 whitelisted methods, 120/min/IP).
GET/llms.txttext/plain agent guide, generated from live config and shared constants.

Example: health

GET /api/health (demo)
{
  "ok": true,
  "network": "devnet",
  "isDemo": true,
  "db": "memory",
  "cache": "memory",
  "rpc": "https://devnet.helius-rpc.com/?api-key=***",
  "programId": "71geDPZMKfjJnKE4an15QyyH5TyFG1w7XEL5tUkp5Tpy",
  "uptimeSec": 221,
  "version": "0.1.0"
}

Example: a launch in reveal

GET /api/launches?status=auctions&limit=1 (demo, trimmed)
{
  "launches": [{
    "id": "Ccrm8zMN6fJFrHGnm9dHHKAquAPTJdJsX2xj7LgGKZXw",
    "mint": "EH5Z1R2MGW2iXAMX9yudQm39xxFZQ8ittkUgNwU4HLty",
    "name": "Solstice", "ticker": "SOLST",
    "creatorAllocationBps": 50, "totalSupply": 1000000000,
    "quoteAsset": "SOL", "creditTier": "plus", "status": "reveal",
    "auction": {
      "commitStartTs": 1795691227, "commitEndTs": 1795692427, "revealEndTs": 1795692547,
      "bidCount": 120, "revealedCount": 43, "escrowedWallets": 100, "totalEscrowed": 354.135,
      "floorPrice": 3.1846375e-7, "tickSize": 1.59231875e-8, "tokensForSale": 400000000,
      "targetRaise": 231.61, "clearingCap": 347.415, "clearingPrice": null, "totalRaised": null
    },
    "market": null, "vault": null, "credit": null,
    "network": "devnet", "isDemo": true
  }],
  "total": 5
}

After graduation market, vault (creditLine, balance, dripAmount, nextDripTs, dripsExecuted, tokensBurned…) and credit (repaid, repaidPct, phase, feesCollected, holderPayouts…) are populated. No per-bid field is ever exposed before clearing.

Example: create a launch (demo)

curl
curl -s -X POST http://localhost:4000/api/launches \
  -H 'content-type: application/json' \
  -d '{"name":"Quiet Money","ticker":"QUIET","quoteAsset":"USDC","creditTier":"standard",
       "creatorAllocationBps":150,"auctionSupplyBps":4000,"commitDurationSec":1200,
       "revealDurationSec":120,"floorPrice":0.0001,"tickSize":0.000005,
       "targetRaise":50000,"clearingCap":75000}'

§ 9.3Custody and trading endpoints

Defined in CUSTODY_ROUTES. Everything except /api/custody/info and the two auth calls requires Authorization: Bearer <token> from SIWS sign-in. The server implementation is in development; shapes are fixed by the shared contract.

MethodPathBody → responseAuth
GET/api/custody/infoCustodyInfoResponse — companyWallet, network, mode, payoutsEnabled, proofOfReserves[]—
POST/api/auth/nonce{ wallet } → { nonce, message, expiresTs }—
POST/api/auth/verify{ wallet, nonce, signature (base58) } → { token, wallet, expiresTs }—
GET/api/accountAccountResponse — balances (available / locked), depositRef, companyWallet, sniperFlagsbearer
GET/api/account/deposit/:assetDepositInstructions — companyWallet, memo, mint, minConfirmations, notebearer
GET · POST/api/account/depositsGET → { deposits }; POST { signature } nudges detection → DepositRecordbearer
GET · POST/api/account/withdrawalsGET → { withdrawals }; POST { asset, amount, destination } → WithdrawalRecordbearer
POST/api/trade/commit{ launchId, commitment, deposit, sealedReveal? } → { bidId, bidCount }bearer
POST/api/trade/reveal{ launchId, maxPrice, bidAmount, salt } → { revealed: true }bearer
POST/api/trade/swap{ launchId, side, amountIn, minAmountOut } → { tradeId, amountIn, amountOut, fee, price, isSniper }bearer
POST/api/trade/claim/:launchIdafter clearing → { tokens, refund }bearer
POST/api/trade/stake{ launchId, amount } — negative amount unstakesbearer
POST/api/trade/rewards/:launchId→ { amount }bearer
GET · POST/api/admin/withdrawalsoperator queue: list, approve, reject — requires the ADMIN_TOKEN headerbearer
Sign in and read your account
import bs58 from "bs58";

const api = "http://localhost:4000";
const { nonce, message } = await fetch(`${api}/api/auth/nonce`, {
  method: "POST", headers: { "content-type": "application/json" },
  body: JSON.stringify({ wallet: wallet.publicKey.toBase58() }),
}).then((r) => r.json());

const signature = bs58.encode(await wallet.signMessage(new TextEncoder().encode(message)));
const { token } = await fetch(`${api}/api/auth/verify`, {
  method: "POST", headers: { "content-type": "application/json" },
  body: JSON.stringify({ wallet: wallet.publicKey.toBase58(), nonce, signature }),
}).then((r) => r.json());

const account = await fetch(`${api}/api/account`, { headers: { authorization: `Bearer ${token}` } }).then((r) => r.json());
// account.depositRef → send funds to account.companyWallet with memo "sealed:" + depositRef

§ 9.4WebSocket

Connect to /ws. Subscribing sends an immediate snapshot (stats.updated for global, launch.updated for a launch). The server pings to detect dead sockets; clients may send {"op":"ping"} and receive {"type":"pong","ts":…}.

client → server
{ "op": "subscribe",   "channels": ["global", "launch:<launchId>"] }
{ "op": "unsubscribe", "channels": ["launch:<launchId>"] }
{ "op": "ping" }
server → client envelope
{ "type": "vault.drip", "channel": "global", "ts": 1795692450,
  "data": { "launchId": "…", "ticker": "LANE", "quoteSpent": 0.52, "tokensBurned": 20123.4,
            "dripIndex": 16, "nextDripTs": 1795692630, "vaultBalance": 11.9, "…": "…" } }
EventData
launch.created · launch.updatedLaunchSummary
auction.bid_committedlaunchId, bidCount, escrowedWallets, totalEscrowed
auction.bid_revealedlaunchId, revealedCount, bidCount
auction.phase_changedlaunchId, from, to
auction.clearedlaunchId, clearingPrice, totalRaised, winners
tradeTrade (launch channel)
vault.dripBuybackEvent + nextDripTs + vaultBalance
credit.ledgerCreditLedgerEntry + repaidPct
credit.flywheel_activatedlaunchId, ts
stats.updatedProtocolStats, every ~3 s on global
'global' carries stats, creations, phase changes, bid counters, clears, flywheel activations and all buybacks. 'launch:<id>' carries everything for one launch.

§ 9.5/llms.txt for AI agents

GET /llms.txt returns a plain-text guide rendered from the running config: mode (demo or live), network, program id, REST and WS URLs, the mechanics with numbers pulled from shared constants, every endpoint with example JSON, the WS protocol, a step-by-step “how an agent participates” recipe (discover → bid → auto-reveal → settle → trade and earn) and the Privacy Ring status. Point an agent at it first.

fetch the agent guide
curl -s http://localhost:4000/llms.txt | head -40