Run it yourself
Run all of Mitome on your machine against a local Midnight network, then on Preview and Preprod, and on a server with Docker.
Mitome is open source under Apache-2.0. Everything below runs on one machine with Docker.
You need
- Node 22 and npm 11.10 or later (CI and the images use
11.21.0) - Docker
- The Compact compiler 0.36.1, to compile the contract
Start it
Install from the repository root.
npm ciStart the local Midnight network (node, indexer, proof server 9.0.2) and Postgres.
npm run env:up -w @mitome/contract
docker compose -f infra/compose.yml up -d --waitCompile the contract.
npm run compile -w @mitome/contractMake the development secrets: the session secret and the checker's key pair, written to git-ignored env files.
npm run setup:dev -w @mitome/apiRun the three apps, each in its own terminal.
npm run dev -w @mitome/apinpm run dev -w @mitome/verifynpm run dev -w @mitome/webOpen the web app (it prints its address), sign in with any email: without a Resend key, sign-in links and email codes are written to the .mail/ folder at the repository root.
The API migrates the database when it starts. On the local network the sponsor wallet is funded from the network's genesis, so publishing and answering work at once.
Check it end to end
npm run e2e -w @mitome/api
npm run test:sim -w @mitome/contractThe first runs the whole flow against your local stack: sign in, keys, publish a checked form, a walletless answer recorded and matched to its receipt, pause, a refused second answer, delete, a signed webhook. The second runs the contract's 41 simulator tests.
Settings
| App | Variable | What |
|---|---|---|
| API, checker | DATABASE_URL | Postgres (local default postgres://mitome:mitome@127.0.0.1:5433/mitome) |
| API, checker | APP_ORIGINS | Where the web app runs |
| API | BETTER_AUTH_URL, BETTER_AUTH_SECRET | The API's public address (AI agents reach /mcp there); the session secret (32+ characters) |
| API | PASSKEY_RP_ID | Your domain, for passkeys |
| API | MIDNIGHT_NETWORK | local, preview or preprod: the network when only one is used |
| API | MIDNIGHT_NETWORKS | Several at once, comma-separated, for example preview,preprod; the first is the default for new forms |
| API | MIDNIGHT_<NETWORK>_SPONSOR_SEED | The wallet that pays fees on that network (in .env.<network>) |
| API | BLOCKFROST_PROJECT_ID | Preprod only: a Blockfrost Midnight Preprod project ID (it starts with nightpreprod) |
| API | MIDNIGHT_WALLET_STATE_DIR | Where synced wallet state is kept, so a restart syncs only the gap (default .wallet-state/) |
| API | MIDNIGHT_PROOF_SERVER | For deploys and owner actions (default http://127.0.0.1:6300) |
| API | CHECKER_VERIFYING_KEY | The checker's public key, sealed into forms with checks |
| API | SPONSOR_PER_IP_PER_HOUR, SPONSOR_PER_FORM_PER_MINUTE | Answer rate limits (30, 60) |
| API | GUEST_SIGNUPS_PER_IP_PER_HOUR, GUEST_FORMS_PER_WORKSPACE, GUEST_PUBLISHES_PER_DAY | Guest workspaces: new ones per address per hour, published forms each, publishes per day in all (5, 3, 40) |
| API | MCP_PREVIEW_ORIGIN | Where the API fetches the in-chat form preview for agents (default: the app's origin) |
| API, checker | PORT | 8787 for the API, 8788 for the checker |
| API, checker | TRUST_PROXY_HOPS | How many proxies to trust in X-Forwarded-For (1 behind one reverse proxy) |
| API, checker | RESEND_API_KEY, EMAIL_FROM | Sending email |
| Checker | MITOME_CHECKER_SIGNING_KEY | Signs passes |
| Checker | GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET (and DISCORD_…, X_…), PUBLIC_URL | Account checks; callbacks go to PUBLIC_URL |
| Checker | ETHEREUM_RPC_URLS, BASE_RPC_URLS | Token balances (public nodes by default) |
| Checker | ZKPASSPORT_DOMAIN | The domain ZKPassport shows people |
| Checker | ZKPASSPORT_RPC_URL | Ethereum node for ZKPassport's certificate registry (the SDK's shared one by default) |
| Checker | ZKPASSPORT_DEV_MODE | Accepts ZKPassport's mock documents, for local testing; refused in production |
| Web | VITE_API_URL, VITE_CHECKER_URL, VITE_DOCS_URL | Where the API, the checker and these docs are |
On Preview
Preview is Midnight's public test network, and Mitome runs on it end to end. Preview's node and indexer are public and need no account; the proof server still runs on your machine.
Make and fund the sponsor wallet. Run MIDNIGHT_NETWORK=preview npm run sponsor:wallet -w @mitome/contract. The first run makes the wallet's seed (kept in the git-ignored .env.preview) and prints its address. Paste it into the Preview faucet, pass its human check and request tNIGHT: 5,000 per request.
Wait for DUST. The script registers that NIGHT to generate DUST and waits for 60 DUST, about 25 minutes. A form costs about 5.5 DUST to publish and an answer about 0.36 DUST, and the wallet keeps generating about 2.5 DUST a minute.
Run the API on Preview. Start it with MIDNIGHT_NETWORK=preview; GET /api/status lists each network's state: {"midnight":{"networks":[{"network":"preview","status":"ready"}]}} once the wallet has synced (starting before that), or unfunded while the sponsor wallet has no DUST to pay fees. The checker and web app need no change: each form remembers its network, and people's browsers read Preview's indexer directly.
Publishing takes about 20 seconds on Preview, and an answer is recorded about 20 seconds after Submit (measurements).
On Preprod
Preprod is Midnight's last test network before mainnet. Its node and indexer are served only by Blockfrost, and every request needs a project key, so people's browsers never talk to it directly: they read it through a read-only window in Mitome's API (/api/public/indexer/preprod), which adds the key on the server and passes on only block reads and contract reads for Mitome's own forms.
Get a key. Sign in at blockfrost.io, add a project on the Midnight preprod network and put its project ID in the git-ignored .env.preprod as BLOCKFROST_PROJECT_ID. The free plan allows 50,000 requests a day; a wallet's sync streams over one connection, so it uses few.
Make and fund the sponsor wallet. Run MIDNIGHT_NETWORK=preprod npm run sponsor:wallet -w @mitome/contract and send it tNIGHT from the Preprod faucet. The first sync starts at the Ledger 9 fork instead of replaying all of Preprod's history, and took about 12.5 minutes when measured; after that, the saved state makes a restart quick.
Run both. Start the API with MIDNIGHT_NETWORKS=preview,preprod. /api/status lists each network and whether it's ready, and owners pick one when they first publish a form.
On a server
Each app has a Dockerfile, built from the repository root:
| Image | Dockerfile | Serves |
|---|---|---|
| API | apps/api/Dockerfile | Port 8787; keep /data/wallet-state and /data/files on volumes |
| Checker | apps/verify/Dockerfile | Port 8788 |
| App | apps/web/Dockerfile | nginx on port 80; VITE_API_URL, VITE_CHECKER_URL and VITE_DOCS_URL are build arguments |
| Site | apps/site/Dockerfile | The landing page, nginx on port 80 (old /docs links redirect to the docs) |
| Docs | apps/docs/Dockerfile | These docs, nginx on port 80 |
The API, checker and app images compile the form contract during the build with the pinned Compact toolchain (0.36.1, checked by SHA-256). Compiling is deterministic, so the keys the app serves to browsers match the API's. The app's nginx passes Midnight's public proving parameters through from srs.midnight.network under /srs/, lets only /embed/… pages be framed by other sites, and answers 404 for a missing key file. The API also needs Midnight's proof server (midnightntwrk/proof-server:9.0.2) on a private network and Postgres 17.
Only one API may use a sponsor wallet at a time: two would try to spend the same DUST.