Running Locally
The app
git clone git@github.com:darwin-miden/darwin-app-mainnet.git
cd darwin-app-mainnet
npm install # postinstall patches the Miden SDK
npm run dev # http://localhost:3000The postinstall step is not optional. It applies patch-package plus four scripts that patch the Miden SDK and its React binding (a worker fix, wasm streaming, wasm public path). A tree installed with --ignore-scripts builds and then fails at runtime in ways that look like protocol bugs.
npm run type-check # tsc --noEmit
npm run build # production build
npm run test:e2e # Playwright
npm run test:relay-proof # the view-proof vectors, shared with the relayPointing at the chain
| Variable | Effect |
|---|---|
NEXT_PUBLIC_MIDEN_NETWORK=cedar | Required for mainnet. Without it the app defaults to testnet ids and endpoints |
RELAY_URL | Where the server-side /api/relay-* routes forward to. Production: https://darwin-relay.fly.dev |
RELAY_TOKEN | The proxy's identity at the relay, used only for rate limiting. Opens no data |
NEXT_PUBLIC_BLUEDW_VAULT_ID, NEXT_PUBLIC_RELAY_OPERATOR_ID | Staging only. Point a local app at a separate vault and operator. Unset everywhere else |
Network endpoints, the oracle and the quote asset live in src/config/network.ts. The basket and its coins live in src/lib/basketFaucets.ts, the operator in src/lib/midenConstants.ts.
The relay
The relay is a Node server (darwin-relay/server/server.mjs) that runs the Rust settlement binaries (relay_buy and relay_sell; production runs both as relay_both) one at a time, so the operator account's transactions are never raced. Its HTTP contract is darwin-relay/server/API.md; deploy and rebuild steps are in REBUILD_RUNBOOK.md.
node darwin-relay/server/test-proof.mjs # view proofs
node darwin-relay/server/test-caps.mjs # beta caps
node darwin-relay/server/test-limits.mjs # rate limitsStaging on mainnet
Testing against production is not allowed. darwin-protocol/ops/staging/ creates a separate operator, vault and relay data directory on Miden mainnet, runs the relay and the app on localhost, and refuses to start if any staging id equals a production id:
bash ops/staging/staging_setup_cedar.sh # once: operator, vault, seed
bash ops/staging/staging_run.sh # local relay + app on :3001
bash ops/staging/staging_e2e.sh # end-to-end checksIt needs about 3 USDCx in Bread for the staging operator, plus whatever you want to trade.
Diagnostics in the browser
The relay handoff logs under [relay-handoff], and a trade's progress comes from /api/relay-status. Pending trades and their proofs are in the browser's local storage, which is the first place to look when a trade does not appear.