Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion apps/docs/content/docs/midnight/meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"title": "Midnight",
"pages": ["midnight-setup"]
"pages": [
"midnight-setup",
"midnight-contracts-wizard"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
---
title: Available Contracts
description: Explore the smart contract templates available in the Midnight Contracts Wizard
icon: DocumentTextIcon
---

The Midnight Contracts Wizard includes several production-ready smart contract templates. Each contract is designed with privacy and zero-knowledge proofs in mind.

## Tokenization Contract

**7 ZK Circuits**

A complete project tokenization system with zero-knowledge privacy for investments.

### Features
- Private token minting and burning
- Confidential balance management
- Investment tracking with ZK proofs
- Transfer with privacy guarantees

### Use Cases
- Real estate tokenization
- Asset-backed securities
- Private equity tracking
- Confidential fundraising

---

## Staking Contract

**8 ZK Circuits**

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

### Features
- Private stake amounts
- Confidential reward distribution
- Flexible lock periods
- Slashing mechanisms

### Use Cases
- Network validation
- Governance participation
- Yield generation
- Long-term holding incentives

---

## Identity Contracts

**1 ZK Circuit**

Complete identity management system with cryptographic libraries for privacy-preserving verification.

### Features
- Zero-knowledge identity proofs
- Selective disclosure
- Credential verification
- Privacy-preserving authentication

### Use Cases
- KYC compliance
- Age verification
- Credential validation
- Access control

---

## Oracle Contract

**7 ZK Circuits**

Decentralized oracle system with privacy-preserving data feeds.

### Features
- Confidential data ingestion
- Multi-source aggregation
- Tamper-proof feeds
- Privacy-preserving validation

### Use Cases
- Price feeds
- Weather data
- Sports results
- IoT data streams

---

## Lending & Borrowing Contract

**7 ZK Circuits**

Privacy-preserving decentralized lending protocol.

### Features
- Confidential collateral management
- Private loan amounts
- Interest rate privacy
- Liquidation with ZK proofs

### Use Cases
- DeFi lending platforms
- Peer-to-peer lending
- Collateralized loans
- Credit lines

---

## Contract Selection Tips

### Single Contract Projects
Perfect for focused applications or proof-of-concepts. Select one contract type and build a specialized solution.

### Multi-Contract Projects
Combine multiple contracts for complex dApps. For example:
- **Tokenization + Oracle** - Real-world asset pricing
- **Staking + Identity** - Governance with verified participants
- **Lending + Oracle** - Price-aware DeFi protocols

### All Contracts
Select all contracts to explore the full ecosystem or build a comprehensive platform.

## Technical Details

Each contract includes:
- Complete `.compact` source files
- Compiled TypeScript interfaces
- ZK circuit configurations
- Build and deployment scripts
- Example usage documentation

## Next Steps

Learn about the [Project Structure](/midnight/midnight-contracts-wizard/project-structure) that gets generated for your selected contracts.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: Overview
description: A CLI tool to create new Midnight contracts projects with selected smart contracts
icon: SparklesIcon
---

import {linksMidnightContractsWizard} from "@/data/links-midnight";
import Link from "next/link";
import {
Card,
CardDescription,
CardTitle,
} from "@/components/ui/card";

<div className="grid md:grid-cols-2 gap-6 items-stretch">
{linksMidnightContractsWizard.map((card) => (
<Link key={card.title} href={card.link} className="no-underline">
<Card className="h-full text-center hover:border-primary/50 transition-colors px-4 py-8">
<CardTitle className="font-heading">{card.title}</CardTitle>
<CardDescription>{card.desc}</CardDescription>
</Card>
</Link>
))}
</div>

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: Installation
description: How to use the Midnight Contracts Wizard CLI tool
icon: ArrowDownTrayIcon
---

The Midnight Contracts Wizard is a CLI tool that you can run directly using `npx`. No installation required!

## Using npx (Recommended)

Run the wizard directly without installing:

```bash
npx @meshsdk/midnight-contracts-wizard
```

This command will:
- Download the latest version automatically
- Run the interactive wizard
- Create your project with selected contracts

## Check Version

You can check the latest version available:

```bash
npx @meshsdk/midnight-contracts-wizard --version
```

## Requirements

- **Node.js**: Version 18 or higher
- **npm**: Version 8 or higher (includes npx)

## Next Steps

Once you're ready, proceed to the [Usage](/midnight/midnight-contracts-wizard/usage) section to learn how to create your first project.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"title": "Midnight Contracts Wizard",
"icon": "BoltIcon",
"pages": ["index", "installation", "usage", "contracts", "project-structure"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
---
title: Project Structure
description: Understanding the generated project structure
icon: FolderIcon
---

# Generated Structure

When you create a project using the Midnight Contracts Wizard, it generates a complete directory structure with all necessary files.

## Directory Layout

```
my-project/
├── src/
│ ├── [selected-contracts]/
│ │ └── *.compact
│ └── managed/ # Compiled contracts
├── dist/ # Distribution files
├── package.json
├── tsconfig.json
├── tsconfig.build.json
└── README.md
```

## Directory Breakdown

### `/src`

Contains all your contract source files.

```
src/
├── tokenization/ # If selected
│ └── token.compact
├── staking/ # If selected
│ └── staking.compact
├── identity/ # If selected
│ └── identity.compact
├── oracle/ # If selected
│ └── oracle.compact
├── lending/ # If selected
│ └── lending.compact
└── managed/ # Auto-generated
└── *.ts # Compiled TypeScript
```

### `/src/managed`

Automatically generated directory containing compiled TypeScript files from your `.compact` contracts. **Do not edit manually** - these files are regenerated on each build.

### `/dist`

Output directory for the final compiled JavaScript and type definitions, ready for distribution or deployment.

## Configuration Files

### `package.json`

Contains project metadata, dependencies, and build scripts:

```json
{
"name": "my-project",
"version": "1.0.0",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"compile": "compact-cli compile src/**/*.compact",
"clean": "rm -rf dist src/managed"
},
"dependencies": {
"@midnight-ntwrk/compact-runtime": "^0.8.1",
"@midnight-ntwrk/midnight-js-types": "^2.0.2"
}
}
```

### `tsconfig.json`

Main TypeScript configuration for development:

```json
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"lib": ["ES2020"],
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
```

### `tsconfig.build.json`

Extends main config for production builds:

```json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"sourceMap": true
},
"exclude": ["**/*.test.ts", "**/*.spec.ts"]
}
```

## Contract Files

Each selected contract includes its `.compact` source file:

### Example: `src/tokenization/token.compact`

```text
contract Token {
// ZK circuit implementations
circuit mint(amount: Secret) -> Public {
// Minting logic
}

circuit transfer(to: Address, amount: Secret) -> Public {
// Transfer logic
}

// Additional circuits...
}
```

## README.md

Each generated project includes a comprehensive README with:
- Project overview
- Installation instructions
- Build commands
- Contract descriptions
- Usage examples
- Deployment guide

## Next Steps

Now that you understand the project structure:
- Start modifying contracts in `src/`
- Run builds with `npm run build`
- Integrate with your dApp
- Deploy to Midnight Network


Loading
Loading