Skip to content

Commit 07afc78

Browse files
Merge pull request #69 from luislucena16/feature/add-midnight-contracts-wizard-docs
feat: add midnight contracts wizard docs and improve midnight setup
2 parents fc6740a + 4b2012b commit 07afc78

File tree

14 files changed

+487
-1
lines changed

14 files changed

+487
-1
lines changed
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
22
"title": "Midnight",
3-
"pages": ["midnight-setup"]
3+
"pages": [
4+
"midnight-setup",
5+
"midnight-contracts-wizard"
6+
]
47
}
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
---
2+
title: Available Contracts
3+
description: Explore the smart contract templates available in the Midnight Contracts Wizard
4+
icon: DocumentTextIcon
5+
---
6+
7+
The Midnight Contracts Wizard includes several production-ready smart contract templates. Each contract is designed with privacy and zero-knowledge proofs in mind.
8+
9+
## Tokenization Contract
10+
11+
**7 ZK Circuits**
12+
13+
A complete project tokenization system with zero-knowledge privacy for investments.
14+
15+
### Features
16+
- Private token minting and burning
17+
- Confidential balance management
18+
- Investment tracking with ZK proofs
19+
- Transfer with privacy guarantees
20+
21+
### Use Cases
22+
- Real estate tokenization
23+
- Asset-backed securities
24+
- Private equity tracking
25+
- Confidential fundraising
26+
27+
---
28+
29+
## Staking Contract
30+
31+
**8 ZK Circuits**
32+
33+
A privacy-focused staking system with rewards and configurable lock periods.
34+
35+
### Features
36+
- Private stake amounts
37+
- Confidential reward distribution
38+
- Flexible lock periods
39+
- Slashing mechanisms
40+
41+
### Use Cases
42+
- Network validation
43+
- Governance participation
44+
- Yield generation
45+
- Long-term holding incentives
46+
47+
---
48+
49+
## Identity Contracts
50+
51+
**1 ZK Circuit**
52+
53+
Complete identity management system with cryptographic libraries for privacy-preserving verification.
54+
55+
### Features
56+
- Zero-knowledge identity proofs
57+
- Selective disclosure
58+
- Credential verification
59+
- Privacy-preserving authentication
60+
61+
### Use Cases
62+
- KYC compliance
63+
- Age verification
64+
- Credential validation
65+
- Access control
66+
67+
---
68+
69+
## Oracle Contract
70+
71+
**7 ZK Circuits**
72+
73+
Decentralized oracle system with privacy-preserving data feeds.
74+
75+
### Features
76+
- Confidential data ingestion
77+
- Multi-source aggregation
78+
- Tamper-proof feeds
79+
- Privacy-preserving validation
80+
81+
### Use Cases
82+
- Price feeds
83+
- Weather data
84+
- Sports results
85+
- IoT data streams
86+
87+
---
88+
89+
## Lending & Borrowing Contract
90+
91+
**7 ZK Circuits**
92+
93+
Privacy-preserving decentralized lending protocol.
94+
95+
### Features
96+
- Confidential collateral management
97+
- Private loan amounts
98+
- Interest rate privacy
99+
- Liquidation with ZK proofs
100+
101+
### Use Cases
102+
- DeFi lending platforms
103+
- Peer-to-peer lending
104+
- Collateralized loans
105+
- Credit lines
106+
107+
---
108+
109+
## Contract Selection Tips
110+
111+
### Single Contract Projects
112+
Perfect for focused applications or proof-of-concepts. Select one contract type and build a specialized solution.
113+
114+
### Multi-Contract Projects
115+
Combine multiple contracts for complex dApps. For example:
116+
- **Tokenization + Oracle** - Real-world asset pricing
117+
- **Staking + Identity** - Governance with verified participants
118+
- **Lending + Oracle** - Price-aware DeFi protocols
119+
120+
### All Contracts
121+
Select all contracts to explore the full ecosystem or build a comprehensive platform.
122+
123+
## Technical Details
124+
125+
Each contract includes:
126+
- Complete `.compact` source files
127+
- Compiled TypeScript interfaces
128+
- ZK circuit configurations
129+
- Build and deployment scripts
130+
- Example usage documentation
131+
132+
## Next Steps
133+
134+
Learn about the [Project Structure](/midnight/midnight-contracts-wizard/project-structure) that gets generated for your selected contracts.
135+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
title: Overview
3+
description: A CLI tool to create new Midnight contracts projects with selected smart contracts
4+
icon: SparklesIcon
5+
---
6+
7+
import {linksMidnightContractsWizard} from "@/data/links-midnight";
8+
import Link from "next/link";
9+
import {
10+
Card,
11+
CardDescription,
12+
CardTitle,
13+
} from "@/components/ui/card";
14+
15+
<div className="grid md:grid-cols-2 gap-6 items-stretch">
16+
{linksMidnightContractsWizard.map((card) => (
17+
<Link key={card.title} href={card.link} className="no-underline">
18+
<Card className="h-full text-center hover:border-primary/50 transition-colors px-4 py-8">
19+
<CardTitle className="font-heading">{card.title}</CardTitle>
20+
<CardDescription>{card.desc}</CardDescription>
21+
</Card>
22+
</Link>
23+
))}
24+
</div>
25+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: Installation
3+
description: How to use the Midnight Contracts Wizard CLI tool
4+
icon: ArrowDownTrayIcon
5+
---
6+
7+
The Midnight Contracts Wizard is a CLI tool that you can run directly using `npx`. No installation required!
8+
9+
## Using npx (Recommended)
10+
11+
Run the wizard directly without installing:
12+
13+
```bash
14+
npx @meshsdk/midnight-contracts-wizard
15+
```
16+
17+
This command will:
18+
- Download the latest version automatically
19+
- Run the interactive wizard
20+
- Create your project with selected contracts
21+
22+
## Check Version
23+
24+
You can check the latest version available:
25+
26+
```bash
27+
npx @meshsdk/midnight-contracts-wizard --version
28+
```
29+
30+
## Requirements
31+
32+
- **Node.js**: Version 18 or higher
33+
- **npm**: Version 8 or higher (includes npx)
34+
35+
## Next Steps
36+
37+
Once you're ready, proceed to the [Usage](/midnight/midnight-contracts-wizard/usage) section to learn how to create your first project.
38+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"title": "Midnight Contracts Wizard",
3+
"icon": "BoltIcon",
4+
"pages": ["index", "installation", "usage", "contracts", "project-structure"]
5+
}
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
---
2+
title: Project Structure
3+
description: Understanding the generated project structure
4+
icon: FolderIcon
5+
---
6+
7+
# Generated Structure
8+
9+
When you create a project using the Midnight Contracts Wizard, it generates a complete directory structure with all necessary files.
10+
11+
## Directory Layout
12+
13+
```
14+
my-project/
15+
├── src/
16+
│ ├── [selected-contracts]/
17+
│ │ └── *.compact
18+
│ └── managed/ # Compiled contracts
19+
├── dist/ # Distribution files
20+
├── package.json
21+
├── tsconfig.json
22+
├── tsconfig.build.json
23+
└── README.md
24+
```
25+
26+
## Directory Breakdown
27+
28+
### `/src`
29+
30+
Contains all your contract source files.
31+
32+
```
33+
src/
34+
├── tokenization/ # If selected
35+
│ └── token.compact
36+
├── staking/ # If selected
37+
│ └── staking.compact
38+
├── identity/ # If selected
39+
│ └── identity.compact
40+
├── oracle/ # If selected
41+
│ └── oracle.compact
42+
├── lending/ # If selected
43+
│ └── lending.compact
44+
└── managed/ # Auto-generated
45+
└── *.ts # Compiled TypeScript
46+
```
47+
48+
### `/src/managed`
49+
50+
Automatically generated directory containing compiled TypeScript files from your `.compact` contracts. **Do not edit manually** - these files are regenerated on each build.
51+
52+
### `/dist`
53+
54+
Output directory for the final compiled JavaScript and type definitions, ready for distribution or deployment.
55+
56+
## Configuration Files
57+
58+
### `package.json`
59+
60+
Contains project metadata, dependencies, and build scripts:
61+
62+
```json
63+
{
64+
"name": "my-project",
65+
"version": "1.0.0",
66+
"scripts": {
67+
"build": "tsc -p tsconfig.build.json",
68+
"compile": "compact-cli compile src/**/*.compact",
69+
"clean": "rm -rf dist src/managed"
70+
},
71+
"dependencies": {
72+
"@midnight-ntwrk/compact-runtime": "^0.8.1",
73+
"@midnight-ntwrk/midnight-js-types": "^2.0.2"
74+
}
75+
}
76+
```
77+
78+
### `tsconfig.json`
79+
80+
Main TypeScript configuration for development:
81+
82+
```json
83+
{
84+
"compilerOptions": {
85+
"target": "ES2020",
86+
"module": "commonjs",
87+
"lib": ["ES2020"],
88+
"strict": true,
89+
"esModuleInterop": true,
90+
"skipLibCheck": true,
91+
"forceConsistentCasingInFileNames": true,
92+
"outDir": "./dist",
93+
"rootDir": "./src"
94+
},
95+
"include": ["src/**/*"],
96+
"exclude": ["node_modules", "dist"]
97+
}
98+
```
99+
100+
### `tsconfig.build.json`
101+
102+
Extends main config for production builds:
103+
104+
```json
105+
{
106+
"extends": "./tsconfig.json",
107+
"compilerOptions": {
108+
"declaration": true,
109+
"declarationMap": true,
110+
"sourceMap": true
111+
},
112+
"exclude": ["**/*.test.ts", "**/*.spec.ts"]
113+
}
114+
```
115+
116+
## Contract Files
117+
118+
Each selected contract includes its `.compact` source file:
119+
120+
### Example: `src/tokenization/token.compact`
121+
122+
```text
123+
contract Token {
124+
// ZK circuit implementations
125+
circuit mint(amount: Secret) -> Public {
126+
// Minting logic
127+
}
128+
129+
circuit transfer(to: Address, amount: Secret) -> Public {
130+
// Transfer logic
131+
}
132+
133+
// Additional circuits...
134+
}
135+
```
136+
137+
## README.md
138+
139+
Each generated project includes a comprehensive README with:
140+
- Project overview
141+
- Installation instructions
142+
- Build commands
143+
- Contract descriptions
144+
- Usage examples
145+
- Deployment guide
146+
147+
## Next Steps
148+
149+
Now that you understand the project structure:
150+
- Start modifying contracts in `src/`
151+
- Run builds with `npm run build`
152+
- Integrate with your dApp
153+
- Deploy to Midnight Network
154+
155+

0 commit comments

Comments
 (0)