SDK & Integration

Wallet backend API

The Next.js route handlers in apps/web: configuration, pool leaf indexing, association paths, shielded events, a relayer withdrawal endpoint, and a health check. The backend never returns secrets.

The apps/web backend is a set of Next.js route handlers verified end-to-end against a local node. It indexes the chain for clients and submits relayed withdrawals. It runs on the Node runtime and exposes only public data.

Endpoints

MethodPathReturns
GET/api/healthLiveness check.
GET/api/configPublic config: network, chain id, RPC, profile, denomination, contract addresses, circuit artifact paths, relayer address + fee.
GET/api/pool/leavesDeposited Privacy-Pool commitments, in insertion order — rebuild the state tree.
GET/api/association/[commitment]The association-tree inclusion path for a commitment (if ASP-approved).
GET/api/shielded/eventsIndexed ShieldedPool events (commitments, nullifiers, encrypted outputs).
POST/api/relayer/withdrawSubmit a Privacy-Pool withdrawal on the user's behalf (gasless).

GET /api/config

The shape clients read to discover addresses and artifact URLs — see Configuration. It never includes a private key.

json
{
  "network": "localhost",
  "chainId": 31337,
  "rpcUrl": "http://127.0.0.1:8545",
  "profile": "open-pool",
  "denomination": "100000000000000000",
  "contracts": { "privacyPool": "0x…", "shieldedPool": "0x…",
                 "associationSetProvider": "0x…", "hasher": "0x…" },
  "circuits": {
    "poolWithdraw":   { "wasm": "/circuits/poolWithdraw.wasm",   "zkey": "/circuits/poolWithdraw.zkey" },
    "transaction2x2": { "wasm": "/circuits/transaction2x2.wasm", "zkey": "/circuits/transaction2x2.zkey" }
  },
  "relayer": { "address": "0x…", "feeBps": 50 }
}

POST /api/relayer/withdraw

Body is the formatted proof plus public signals. The relayer fills in its own address (the proof must already be bound to it) and submits:

json
{
  "a": ["0x…","0x…"],
  "b": [["0x…","0x…"],["0x…","0x…"]],
  "c": ["0x…","0x…"],
  "stateRoot": "0x…",
  "associationRoot": "0x…",
  "nullifierHash": "0x…",
  "recipient": "0x…",
  "fee": "…",
  "refund": "…"
}
json
// 200 OK
{ "txHash": "0x…", "relayer": "0x…" }

More on the trust model in The relayer.