Install the toolchain
This guide covers the installation of core dependencies for developing decentralized applications (DApps) on Midnight. For users intending to interact with DApps on Midnight testnets, see the Set up Lace Wallet guide.
Prerequisites
Before you begin developing DApps on Midnight, ensure you have:
- Google Chrome browser
- Visual Studio Code
- Docker Desktop: https://www.docker.com/products/docker-desktop/
- Lace Wallet: https://chromewebstore.google.com/detail/lace/gafhhkghbfjjkeiendhlofajokpaflmk
Lace Midnight Wallet is in Beta. To access the Midnight wallet, first create a Cardano wallet, then go to settings and enable Beta features. After that you can add a new wallet and choose the Midnight network.
Development is supported on Linux and Mac, Windows is not supported at this time.
Install Compact
Compact is Midnight's dedicated smart contract language for creating DApps that allows developers to control the level of data protection in their applications.
Use the following command to install the pre-built binaries:
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/midnightntwrk/compact/releases/latest/download/compact-installer.sh | sh
Update your shell PATH
The installer script automatically adds Compact to your shell's PATH. However, you need to restart your terminal or reload your shell configuration for the changes to take effect.
To reload your shell configuration without restarting, run the following command:
source ~/.zshrc # for zsh
# or
source ~/.bashrc # for bash
Manual PATH configuration (only if needed): If Compact is not found after restarting, manually add it to your PATH:
export PATH="$HOME/.compact/bin:$PATH"
Then reload your shell configuration as shown above.
Update the compiler version
Update to the latest compiler version:
compact update
This command downloads the latest version of the Compact compiler and sets it as the default version.
Verify the Compact installation
Run these commands to verify your installation:
compact --version # print the version of Compact
compact compile --version # print the version of the compiler
which compact # print the installation path
Verification: These commands return the Compact version number, the compiler version number, and the installation path.
Set up the proof server
The proof server is required to generate zero-knowledge proofs for transactions locally. This section walks you through the process of running the proof server.
Docker Desktop
The proof server runs as a background service using Docker. Ensure the Docker engine is running for the following step.
Run the proof server
Use the following command to start the proof server in your terminal:
docker run -p 6300:6300 midnightntwrk/proof-server:7.0.0 -- midnight-proof-server -v
This command occupies the terminal window while running.
Verification: The terminal displays logs indicating the server is running and listening at http://localhost:6300.
To use a local proof-server with the Lace Midnight wallet, go to Settings » Midnight and select Local (http://localhost:6300).
Install the Compact VS Code extension
The Compact VS Code extension provides helpful syntax highlighting and code snippet completion. To install it, follow these steps:
Verification: You now see the Compact Language Support extension in your installed VS Code extensions.
Install Complete
Your development environment is now configured. You are ready to start building and interacting with privacy-preserving applications on Midnight.
In order to deploy and interact with Midnight DApps, both a Midnight Node and Indexer are required. These are provided as RPC endpoints and can be found in the Latest Stable Release. Subsequent Tutorials will demonstrate their use, alternatively, the Examples section provides complete DApp demonstrations.
Troubleshoot
This section covers common issues that you might encounter during installation and their solutions.
Compact binary not found
If you see this error:
compact: command not found
This means the Compact binary is not in your PATH. Follow the instructions in Update your shell PATH to add it to your PATH.
Docker Desktop not running
If you encounter connection errors when starting the proof server, ensure Docker Desktop is running:
- Open Docker Desktop application.
- Wait for the Docker engine to start (the Docker icon in your system tray should be steady, not animated).
- Try running the proof server command again.
Port already in use
If you see an error that port 6300 is already in use:
Error: bind: address already in use
Either stop the process using port 6300, or run the proof server on a different port:
docker run -p 6301:6300 midnightntwrk/proof-server:7.0.0 -- midnight-proof-server -v
Remember to update your application configuration to use the new port.
Next steps
Now that your development environment is set up, you can: