Skip to main content

Local Dev Environment

Knight Shield uses Docker Compose to run a complete local Midnight Network stack for development.

Docker Compose Services

The docker-compose.yml at the project root defines three services:

midnight-node

image: midnightnetwork/midnight-node:v0.21.0
ports:
- "9944:9944"

Local Midnight node exposing WebSocket RPC on port 9944. This is the blockchain node that processes transactions and maintains state.

indexer

image: midnightnetwork/indexer:v4.0.0-rc.4
ports:
- "8088:8088"

Block indexer that provides queryable APIs for transaction history, contract state, and balance lookups. The wallet SDK queries this for sync operations.

proof-server

image: midnightnetwork/proof-server:v7.0.0
ports:
- "6300:6300"

ZK proof generation server. Required for submitting transactions that involve Compact contract calls — the proof server generates the zero-knowledge proofs that validate state transitions.

Starting the Stack

# Start all services in background
docker compose up -d

# Check status
docker compose ps

# View logs
docker compose logs -f midnight-node

# Stop all services
docker compose down

Network Configuration

When running locally, use the standalone network configuration in the core SDK:

import { NETWORKS } from '@knight-shield/core';

const config = NETWORKS.standalone;
// {
// node: 'http://127.0.0.1:9944',
// indexer: 'http://127.0.0.1:8088/api/v1/graphql',
// proofServer: 'http://127.0.0.1:6300'
// }

Relay Server

The relay server runs separately from the Docker stack. It connects to the local Midnight node as its upstream:

# Default upstream: ws://127.0.0.1:9944
cd packages/relay-server
MIDNIGHT_NODE=ws://127.0.0.1:9944 PORT=8443 node dist/server.js

Environment variables:

  • PORT — Server port (default: 8443)
  • MIDNIGHT_NODE — Upstream Midnight node WebSocket URL (default: ws://127.0.0.1:9944)

Compact Compiler

Install the Compact compiler (compactc) from the Midnight Network developer tools:

# Verify installation
compactc --version
# Expected: 0.29.0

Compile contracts:

pnpm compile:contracts
# Outputs to build/ directory:
# - JS bindings (managed and witnesses)
# - ZK proving keys
# - ZKIR (zero-knowledge intermediate representation)

Mobile Development

iOS

Requires Xcode with iOS Simulator. Install CocoaPods dependencies:

cd packages/mobile/ios
pod install
cd ..
npx react-native run-ios

Android

Requires Android Studio with an emulator or connected device:

cd packages/mobile
npx react-native run-android

Metro Bundler

The Metro bundler serves the JavaScript bundle to the mobile app:

cd packages/mobile
npx react-native start

Troubleshooting

IssueSolution
Node not syncingCheck docker compose logs midnight-node for errors
Proof server timeoutZK proof generation is CPU-intensive — ensure adequate resources
Indexer not respondingThe indexer needs the node to be fully synced first
Relay connection refusedEnsure the relay server is running and pointing to the correct node