I built a privacy-preserving Escrow smart contract using Compact and a TypeScript CLI.
This project demonstrates how two parties (Buyer and Seller) can securely transact using zk proofs, where funds are released only when predefined conditions (a secret + identity verification) are satisfied.
It serves as a complete reference implementation of a real-world escrow workflow on Midnight.
Smart Contract (Compact)
The contract enables:
-
Buyer to create and fund an escrow
-
Seller to accept the escrow
-
Conditional release of funds using a secret
-
Refund functionality if conditions are not met
Core properties:
-
Zero-knowledge proof verification of the release secret
-
Identity verification without exposing unnecessary data
-
Privacy-preserving transaction flow
Stable Identity System
The project implements a deterministic escrow identity layer using escrow-identity.json, separate from the Midnight wallet address.
This ensures:
-
Persistent seller identity across sessions
-
Separation of wallet address and escrow identity
-
Secure role-based interaction
CLI Application
The interactive CLI supports:
-
Wallet restore (Alice / Bob simulation)
-
Deploy new escrow contract
-
Join existing escrow
-
Create escrow (Buyer)
-
Accept escrow (Seller)
-
Release funds with secret + nonce
-
Refund escrow (Buyer fallback)
-
Identity display
-
Proof server integration
All actions execute real Midnight transactions.
Check it out: GitHub - tusharpamnani/midnight-escrow
