Decentralized escrow system built on the Midnight Network using Compact smart contracts. The escrow contract enables secure, trustless transactions by holding funds in escrow until conditions are met.
- Create Escrows: Deposit funds and assign them to a contributor using their
ZswapCoinPublicKeyaddress - Release Funds: Release escrowed funds to the designated contributor
- State Management: Track escrow status (active, released, refunded)
- Privacy-Preserving: Built on Midnight Network with zero-knowledge proofs for transaction privacy
- Treasury Management: Secure fund storage using
QualifiedCoinInfo
-
Create: A user creates an escrow by depositing funds and specifying a contributor address. The contract stores the funds in its treasury and assigns a unique escrow ID.
-
Release: When conditions are met, the escrow can be released, transferring the funds to the designated contributor address.
-
State Tracking: Each escrow maintains its state (active → released), allowing for transparent tracking of all escrow transactions.
yarn install- Navigate to the
clifolder:
cd packages/cli- Run zk-params script for proof server:
./fetch-zk-params.shThis downloads all required ZK parameters (k=10 to k=17) to .cache/midnight/zk-params/.
- Navigate to the
uifolder
cd packages/ui- Add the
.envvariables
echo "VITE_NETWORK_ID=TestNet
VITE_LOGGING_LEVEL=trace" > .env- Navigate to the
uifolder
cd packages/ui- Add the
.envvariables (useUndeployedas the Network ID for local development)
echo "VITE_NETWORK_ID=Undeployed
VITE_LOGGING_LEVEL=trace" > .envyarn build:allThis compiles the contract, builds the API, and builds the UI.
Choose one option:
cd packages/cli && docker compose -f testnet.yml upcd packages/cli && docker compose -f standalone.yml upPorts:
- Node:
9944 - Indexer:
8088 - Proof Server:
6300
- Open Midnight Lace Wallet
- Go to Settings → Network
- Select:
- TestNet for Option A
- Undeployed for Option B (Standalone infrastructure)
If using Standalone infrastructure, fund your wallet address:
- Go to the
clifolder:
cd packages/cli- Run the
fundcommand to receive Midnight test tokens (tDUST), replacemn_shield-addr_undeployed...with your Undeployed network address:
yarn fund mn_shield-addr_undeployed...cd packages/ui && yarn startOpen http://localhost:8080 in your browser.
yarn build:all # Build everything
yarn infra:up # Start standalone infrastructure
yarn infra:down # Stop standalone infrastructure
yarn infra:logs # View infrastructure logs
yarn fund <address> # Fund wallet (standalone mode)escrow/
├── packages/
│ ├── contract/ # Escrow Compact contract
│ ├── api/ # API layer
│ ├── ui/ # React frontend
│ └── cli/ # Infrastructure & CLI tools
│ ├── standalone.yml # Local network compose
│ ├── testnet.yml # Testnet compose
│ └── src/ # Funding scripts
├── compact/ # Compact compiler
└── .cache/ # ZK params (gitignored)
This project reuses and adapts components from upstream open-source work by Brick Towers.
In particular:
- The CLI funding utility and related infrastructure scripts are derived from the Brick Towers midnight-local-network project: https://github.com/bricktowers/midnight-local-network
These upstream project is licensed under the MIT License. The original copyright and permission notices are preserved in the relevant source files, in accordance with the license terms.
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
We welcome contributions! Please follow these guidelines:
- Fork the repository and create a feature branch
- Make your changes following the existing code style
- Test thoroughly - ensure all builds pass and the contract works as expected
- Submit a pull request with a clear description of your changes