Skip to content

Kali-Decoder/midnight-dapps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Midnight dApps Collection

Compact Runtime midnight-js wallet-sdk Tests

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.


Repository Structure

├── hello-world ├── escrow ├── todo ├── voting └── README.md

Each folder represents a separate decentralized application template demonstrating a different concept of Midnight smart contract development.


Projects Overview

This repository contains four example applications:

  1. Hello World — Basic Template
  2. Escrow Contract Template
  3. Todo Application
  4. Voting dApp

Each project progressively introduces more advanced concepts.


1. Hello World — Basic Template

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.

Concepts Demonstrated

  • Basic Compact syntax
  • Ledger state variables
  • Writing simple circuits
  • Deploying a contract
  • Interacting with the contract

Example Use Case

A simple contract that stores and retrieves a message.

What You Learn

  • 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.


2. Escrow Contract Template

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.

Key Concepts Demonstrated

  • ZK commitment schemes
  • Multi-party smart contract interactions
  • Derived identity keys
  • Secure contract state machines
  • Conditional fund release

Escrow Workflow

Buyer creates escrow │ ▼ Seller accepts escrow │ ▼ Seller reveals secret │ ├──► RELEASED │ └──► REFUNDED (buyer reclaim)

Features

  • 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.


3. Todo Application

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

Concepts Demonstrated

  • Private data commitments
  • Owner-based access control
  • Simple state machines
  • Zero-Knowledge validation

Features

  • Private todo storage
  • Owner-only updates
  • Commitment-based task verification
  • Local simulator testing

This template shows how Midnight can power privacy-first productivity tools.


4. Voting dApp

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.

Concepts Demonstrated

  • Anonymous voting commitments
  • Poll lifecycle management
  • Governance mechanisms
  • Zero-knowledge vote verification

Features

  • 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.


Learning Path

Developers new to Midnight should explore these projects in the following order:

Step 1 — Hello World

Learn the basics of Compact smart contracts.

Step 2 — Todo Application

Understand private data commitments.

Step 3 — Escrow Contract

Explore multi-party interactions and conditional execution.

Step 4 — Voting dApp

Learn about governance systems and anonymous voting.


Technologies Used

These examples are built using the Midnight development stack.

Midnight Compact

A privacy-first smart contract language used to write Zero-Knowledge circuits and contract logic.

Midnight JS

JavaScript libraries used to interact with the Midnight network.

Wallet SDK

Handles wallet creation, key management, and transaction signing.

Proof Server

Generates Zero-Knowledge proofs required for contract execution.

Docker

Used to run the proof server locally.


Wait until the proof server reports it is ready before interacting with the contracts.


Future Improvements

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

Contributing

Contributions are welcome. Developers can extend these examples to explore new privacy-preserving applications on Midnight.


License

MIT License

About

midnight-dapps

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors