Skip to content

MeshJS/midnight-contracts-wizard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Midnight Contracts Wizard

A collection of ready-to-use smart contracts for the Midnight network, with complete documentation, NatSpec, automated compilation and build configuration.

Included Contracts

Tokenization Contract

Complete project tokenization system with:

  • Project creation and management
  • ZK privacy investment system
  • Fund management and refunds
  • Access control and permissions
  • 7 ZK circuits: cancelProject, createProject, endProject, investProject, requestRefund, updateProject, withdrawProjectFunds

Staking Contract

Privacy-focused staking system with rewards:

  • Private token staking
  • Automatic reward calculation
  • Configurable lock periods
  • Balance and state management
  • 8 ZK circuits: claimRewards, queryRewards, queryStake, queryStatus, stake, unstake, updateLockPeriod, updateRewardRate

Identity Contracts

Complete identity management system with cryptographic libraries:

  • Identity verification and registration
  • Cryptographic signature operations
  • Credential management and validation
  • Privacy-preserving identity proofs
  • 1 ZK circuit: register (from registry contract)
  • Libraries: IdentityLibrary, CryptoLibrary for cryptographic operations

Oracle Contract

Decentralized oracle system with privacy-preserving data feeds:

  • Trusted oracle data submission and verification
  • Cryptographic signature verification for data integrity
  • Privacy-preserving data access and validation
  • Collateral ratio verification without revealing amounts
  • Auditor access controls for compliance oversight
  • 7 ZK circuits: registerOperator, submitOracleData, getOracleData, verifyOracleCondition, checkCollateralRatio, registerAuditor, discloseToAuditor, updateValue

Lending & Borrowing Contract

Privacy-preserving decentralized lending protocol:

  • Anonymous collateral deposits and borrowing
  • Private supply positions for lenders
  • Automated liquidation mechanisms
  • Dynamic interest rate calculations
  • Privacy-preserving debt management
  • 7 ZK circuits: depositCollateral, borrow, liquidatePosition, repayDebt, withdrawCollateral, supplyToPool, calculateInterestRate

Features

  • Complete NatSpec documentation - Every function and variable documented
  • Automated compilation - Scripts configured to compile all contracts
  • Integrated build system - Ready for distribution
  • ZK Privacy - All operations are private using zero-knowledge proofs
  • Multi-contract configuration - Support for multiple contracts in the same project
  • Multi-call configuration - Call multiple contracts sharing logic

Installation and Setup

Prerequisites

Project Installation

  • i) Clone the repository

  • using https:

git clone https://github.com/MeshJS/midnight-contracts-wizard.git
  • using ssh:
git clone [email protected]:MeshJS/midnight-contracts-wizard.git
  • ii) Navigate to the project folder
cd midnight-contracts-wizard
  • iii) Install dependencies
yarn install
  • iv) Download ZK parameters
cd packages/cli && ./fetch-zk-params.sh

Available Commands

Compilation

  • i) Navigate to the contract folder:
cd ../contract/
  • ii) Compile all contracts:
yarn compact
  • iii) Compile specified contract (e.g tokenization):
compact compile src/tokenization/tokenization.compact ./src/managed/tokenization

Build All Packages

  • Full project build (api, cli, contract, ui)

i) Go to the midnight-contracts-wizard folder:

cd ../../

ii) Build all folders:

yarn build:all

Project Structure

midnight-contracts-wizard/
├── packages/
│   ├── contract/                 # Smart contracts
│   │   ├── src/
│   │   │   ├── tokenization/     # Tokenization contract
│   │   │   │   ├── tokenization.compact
│   │   │   │   └── TokenizationLibrary.compact
│   │   │   ├── staking/          # Staking contract
│   │   │   │   └── staking.compact
│   │   │   ├── identity/         # Identity contracts
│   │   │   │   ├── IdentityLibrary.compact
│   │   │   │   ├── registry.compact
│   │   │   │   └── CryptoLibrary.compact
│   │   │   ├── oracle/           # Oracle contract
│   │   │   │   └── oracle.compact
│   │   │   ├── lending-borrowing/ # Lending & Borrowing contract
│   │   │   │   └── lending-borrowing.compact
│   │   │   └── managed/          # Compiled contracts
│   │   └── dist/                 # Distribution
│   ├── ui/                       # Web interface
│   ├── cli/                      # Command line tools
│   └── api/                      # API and TypeScript types
├── docs/                         # Additional documentation
└── README.md

Security and Privacy

  • ZK Privacy: All operations use zero-knowledge proofs
  • Security documentation: Each contract includes security comments
  • Input validation: Robust validations in all functions
  • Access control: Integrated permission system

Documentation

Each contract includes complete NatSpec documentation with:

  • @title: Contract title
  • @dev: Technical information for developers
  • @notice: Information for end users
  • @param: Parameter documentation
  • @return: Return value documentation

MeshJS Logo Powered by MeshJS Team

Built with ❤️ on Midnight Network

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks