{"id":47301308,"url":"https://github.com/0xshae/midnight-playground","last_synced_at":"2026-03-31T07:00:44.451Z","repository":{"id":336419757,"uuid":"1146540801","full_name":"0xshae/midnight-playground","owner":"0xshae","description":"Local playground for Midnight Compact contracts - run a full node, indexer, and proof server via Docker, fund your Lace wallet, and deploy without testnets or faucets.","archived":false,"fork":false,"pushed_at":"2026-03-16T16:12:31.000Z","size":215,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-17T03:43:58.197Z","etag":null,"topics":["blockchain","compact","devrel","lace","local-development","midnightntwrk","privacy","smart-contracts","typescript","zkproof"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0xshae.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-31T09:04:24.000Z","updated_at":"2026-03-16T16:12:37.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/0xshae/midnight-playground","commit_stats":null,"previous_names":["0xshae/midnight-playground"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/0xshae/midnight-playground","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xshae%2Fmidnight-playground","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xshae%2Fmidnight-playground/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xshae%2Fmidnight-playground/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xshae%2Fmidnight-playground/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xshae","download_url":"https://codeload.github.com/0xshae/midnight-playground/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xshae%2Fmidnight-playground/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31224248,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-31T04:08:55.938Z","status":"ssl_error","status_checked_at":"2026-03-31T04:08:47.883Z","response_time":111,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","compact","devrel","lace","local-development","midnightntwrk","privacy","smart-contracts","typescript","zkproof"],"created_at":"2026-03-17T03:00:22.710Z","updated_at":"2026-03-31T07:00:44.439Z","avatar_url":"https://github.com/0xshae.png","language":"TypeScript","funding_links":[],"categories":["Developer Tools"],"sub_categories":[],"readme":"# Midnight Local Playground\n\nThis project extends the Midnight Network with additional developer tooling.\n\nA **playground** for writing [Compact](https://docs.midnight.network) contracts and deploying them **locally** on your machine. Use the **Midnight Lace Preview Wallet** on the **“Undeployed”** network to fund your wallet, deploy contracts, and interact with them—without depending on public testnets or faucets.\n\n---\n\n## What this repo is for\n\n- **Write** Compact smart contracts (edit the example in `midnight-local-dapp` or add your own).\n- **Run** a full local Midnight network (node, indexer, proof server) via Docker.\n- **Fund** your Lace-derived wallet using a CLI script (no built-in faucet on Undeployed).\n- **Deploy** contracts from the repo root using the **same wallet as Lace** (mnemonic-based).\n- **Interact** with deployed contracts via the Lace wallet UI or a CLI adapted for the local setup.\n\nIdeal for development, workshops, and learning the Compact toolchain and Midnight stack locally.\n\n---\n\n## Prerequisites\n\n- **Git**\n- **Docker** and **Docker Compose v2**\n- **Node.js ≥ 22.16.0** ([nvm](https://github.com/nvm-sh/nvm) recommended)\n- **Yarn** (classic)\n- **Midnight Lace Preview** (v2.36.0 or later) browser extension\n\n---\n\n## Quick reference: ports\n\n| Service       | Port | Purpose        |\n|---------------|------|----------------|\n| Proof Server  | 6300 | ZK proof generation |\n| Node          | 9944 | RPC / chain   |\n| Indexer       | 8088 | GraphQL API   |\n\n---\n\n## Step-by-step setup\n\nAll commands below are from the **repository root** unless stated otherwise.\n\n### 1. Clone and install\n\n```bash\ngit clone https://github.com/0xshae/midnight-playground.git midnight-playground\ncd midnight-playground\nnvm use 22   # or: nvm install 22 \u0026\u0026 nvm use 22\nyarn install\n```\n\n### 2. Start the local network\n\n```bash\ndocker compose up -d\n```\n\nGive it a short time to start (e.g. 30 seconds). The node, indexer, and proof server will be available on the ports above.\n\n### 3. Connect Lace to “Undeployed”\n\n- In **Lace** → **Settings** → **Midnight**\n- Set network to **“Undeployed”**\n- Save and switch the wallet to that network\n\nUse the same wallet (and mnemonic) for funding and deployment so addresses match.\n\n### 4. Fund your wallet\n\nThe Undeployed network has no faucet. Use the included fund script with your **BIP-39 mnemonic** (the one from Lace):\n\n```bash\nyarn fund \"your twelve or twenty four mnemonic words\"\n```\n\nThis funds both the shielded and unshielded addresses derived from that mnemonic (same derivation as Lace). You can also fund a single address:\n\n```bash\nyarn fund mn_shield-addr_undeployed1...\nyarn fund mn_addr_undeployed1...\n```\n\n### 5. Generate DUST in Lace (required before deploy)\n\nDeploying a contract uses **DUST** for fees. You must have DUST in your Lace wallet on the Undeployed network:\n\n1. Open **Lace** → **Midnight** (Undeployed).\n2. Use the wallet UI to **generate DUST** (follow Lace’s in-app steps).\n3. **Wait for DUST to refill** to the required level.\n\nIf you skip this step, `yarn deploy` can fail due to insufficient DUST.\n\n### 6. Deploy the Hello World contract\n\nFrom the repo root, using the **same mnemonic** as Lace:\n\n```bash\nyarn deploy \"your twelve or twenty four mnemonic words\"\n```\n\n- Requires a **funded** wallet (`yarn fund` first) and **DUST** (generated in Lace).\n- Deploys the contract from `midnight-local-dapp` (Hello World example).\n- Writes **`midnight-local-dapp/deployment.json`** with `contractAddress` and `txHash`.\n\nYou can re-run this after changing the contract (see below).\n\n---\n\n## Changing the contract and redeploying\n\n1. **Edit** the Compact source, e.g.  \n   `midnight-local-dapp/contracts/hello-world.compact`\n2. **Recompile** from the dApp directory:\n   ```bash\n   cd midnight-local-dapp\n   yarn compile\n   cd ..\n   ```\n3. **Redeploy** from the repo root:\n   ```bash\n   yarn deploy \"your mnemonic\"\n   ```\n\nThe deploy script is currently wired to the **Hello World** contract and its `storeMessage` entrypoint/verifier. To deploy a different contract or entrypoint, you’d need to point the deploy script at that contract’s path and verifier key (see `src/deploy.ts`).\n\n---\n\n## Interacting with the deployed contract\n\n### Option A: CLI (read contract state)\n\nThe `midnight-local-dapp` folder includes a CLI that uses the **same wallet derivation as Lace/deploy**, so your address and balance match.\n\n```bash\ncd midnight-local-dapp\nyarn install\nyarn build\nyarn cli\n```\n\nEnter your mnemonic when prompted. The CLI can:\n- **Read** the current message stored in the contract\n- **Show** your wallet address and balance (matches Lace)\n\nExample session:\n```\nHello World Contract CLI (Lace-compatible wallet)\n\nContract: aa6ce704ee3f482b8675ba1b0f95f9e0dfa8fbcf693800e32f3b5593dbd41688\n\nEnter your mnemonic: \u003cyour mnemonic\u003e\n\nBuilding wallet (same derivation as Lace)...\nYour wallet address (Lace match): mn_shield-addr_undeployed1r6d...\nBalance: 94011000000\n\n--- Menu ---\n1. Read current message\n2. Show wallet info\n3. Exit\n```\n\n### Option B: Lace wallet UI (store messages)\n\nTo **store a message** in the contract, use a dApp frontend connected to Lace:\n\n1. Build or use a dApp that connects to Lace via the **dapp-connector-api**\n2. Configure it for the **Undeployed** network with local endpoints:\n   - Indexer: `http://127.0.0.1:8088/api/v3/graphql`\n   - Node: `http://127.0.0.1:9944`\n   - Proof server: `http://127.0.0.1:6300`\n3. Point it at the contract address from `midnight-local-dapp/deployment.json`\n4. Call the `storeMessage` circuit through the dApp UI\n\nLace will use your local node/indexer when connected to Undeployed.\n\n### Why can't the CLI store messages?\n\nStoring a message requires calling the `storeMessage` circuit, which involves:\n- Building a contract call transaction with ZK proofs\n- The proof server generating proofs for the circuit inputs\n\nThis is typically handled by a dApp frontend + Lace, which manages the proof generation and transaction signing through the wallet connector. The CLI currently focuses on reading state, which doesn't require proofs.\n\n---\n\n## Repo layout (relevant parts)\n\n```\nmidnight-playground/\n├── compose.yml          # Docker: node, indexer, proof-server\n├── package.json         # Root scripts: fund, deploy\n├── src/\n│   ├── fund.ts          # Fund shielded/unshielded from mnemonic or address\n│   ├── deploy.ts        # Deploy Hello World using Lace-compatible wallet\n│   └── utils.ts         # Wallet initialization (HD wallet, same derivation as Lace)\n└── midnight-local-dapp/\n    ├── contracts/\n    │   ├── hello-world.compact   # Edit this (or add new contracts)\n    │   └── managed/hello-world/  # Compiled output, keys, contract module\n    ├── deployment.json           # Written by yarn deploy\n    ├── src/\n    │   ├── cli.ts                # CLI for reading contract state\n    │   └── utils.ts              # Wallet utils (same as root)\n    └── package.json              # compile, build, cli scripts\n```\n\n---\n\n## Scripts\n\n### Repo root\n\n| Script                   | Description |\n|--------------------------|-------------|\n| `yarn fund \"mnemonic\"`   | Fund Lace-derived addresses on Undeployed (or pass a single address). |\n| `yarn deploy \"mnemonic\"` | Deploy the Hello World contract; requires funded wallet + DUST in Lace. |\n\n### midnight-local-dapp\n\n| Script        | Description                                |\n|---------------|--------------------------------------------|\n| `yarn compile`| Compile `contracts/hello-world.compact`    |\n| `yarn build`  | Compile TypeScript (`src/` → `dist/`)      |\n| `yarn cli`    | Run the interactive CLI (read contract state, show wallet info) |\n\n---\n\n## Troubleshooting\n\n- **“Balance is still 0”**  \n  Run `yarn fund \"your mnemonic\"` and ensure the local network is up (`docker compose up -d`).\n\n- **Deploy fails (e.g. insufficient DUST)**  \n  In Lace (Undeployed), generate DUST and wait for it to refill, then run `yarn deploy` again.\n\n- **“Invalid Transaction: Custom error: 110”**  \n  The node rejected the deploy (e.g. verifier key or proof issue). Check `docker compose logs node` and ensure node/image versions in `compose.yml` match the ledger-v6 and proof-server versions used by this repo.\n\n- **“Command 'fund' not found”**  \n  Run `yarn install` from the repo root so the `fund` script is available.\n\n---\n\n## References\n\n- [Midnight Docs – Interact with an MN app](https://docs.midnight.network/getting-started/interact-with-mn-app) (Testnet CLI flow; adapt endpoints and network for local Undeployed).\n- [Compact](https://docs.midnight.network) – Midnight’s smart contract language and toolchain.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xshae%2Fmidnight-playground","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xshae%2Fmidnight-playground","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xshae%2Fmidnight-playground/lists"}