Midnight local network
The local network is a standalone tool for running a local Midnight development network and funding test wallets.
This guide walks you through the process of setting up a local Midnight network and funding test wallets in the undeployed network.
Prerequisites
Before you proceed, ensure you have::
- Docker Desktop
- Node.js >= 22.0.0
Installation
To get started, clone the Midnight local network repository:
git clone https://github.com/midnightntwrk/midnight-local-dev.git
cd midnight-local-dev
Install the dependencies:
npm install
Network services
The local network runs three Docker containers on the following ports:
| Service | Container Name | Port | URL |
|---|---|---|---|
| Midnight Node | midnight-node | 9944 | http://localhost:9944 |
| Indexer (GraphQL) | midnight-indexer | 8088 | http://localhost:8088/api/v3/graphql |
| Indexer (WebSocket) | midnight-indexer | 8088 | ws://localhost:8088/api/v3/graphql/ws |
| Proof Server | midnight-proof-server | 6300 | http://localhost:6300 |
All services use the undeployed network ID with the dev node preset.
Docker images
The standalone.yml file in the root of the repository defines the Docker images and specific versions pulled when you start the local network.
| Service | Image | Version |
|---|---|---|
| Node | midnightntwrk/midnight-node | 0.20.0 |
| Indexer | midnightntwrk/indexer-standalone | 3.0.0 |
| Proof Server | midnightntwrk/proof-server | 7.0.0 |
Start the local network
Once the installation is complete, start the local network by running the following command:
npm start
This single command does the following:
- Pull the latest Docker images for the Midnight node, indexer, and proof server.
- Start all three containers with health checks.
- Initialize the genesis master wallet (seed
0x00...001) which holds all minted NIGHT tokens. - Register DUST for the master wallet (required to pay transaction fees).
- Display the master wallet balance.
- Present an interactive menu for funding wallets in the undeployed network.
Once running, you'll see:
Choose an option:
[1] Fund accounts from config file (NIGHT + DUST registration)
[2] Fund accounts by public key (NIGHT transfer only)
[3] Display master wallet balances
[4] Exit
>
Fund wallets
The local network provides two options for funding wallets:
- Fund from a config file
- Fund by public key
Each funding operation transfers 50,000 tNIGHT from the genesis master wallet. You can fund up to 10 accounts per operation.
Option 1: Fund from a config file
The config option handles wallet operations such as generating the wallet seed from mnemonic, transferring tNIGHT to the unshielded address, syncing the wallet, and registering tNIGHT for DUST generation.
It pulls wallet information from a config file, which is a JSON file with the following structure:
{
"accounts": [
{
"name": "Alice",
"mnemonic": "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art"
}
]
}
Here's a breakdown of the fields:
| Field | Type | Description |
|---|---|---|
accounts | array | List of accounts to fund (max 10) |
accounts[].name | string | Display name for logging |
accounts[].mnemonic | string | BIP39 mnemonic phrase (24 words) |
An example file is provided at accounts.example.json. Copy the file to accounts.json and edit it to add your wallet mnemonics.
cp accounts.example.json accounts.json
After editing the file, select option [1] Fund accounts from config file (NIGHT + DUST registration) from the interactive menu.
You are prompted to enter the path to the config file.
> 1
Path to accounts JSON file: ./accounts.json
The tool funds the wallets from the config file.