Skip to content

MeshJS/midnight-escrow-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Midnight Escrow System

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.

Key Features

  • Create Escrows: Deposit funds and assign them to a contributor using their ZswapCoinPublicKey address
  • 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

How It Works

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

  2. Release: When conditions are met, the escrow can be released, transferring the funds to the designated contributor address.

  3. State Tracking: Each escrow maintains its state (active → released), allowing for transparent tracking of all escrow transactions.

Quick Start

1. Install Dependencies

yarn install

2. Fetch ZK Parameters

  • Navigate to the cli folder:
cd packages/cli
  • Run zk-params script for proof server:
./fetch-zk-params.sh

This downloads all required ZK parameters (k=10 to k=17) to .cache/midnight/zk-params/.

3. Configure Environment Variables

For Testnet:

  • Navigate to the ui folder
cd packages/ui
  • Add the .env variables
echo "VITE_NETWORK_ID=TestNet
VITE_LOGGING_LEVEL=trace" > .env

For Standalone (Local Development):

  • Navigate to the ui folder
cd packages/ui
  • Add the .env variables (use Undeployed as the Network ID for local development)
echo "VITE_NETWORK_ID=Undeployed
VITE_LOGGING_LEVEL=trace" > .env

4. Build All Packages

yarn build:all

This compiles the contract, builds the API, and builds the UI.

5. Start Infrastructure

Choose one option:

Option A: Testnet (connects to Midnight public testnet)

cd packages/cli && docker compose -f testnet.yml up

Option B: Standalone (runs your own local network)

cd packages/cli && docker compose -f standalone.yml up

Ports:

  • Node: 9944
  • Indexer: 8088
  • Proof Server: 6300

6. Configure Wallet

  • Open Midnight Lace Wallet
  • Go to SettingsNetwork
  • Select:
    • TestNet for Option A
    • Undeployed for Option B (Standalone infrastructure)

7. Fund Wallet (Standalone only)

If using Standalone infrastructure, fund your wallet address:

  • Go to the cli folder:
cd packages/cli
  • Run the fund command to receive Midnight test tokens (tDUST), replace mn_shield-addr_undeployed... with your Undeployed network address:
yarn fund mn_shield-addr_undeployed...

8. Start Development Server

cd packages/ui && yarn start

Open http://localhost:8080 in your browser.

Root Scripts

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)

Project Structure

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)

Attribution

This project reuses and adapts components from upstream open-source work by Brick Towers.

In particular:

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.

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

Contributing

We welcome contributions! Please follow these guidelines:

  1. Fork the repository and create a feature branch
  2. Make your changes following the existing code style
  3. Test thoroughly - ensure all builds pass and the contract works as expected
  4. Submit a pull request with a clear description of your changes

MeshJS Logo × Socious Logo

Powered by MeshJS in partnership with Socious

Built with ❤️ on Midnight Network

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •