Mesh LogoMesh
MidnightMidnight Contracts Wizard

Available Contracts

Explore the zero-knowledge smart contract templates in the Midnight Contracts Wizard

The Midnight Contracts Wizard includes five production-ready smart contract templates. Each template provides complete functionality with privacy-preserving zero-knowledge circuits built in.

Contract overview

ContractZK CircuitsPrimary use case
Tokenization7Asset tokenization, private investments
Staking8Rewards, governance participation
Identity1Credential verification, access control
Oracle7External data feeds, price oracles
Lending7DeFi protocols, collateralized loans

Tokenization Contract

7 ZK Circuits

A complete asset tokenization system with zero-knowledge privacy for investments and ownership tracking.

Features

FeatureDescription
Private mintingCreate tokens without revealing amounts
Confidential balancesHide holder balances from public view
Private transfersMove tokens without exposing transaction details
Investment trackingTrack investments with ZK proofs

Use cases

  • Real estate tokenization - Fractional property ownership with private holdings
  • Securities issuance - Confidential cap table management
  • Private equity - Track investments without public disclosure
  • Fundraising - Accept contributions with privacy guarantees

Example usage

import { TokenizationContract } from './managed/tokenization';
import { MidnightSetupAPI } from '@meshsdk/midnight-setup';

const contract = new TokenizationContract({
  name: "Property Token",
  symbol: "PROP",
  totalSupply: 1000000
});

const api = await MidnightSetupAPI.deployContract(providers, contract);

Staking Contract

8 ZK Circuits

A privacy-focused staking system with configurable rewards and lock periods.

Features

FeatureDescription
Private stake amountsHide how much each user stakes
Confidential rewardsDistribute rewards privately
Flexible lock periodsConfigure custom staking durations
Slashing mechanismsPenalize bad actors with ZK verification

Use cases

  • Network validation - Stake to participate in consensus
  • Governance - Voting power based on private stake
  • Yield generation - Earn rewards on locked assets
  • Long-term incentives - Reward committed participants

Example usage

import { StakingContract } from './managed/staking';
import { MidnightSetupAPI } from '@meshsdk/midnight-setup';

const contract = new StakingContract({
  rewardRate: 0.05, // 5% annual
  lockPeriod: 30 * 24 * 60 * 60 // 30 days in seconds
});

const api = await MidnightSetupAPI.deployContract(providers, contract);

Identity Contract

1 ZK Circuit

A complete identity management system for privacy-preserving credential verification.

Features

FeatureDescription
Zero-knowledge proofsProve attributes without revealing data
Selective disclosureShare only what you choose
Credential verificationValidate credentials privately
Access controlGrant permissions based on verified attributes

Use cases

  • KYC compliance - Verify identity without storing personal data
  • Age verification - Prove age without revealing birthdate
  • Credential validation - Check qualifications privately
  • Gated access - Control access based on verified attributes

Example usage

import { IdentityContract } from './managed/identity';
import { MidnightSetupAPI } from '@meshsdk/midnight-setup';

const contract = new IdentityContract({
  issuer: "trusted-issuer-address",
  requiredAttributes: ["over18", "verified"]
});

const api = await MidnightSetupAPI.deployContract(providers, contract);

Oracle Contract

7 ZK Circuits

A decentralized oracle system with privacy-preserving data feeds.

Features

FeatureDescription
Confidential data ingestionIngest data without public exposure
Multi-source aggregationCombine data from multiple sources
Tamper-proof feedsEnsure data integrity with ZK proofs
Private validationVerify data quality without revealing sources

Use cases

  • Price feeds - Private asset pricing for DeFi
  • Weather data - Confidential environmental data
  • Sports results - Private outcome verification
  • IoT streams - Secure sensor data ingestion

Example usage

import { OracleContract } from './managed/oracle';
import { MidnightSetupAPI } from '@meshsdk/midnight-setup';

const contract = new OracleContract({
  feedId: "BTC-USD",
  updateInterval: 60, // seconds
  minSources: 3
});

const api = await MidnightSetupAPI.deployContract(providers, contract);

Lending Contract

7 ZK Circuits

A privacy-preserving decentralized lending protocol.

Features

FeatureDescription
Confidential collateralHide collateral amounts
Private loan amountsKeep borrowed amounts private
Interest rate privacyCalculate interest without exposure
ZK liquidationVerify liquidation conditions privately

Use cases

  • DeFi lending platforms - Build private lending pools
  • Peer-to-peer lending - Connect lenders and borrowers privately
  • Collateralized loans - Secure loans with hidden collateral
  • Credit lines - Establish private credit facilities

Example usage

import { LendingContract } from './managed/lending';
import { MidnightSetupAPI } from '@meshsdk/midnight-setup';

const contract = new LendingContract({
  collateralRatio: 150, // 150% collateralization
  interestRate: 0.08, // 8% annual
  liquidationThreshold: 120 // liquidate at 120%
});

const api = await MidnightSetupAPI.deployContract(providers, contract);

Combining contracts

You can select multiple contracts to build comprehensive applications.

DeFi platform example

Combine Tokenization + Oracle + Lending for a complete DeFi platform:

npx @meshsdk/midnight-contracts-wizard

? Select contracts to include:
  [x] Tokenization Contract
  [x] Oracle Contract
  [x] Lending & Borrowing Contract

This combination enables:

  • Issue tokens representing assets
  • Get real-time price feeds
  • Enable collateralized borrowing

Governance example

Combine Staking + Identity for verified governance:

npx @meshsdk/midnight-contracts-wizard

? Select contracts to include:
  [x] Staking Contract
  [x] Identity Contracts

This combination enables:

  • Stake tokens for voting power
  • Verify voter eligibility
  • Private vote counting

Technical details

Each contract template includes:

ComponentDescription
.compact sourceComplete Compact contract code
ZK circuitsPre-configured zero-knowledge circuits
TypeScript interfacesType definitions for integration
Build scriptsCompilation and deployment helpers

Next steps

On this page