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.
Note: This project uses Compact 0.24.0 for contract compilation.
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 you hit issues with Preview, install the legacy Lace Wallet extension:
-
Sign in to download:
-
Download
.crxversion 2.34.0. -
In Chrome, open
chrome://extensions. -
Enable Developer mode (top-right).
-
Click Load unpacked and select the extracted extension folder.
After installing, set the Lace Wallet to Undeployed and set the Proof Server to Local.
If using Standalone infrastructure, deposit to your wallet address:
- Go to the
clifolder:
cd packages/cli- Run the
depositcommand to receive Midnight test tokens (tDUST), replacemn_shield-addr_undeployed...with your Undeployed network address:
yarn deposit mn_shield-addr_undeployed...cd packages/ui && yarn startOpen http://localhost:8080 in your browser.
yarn build:all # Build everything
yarn deposit <receiverAddress> # Deposit to 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 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