Build

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 ci

Start 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 --wait

Compile the contract.

npm run compile -w @mitome/contract

Make the development secrets: the session secret and the checker's key pair, written to git-ignored env files.

npm run setup:dev -w @mitome/api

Run the three apps, each in its own terminal.

npm run dev -w @mitome/api
npm run dev -w @mitome/verify
npm run dev -w @mitome/web

Open 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/contract

The 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

AppVariableWhat
API, checkerDATABASE_URLPostgres (local default postgres://mitome:mitome@127.0.0.1:5433/mitome)
API, checkerAPP_ORIGINSWhere the web app runs
APIBETTER_AUTH_URL, BETTER_AUTH_SECRETThe API's public address (AI agents reach /mcp there); the session secret (32+ characters)
APIPASSKEY_RP_IDYour domain, for passkeys
APIMIDNIGHT_NETWORKlocal, preview or preprod: the network when only one is used
APIMIDNIGHT_NETWORKSSeveral at once, comma-separated, for example preview,preprod; the first is the default for new forms
APIMIDNIGHT_<NETWORK>_SPONSOR_SEEDThe wallet that pays fees on that network (in .env.<network>)
APIBLOCKFROST_PROJECT_IDPreprod only: a Blockfrost Midnight Preprod project ID (it starts with nightpreprod)
APIMIDNIGHT_WALLET_STATE_DIRWhere synced wallet state is kept, so a restart syncs only the gap (default .wallet-state/)
APIMIDNIGHT_PROOF_SERVERFor deploys and owner actions (default http://127.0.0.1:6300)
APICHECKER_VERIFYING_KEYThe checker's public key, sealed into forms with checks
APISPONSOR_PER_IP_PER_HOUR, SPONSOR_PER_FORM_PER_MINUTEAnswer rate limits (30, 60)
APIGUEST_SIGNUPS_PER_IP_PER_HOUR, GUEST_FORMS_PER_WORKSPACE, GUEST_PUBLISHES_PER_DAYGuest workspaces: new ones per address per hour, published forms each, publishes per day in all (5, 3, 40)
APIMCP_PREVIEW_ORIGINWhere the API fetches the in-chat form preview for agents (default: the app's origin)
API, checkerPORT8787 for the API, 8788 for the checker
API, checkerTRUST_PROXY_HOPSHow many proxies to trust in X-Forwarded-For (1 behind one reverse proxy)
API, checkerRESEND_API_KEY, EMAIL_FROMSending email
CheckerMITOME_CHECKER_SIGNING_KEYSigns passes
CheckerGITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET (and DISCORD_…, X_…), PUBLIC_URLAccount checks; callbacks go to PUBLIC_URL
CheckerETHEREUM_RPC_URLS, BASE_RPC_URLSToken balances (public nodes by default)
CheckerZKPASSPORT_DOMAINThe domain ZKPassport shows people
CheckerZKPASSPORT_RPC_URLEthereum node for ZKPassport's certificate registry (the SDK's shared one by default)
CheckerZKPASSPORT_DEV_MODEAccepts ZKPassport's mock documents, for local testing; refused in production
WebVITE_API_URL, VITE_CHECKER_URL, VITE_DOCS_URLWhere 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:

ImageDockerfileServes
APIapps/api/DockerfilePort 8787; keep /data/wallet-state and /data/files on volumes
Checkerapps/verify/DockerfilePort 8788
Appapps/web/Dockerfilenginx on port 80; VITE_API_URL, VITE_CHECKER_URL and VITE_DOCS_URL are build arguments
Siteapps/site/DockerfileThe landing page, nginx on port 80 (old /docs links redirect to the docs)
Docsapps/docs/DockerfileThese 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.

On this page