A collection of ready-to-use smart contracts for the Midnight network, with complete documentation, NatSpec, automated compilation and build configuration.
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
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
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
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
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
- 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
- Node.js (v18 or higher)
- Yarn
- Midnight Compact compiler
-
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- 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- Full project build (api, cli, contract, ui)
i) Go to the midnight-contracts-wizard folder:
cd ../../ii) Build all folders:
yarn build:allmidnight-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
- 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
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
Powered by MeshJS Team
Built with ❤️ on Midnight Network