From 06b28a7c813524a37b3b299da8aa231ef0d403fe Mon Sep 17 00:00:00 2001 From: luislucena16 Date: Fri, 24 Oct 2025 21:56:14 +0200 Subject: [PATCH] chore: add complete midnight-contracts-wizard docs --- apps/docs/src/pages/en/packages/_meta.js | 8 + .../midnight_contracts_wizard/_meta.js | 23 +++ .../midnight_contracts_wizard/contracts.mdx | 136 ++++++++++++++++ .../midnight_contracts_wizard/index.mdx | 52 ++++++ .../installation.mdx | 48 ++++++ .../project_structure.mdx | 154 ++++++++++++++++++ .../midnight_contracts_wizard/usage.mdx | 84 ++++++++++ 7 files changed, 505 insertions(+) create mode 100644 apps/docs/src/pages/en/packages/midnight_contracts_wizard/_meta.js create mode 100644 apps/docs/src/pages/en/packages/midnight_contracts_wizard/contracts.mdx create mode 100644 apps/docs/src/pages/en/packages/midnight_contracts_wizard/index.mdx create mode 100644 apps/docs/src/pages/en/packages/midnight_contracts_wizard/installation.mdx create mode 100644 apps/docs/src/pages/en/packages/midnight_contracts_wizard/project_structure.mdx create mode 100644 apps/docs/src/pages/en/packages/midnight_contracts_wizard/usage.mdx diff --git a/apps/docs/src/pages/en/packages/_meta.js b/apps/docs/src/pages/en/packages/_meta.js index fea991b..b463901 100644 --- a/apps/docs/src/pages/en/packages/_meta.js +++ b/apps/docs/src/pages/en/packages/_meta.js @@ -1,4 +1,12 @@ export default { + "midnight_setup": { + title: "Midnight Setup", + route: "/midnight_setup", + }, + "midnight_contracts_wizard": { + title: "Contracts Wizard", + route: "/midnight_contracts_wizard", + }, "wallet_widget": { title: "Wallet Widget", route: "/wallet_widget", diff --git a/apps/docs/src/pages/en/packages/midnight_contracts_wizard/_meta.js b/apps/docs/src/pages/en/packages/midnight_contracts_wizard/_meta.js new file mode 100644 index 0000000..af713ec --- /dev/null +++ b/apps/docs/src/pages/en/packages/midnight_contracts_wizard/_meta.js @@ -0,0 +1,23 @@ +export default { + "index": { + title: "Introduction", + route: "/", + }, + "installation": { + title: "Installation", + route: "/installation", + }, + "usage": { + title: "Usage", + route: "/usage", + }, + "contracts": { + title: "Available Contracts", + route: "/contracts", + }, + "project_structure": { + title: "Project Structure", + route: "/project_structure", + }, +}; + diff --git a/apps/docs/src/pages/en/packages/midnight_contracts_wizard/contracts.mdx b/apps/docs/src/pages/en/packages/midnight_contracts_wizard/contracts.mdx new file mode 100644 index 0000000..5911605 --- /dev/null +++ b/apps/docs/src/pages/en/packages/midnight_contracts_wizard/contracts.mdx @@ -0,0 +1,136 @@ +--- +title: Available Contracts +description: Explore the smart contract templates available in the Midnight Contracts Wizard +--- + +# Available Contracts + +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](/en/packages/midnight_contracts_wizard/project_structure) that gets generated for your selected contracts. + diff --git a/apps/docs/src/pages/en/packages/midnight_contracts_wizard/index.mdx b/apps/docs/src/pages/en/packages/midnight_contracts_wizard/index.mdx new file mode 100644 index 0000000..c3e5b97 --- /dev/null +++ b/apps/docs/src/pages/en/packages/midnight_contracts_wizard/index.mdx @@ -0,0 +1,52 @@ +--- +title: Midnight Contracts Wizard +description: A CLI tool to create new Midnight contracts projects with selected smart contracts +asIndexPage: true +sidebarTitle: Contracts Wizard +--- + +# Midnight Contracts Wizard + +**A CLI tool to create new Midnight contracts projects with selected smart contracts.** + +## Overview + +The Midnight Contracts Wizard is an interactive command-line tool that helps you quickly scaffold new Midnight smart contract projects. With a simple interactive interface, you can select from multiple pre-built contract templates and generate a complete project structure ready for development. + +## What's Included + +- **Interactive CLI** - Select which contracts to include through an easy-to-use interface +- **Multiple Contract Types** - Choose from Tokenization, Staking, Identity, Oracle, and Lending & Borrowing contracts +- **Complete Setup** - Automatically generates package.json, tsconfig, and build scripts +- **Ready to Use** - All necessary files for compilation and build included +- **Self-Contained** - All contract templates included, no external dependencies required + +## Quick Installation + +- npm: +```bash +npm install @meshsdk/midnight-contracts-wizard +``` + +- yarn: +```bash +yarn add @meshsdk/midnight-contracts-wizard +``` + +## Getting Started + +1. **[Installation](/en/packages/midnight_contracts_wizard/installation)** - Install the CLI tool +2. **[Usage](/en/packages/midnight_contracts_wizard/usage)** - Learn how to use the interactive wizard +3. **[Available Contracts](/en/packages/midnight_contracts_wizard/contracts)** - Explore the contract templates +4. **[Project Structure](/en/packages/midnight_contracts_wizard/project_structure)** - Understanding generated projects + +## Key Features + +- **Zero-knowledge contracts** - Pre-built ZK circuit implementations +- **Privacy-focused** - All contracts designed with privacy in mind +- **Production-ready** - Battle-tested contract templates +- **TypeScript support** - Full type safety and IntelliSense +- **Quick setup** - Get started in minutes + +Start building your Midnight smart contracts today! Explore the sections below to get started. + diff --git a/apps/docs/src/pages/en/packages/midnight_contracts_wizard/installation.mdx b/apps/docs/src/pages/en/packages/midnight_contracts_wizard/installation.mdx new file mode 100644 index 0000000..ab8c576 --- /dev/null +++ b/apps/docs/src/pages/en/packages/midnight_contracts_wizard/installation.mdx @@ -0,0 +1,48 @@ +--- +title: Installation +description: How to install the Midnight Contracts Wizard CLI tool +--- + +# Installation + +Install the Midnight Contracts Wizard globally or as a project dependency. + +## Global Installation + +Install globally to use the wizard from anywhere: + +```bash +npm install -g @meshsdk/midnight-contracts-wizard +``` + +## Project Installation + +Install as a project dependency: + +```bash +npm install @meshsdk/midnight-contracts-wizard +``` + +Or with yarn: + +```bash +yarn add @meshsdk/midnight-contracts-wizard +``` + +## Verify Installation + +After installation, verify that the wizard is available: + +```bash +npx @meshsdk/midnight-contracts-wizard --version +``` + +## Requirements + +- **Node.js**: Version 18 or higher +- **npm**: Version 8 or higher (or yarn equivalent) + +## Next Steps + +Once installed, proceed to the [Usage](/en/packages/midnight_contracts_wizard/usage) section to learn how to create your first project. + diff --git a/apps/docs/src/pages/en/packages/midnight_contracts_wizard/project_structure.mdx b/apps/docs/src/pages/en/packages/midnight_contracts_wizard/project_structure.mdx new file mode 100644 index 0000000..f83ba6f --- /dev/null +++ b/apps/docs/src/pages/en/packages/midnight_contracts_wizard/project_structure.mdx @@ -0,0 +1,154 @@ +--- +title: Project Structure +description: Understanding the generated project structure +--- + +# Generated Project 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` + +```compact +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 + + diff --git a/apps/docs/src/pages/en/packages/midnight_contracts_wizard/usage.mdx b/apps/docs/src/pages/en/packages/midnight_contracts_wizard/usage.mdx new file mode 100644 index 0000000..abbdea6 --- /dev/null +++ b/apps/docs/src/pages/en/packages/midnight_contracts_wizard/usage.mdx @@ -0,0 +1,84 @@ +--- +title: Usage +description: Learn how to use the Midnight Contracts Wizard CLI tool +--- + +# Usage + +The Midnight Contracts Wizard provides an interactive command-line interface to scaffold new contract projects. + +## Basic Usage + +Run the wizard using npx (no installation required): + +```bash +npx @meshsdk/midnight-contracts-wizard +``` + +## Interactive Mode + +When you run the wizard, it will guide you through an interactive setup: + +1. **Project Name** - Enter a name for your new project +2. **Select Contracts** - Choose which contract templates to include: + - Tokenization Contract + - Staking Contract + - Identity Contracts + - Oracle Contract + - Lending & Borrowing Contract +3. **Confirmation** - Review your selections and confirm + +## Example Session + +```bash +$ npx @meshsdk/midnight-contracts-wizard + +Welcome to Midnight Contracts Wizard! +? Enter your project name: my-midnight-contracts +? Select contracts to include: (Use arrow keys and space to select) + ◉ Tokenization Contract (7 ZK circuits) + ◯ Staking Contract (8 ZK circuits) + ◉ Identity Contracts (1 ZK circuit) + ◯ Oracle Contract (7 ZK circuits) + ◯ Lending & Borrowing Contract (7 ZK circuits) + +✓ Project created successfully! +✓ Tokenization contract added +✓ Identity contracts added + +📋 Next steps: +1) Navigate to the project folder: + cd ./my-midnight-contracts + +2) Compile your smart contracts: + compact compile contracts/tokenization/tokenization.compact ./src/managed/tokenization + + compact compile contracts/identity/identity.compact ./src/managed/identity + +💡 Your contracts will be compiled to `src/managed/` +💡 Check the `README.md` for detailed instructions +``` + +## Command Options + +### Help + +Display help information: + +```bash +npx @meshsdk/midnight-contracts-wizard --help +``` + +### Version + +Check the installed version: + +```bash +npx @meshsdk/midnight-contracts-wizard --version +``` + +## Next Steps + +- Explore [Available Contracts](/en/packages/midnight_contracts_wizard/contracts) to understand each contract type +- Review [Project Structure](/en/packages/midnight_contracts_wizard/project_structure) to learn about generated files +