This repository contains a collection of example decentralized applications built on the Midnight Network using the Compact smart contract language.
These dApps are designed as learning templates to help developers understand how to build privacy-preserving applications using Zero-Knowledge proofs on Midnight.
Each project demonstrates different concepts including:
- Compact smart contract development
- Zero-Knowledge circuits
- Private state handling
- Witness inputs
- Contract state machines
- Local simulation and testing
The goal of this repository is to provide a step-by-step learning path for developers building privacy-first applications on Midnight.
├── hello-world ├── escrow ├── todo ├── voting └── README.md
Each folder represents a separate decentralized application template demonstrating a different concept of Midnight smart contract development.
This repository contains four example applications:
- Hello World — Basic Template
- Escrow Contract Template
- Todo Application
- Voting dApp
Each project progressively introduces more advanced concepts.
The Hello World template is the simplest possible Midnight Compact smart contract.
It is designed for developers who are completely new to Midnight development.
This example focuses on understanding the basic structure of a Compact contract.
- Basic Compact syntax
- Ledger state variables
- Writing simple circuits
- Deploying a contract
- Interacting with the contract
A simple contract that stores and retrieves a message.
- How Compact contracts are structured
- How ledger variables work
- How circuits execute
- How to compile and deploy contracts
This project is ideal as a starting point before exploring more complex applications.
The Escrow contract demonstrates how to build a privacy-preserving financial primitive on Midnight.
Escrow systems typically require a trusted third party to hold funds until a condition is satisfied.
This implementation replaces that trust with cryptographic verification using Zero-Knowledge proofs.
- ZK commitment schemes
- Multi-party smart contract interactions
- Derived identity keys
- Secure contract state machines
- Conditional fund release
Buyer creates escrow │ ▼ Seller accepts escrow │ ▼ Seller reveals secret │ ├──► RELEASED │ └──► REFUNDED (buyer reclaim)
- Privacy-preserving escrow agreements
- Secret-based fund release
- Buyer and seller identity verification
- Secure escrow lifecycle
- Simulator and test environment
This example demonstrates how Midnight can be used for privacy-preserving financial contracts.
The Todo application demonstrates how to build a privacy-preserving productivity application.
Unlike traditional todo apps that store task content in plaintext, this implementation stores cryptographic commitments.
This ensures:
- Todo content remains private
- Only the owner can modify tasks
- The blockchain verifies operations without revealing task content
- Private data commitments
- Owner-based access control
- Simple state machines
- Zero-Knowledge validation
- Private todo storage
- Owner-only updates
- Commitment-based task verification
- Local simulator testing
This template shows how Midnight can power privacy-first productivity tools.
The Voting dApp demonstrates how to build a privacy-preserving governance system on Midnight.
Traditional blockchain voting systems expose all votes publicly, which can lead to:
- Loss of voter privacy
- Manipulation risks
- Coercion
This implementation solves the problem by using Zero-Knowledge vote commitments.
Votes remain private while the blockchain verifies their validity.
- Anonymous voting commitments
- Poll lifecycle management
- Governance mechanisms
- Zero-knowledge vote verification
- Private vote commitments
- Poll creator permissions
- Secure poll lifecycle
- Vote counting
- Zero-knowledge validation
This project demonstrates how Midnight can support private governance systems and DAOs.
Developers new to Midnight should explore these projects in the following order:
Learn the basics of Compact smart contracts.
Understand private data commitments.
Explore multi-party interactions and conditional execution.
Learn about governance systems and anonymous voting.
These examples are built using the Midnight development stack.
A privacy-first smart contract language used to write Zero-Knowledge circuits and contract logic.
JavaScript libraries used to interact with the Midnight network.
Handles wallet creation, key management, and transaction signing.
Generates Zero-Knowledge proofs required for contract execution.
Used to run the proof server locally.
Wait until the proof server reports it is ready before interacting with the contracts.
Possible improvements to these templates include:
- Multi-candidate voting systems
- Anonymous voting with nullifiers
- Multi-user todo applications
- Escrow dispute resolution
- DAO governance integration
- Privacy-preserving DeFi primitives
Contributions are welcome. Developers can extend these examples to explore new privacy-preserving applications on Midnight.
MIT License