| name | midnight-infra-setup |
| description | Set up and run Midnight infrastructure locally using official dev tools. Use this skill when setting up local development environment, starting node/indexer/proof-server, troubleshooting infrastructure, or syncing components. Triggers on "setup infrastructure", "start local node", "run indexer", "proof server", "midnight-infra-dev-tools", or "local development". |
| license | MIT |
| metadata | {"author":"webisoft","version":"1.0.0","midnight-version":"0.27.0","sources":["https://github.com/midnightntwrk/midnight-infra-dev-tools","https://github.com/midnightntwrk/midnight-node","https://github.com/midnightntwrk/midnight-indexer","https://github.com/midnightntwrk/midnight-ledger"]} |
Midnight Infrastructure Setup
Complete guide to running Midnight infrastructure locally using the official midnight-infra-dev-tools. This enables full local development without connecting to testnet.
Architecture Overview
┌─────────────────────────────────────────────────────────────────┐
│ Local Development Stack │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
│ │ Midnight Node │ │ Indexer │ │ Proof Server │ │
│ │ │ │ │ │ │ │
│ │ ws://127.0.0.1 │ │ http://127.0.0.1│ │ http://127.0.0.1│ │
│ │ :9944 │ │ :8088 │ │ :6300 │ │
│ │ │ │ │ │ │ │
│ │ - Blockchain │ │ - Query state │ │ - ZK proofs │ │
│ │ - Consensus │ │ - Index txs │ │ - Verification │ │
│ │ - State │ │ - GraphQL API │ │ - Circuits │ │
│ └────────┬────────┘ └────────┬────────┘ └────────┬────────┘ │
│ │ │ │ │
│ └────────────────────┼────────────────────┘ │
│ │ │
│ ┌───────────┴───────────┐ │
│ │ Your dApp / Tests │ │
│ └───────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘
When to Use
- Setting up local Midnight development environment
- Running node, indexer, and proof server locally
- Troubleshooting infrastructure issues
- Syncing component versions
- Building/testing without testnet
Official Repositories
Quick Start
Step 1: Clone Dev Tools
git clone https://github.com/midnightntwrk/midnight-infra-dev-tools.git
cd midnight-infra-dev-tools
Step 2: Select Commit Version
The dev tools allow you to select specific commits for each component to ensure compatibility.
cat versions.json
Step 3: Clone Component Repositories
git clone https://github.com/midnightntwrk/midnight-node.git
git clone https://github.com/midnightntwrk/midnight-indexer.git
git clone https://github.com/midnightntwrk/midnight-ledger.git
Step 4: Start Infrastructure
./scripts/start-all.sh
./scripts/start-node.sh
./scripts/start-indexer.sh
./scripts/start-proof-server.sh
Component Details
Midnight Node
The blockchain node handles consensus, state management, and transaction processing.
Default Endpoint: ws://127.0.0.1:9944
cd midnight-node
cargo build --release
./target/release/midnight-node --dev
docker run -p 9944:9944 midnightntwrk/midnight-node:latest --dev
Key Features:
- Substrate-based blockchain
- Block production
- Transaction pool
- State storage
Midnight Indexer
Indexes blockchain state and provides GraphQL API for queries.
Default Endpoint: http://127.0.0.1:8088
cd midnight-indexer
npm install
npm run start
Key Features:
- Real-time state indexing
- GraphQL API
- Contract state queries
- Transaction history
IMPORTANT: The indexer must be synced with the node version. Update the metadata that the indexer interprets when changing node commits.
Proof Server (Ledger)
Generates and verifies zero-knowledge proofs for transactions.
Default Endpoint: http://127.0.0.1:6300
cd midnight-ledger
cargo build --release
./target/release/proof-server
docker run -p 6300:6300 midnightntwrk/proof-server:latest
CRITICAL: The proof server must use the same ledger version integrated into midnight-node. Check version in:
midnight-node/Cargo.toml lines 63-70
Example from Cargo.toml:
[dependencies]
midnight-ledger = { git = "https://github.com/midnightntwrk/midnight-ledger", rev = "abc123" }
Version Synchronization
Why Version Matching Matters
All three components must be version-compatible:
- Node produces blocks with specific ledger format
- Indexer parses blocks using matching metadata
- Proof server generates proofs for the ledger version
Checking Versions
grep "midnight-ledger" midnight-node/Cargo.toml
cat midnight-indexer/metadata/version.json
./proof-server --version
Syncing Indexer to Node
When you change the node commit:
- Find the ledger version in node's Cargo.toml
- Update indexer metadata to match
- Restart indexer to re-index
cd midnight-indexer
./scripts/update-metadata.sh <node-commit>
npm run reindex
Configuration
Network Configuration
Create a config file for your dApp:
export const localConfig = {
node: {
url: "ws://127.0.0.1:9944",
},
indexer: {
url: "http://127.0.0.1:8088",
graphql: "http://127.0.0.1:8088/graphql",
},
proofServer: {
url: "http://127.0.0.1:6300",
},
};
export const previewConfig = {
node: {
url: "wss://rpc.preview.midnight.network",
},
indexer: {
url: "https://indexer.preview.midnight.network",
graphql: "https://indexer.preview.midnight.network/graphql",
},
proofServer: {
url: "https://proof.preview.midnight.network",
},
};
Environment Variables
MIDNIGHT_NODE_URL=ws://127.0.0.1:9944
MIDNIGHT_INDEXER_URL=http://127.0.0.1:8088
MIDNIGHT_PROOF_SERVER_URL=http://127.0.0.1:6300
Using with Starter Template
The starter template integrates with local infrastructure:
git clone https://github.com/MeshJS/midnight-starter-template.git
cd midnight-starter-template
npm install
npm run setup-standalone
npm run dev:frontend
Troubleshooting
Node Won't Start
Error: Cannot bind to port 9944
Solution: Another process is using the port
lsof -i :9944
kill -9 <PID>
Indexer Can't Connect to Node
Error: WebSocket connection failed
Solution: Ensure node is running and accessible
wscat -c ws://127.0.0.1:9944
Proof Server Version Mismatch
Error: Incompatible ledger version
Solution: Sync proof server to node's ledger version
grep "midnight-ledger" midnight-node/Cargo.toml
cd midnight-ledger
git checkout <matching-commit>
cargo build --release
Indexer Out of Sync
Error: Block parsing failed
Solution: Update indexer metadata and reindex
cd midnight-indexer
./scripts/update-metadata.sh
npm run reindex
Docker Issues
Error: Cannot connect to Docker daemon
Solution: Start Docker Desktop or daemon
open -a Docker
sudo systemctl start docker
Health Checks
Check All Services
curl -s http://127.0.0.1:9944/health
curl -s http://127.0.0.1:8088/health
curl -s http://127.0.0.1:6300/health
Verify Connectivity
wscat -c ws://127.0.0.1:9944
curl -X POST http://127.0.0.1:8088/graphql \
-H "Content-Type: application/json" \
-d '{"query": "{ __schema { types { name } } }"}'
Scripts
Use the provided setup script:
bash /path/to/skills/midnight-infra-setup/scripts/setup.sh [action]
Actions:
start - Start all infrastructure
stop - Stop all infrastructure
status - Check service status
logs - View logs
reset - Reset and restart
Present Results to User
Midnight Infrastructure Status:
Node: ✓ Running (ws://127.0.0.1:9944)
Indexer: ✓ Running (http://127.0.0.1:8088)
Proof Server: ✓ Running (http://127.0.0.1:6300)
All services are healthy and synchronized.
Next steps:
1. Deploy your contract: npm run deploy:local
2. Start frontend: npm run dev:frontend
3. Connect wallet and interact
References