diff --git a/apps/docs/content/docs/midnight/meta.json b/apps/docs/content/docs/midnight/meta.json index bfeddad..b22404d 100644 --- a/apps/docs/content/docs/midnight/meta.json +++ b/apps/docs/content/docs/midnight/meta.json @@ -1,4 +1,7 @@ { "title": "Midnight", - "pages": ["midnight-setup"] + "pages": [ + "midnight-setup", + "midnight-contracts-wizard" + ] } diff --git a/apps/docs/content/docs/midnight/midnight-contracts-wizard/contracts.mdx b/apps/docs/content/docs/midnight/midnight-contracts-wizard/contracts.mdx new file mode 100644 index 0000000..62b4a13 --- /dev/null +++ b/apps/docs/content/docs/midnight/midnight-contracts-wizard/contracts.mdx @@ -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. + diff --git a/apps/docs/content/docs/midnight/midnight-contracts-wizard/index.mdx b/apps/docs/content/docs/midnight/midnight-contracts-wizard/index.mdx new file mode 100644 index 0000000..93f1123 --- /dev/null +++ b/apps/docs/content/docs/midnight/midnight-contracts-wizard/index.mdx @@ -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"; + +
+ {linksMidnightContractsWizard.map((card) => ( + + + {card.title} + {card.desc} + + + ))} +
+ diff --git a/apps/docs/content/docs/midnight/midnight-contracts-wizard/installation.mdx b/apps/docs/content/docs/midnight/midnight-contracts-wizard/installation.mdx new file mode 100644 index 0000000..01f1f27 --- /dev/null +++ b/apps/docs/content/docs/midnight/midnight-contracts-wizard/installation.mdx @@ -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. + diff --git a/apps/docs/content/docs/midnight/midnight-contracts-wizard/meta.json b/apps/docs/content/docs/midnight/midnight-contracts-wizard/meta.json new file mode 100644 index 0000000..d1d88ce --- /dev/null +++ b/apps/docs/content/docs/midnight/midnight-contracts-wizard/meta.json @@ -0,0 +1,5 @@ +{ + "title": "Midnight Contracts Wizard", + "icon": "BoltIcon", + "pages": ["index", "installation", "usage", "contracts", "project-structure"] +} diff --git a/apps/docs/content/docs/midnight/midnight-contracts-wizard/project-structure.mdx b/apps/docs/content/docs/midnight/midnight-contracts-wizard/project-structure.mdx new file mode 100644 index 0000000..4c2091b --- /dev/null +++ b/apps/docs/content/docs/midnight/midnight-contracts-wizard/project-structure.mdx @@ -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 + + diff --git a/apps/docs/content/docs/midnight/midnight-contracts-wizard/usage.mdx b/apps/docs/content/docs/midnight/midnight-contracts-wizard/usage.mdx new file mode 100644 index 0000000..2b02718 --- /dev/null +++ b/apps/docs/content/docs/midnight/midnight-contracts-wizard/usage.mdx @@ -0,0 +1,81 @@ +--- +title: Usage +description: Learn how to use the Midnight Contracts Wizard CLI tool +icon: CommandLineIcon +--- + +## 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](/midnight/midnight-contracts-wizard/contracts) to understand each contract type +- Review [Project Structure](/midnight/midnight-contracts-wizard/project-structure) to learn about generated files + diff --git a/apps/docs/content/docs/midnight/midnight-setup/api.mdx b/apps/docs/content/docs/midnight/midnight-setup/api.mdx index e997205..60bef9d 100644 --- a/apps/docs/content/docs/midnight/midnight-setup/api.mdx +++ b/apps/docs/content/docs/midnight/midnight-setup/api.mdx @@ -1,6 +1,7 @@ --- title: "Core API Methods" description: "Complete reference for MidnightSetupAPI methods and provider setup" +icon: CodeBracketIcon --- import Link from "fumadocs-core/link"; diff --git a/apps/docs/content/docs/midnight/midnight-setup/examples.mdx b/apps/docs/content/docs/midnight/midnight-setup/examples.mdx index 22cbc99..c6fd9bc 100644 --- a/apps/docs/content/docs/midnight/midnight-setup/examples.mdx +++ b/apps/docs/content/docs/midnight/midnight-setup/examples.mdx @@ -1,6 +1,7 @@ --- title: "Integration Examples" description: "The fastest way to build on Midnight Network with pre-built smart contracts, complete API, and ready-to-use code snippets" +icon: BeakerIcon --- import Link from "fumadocs-core/link"; diff --git a/apps/docs/content/docs/midnight/midnight-setup/getting-started.mdx b/apps/docs/content/docs/midnight/midnight-setup/getting-started.mdx index 57171e6..9e266de 100644 --- a/apps/docs/content/docs/midnight/midnight-setup/getting-started.mdx +++ b/apps/docs/content/docs/midnight/midnight-setup/getting-started.mdx @@ -1,6 +1,7 @@ --- title: "Getting Started" description: "Install and set up @meshsdk/midnight-setup for building zero-knowledge privacy dApps on Midnight Network" +icon: RocketLaunchIcon --- import Link from "fumadocs-core/link"; diff --git a/apps/docs/content/docs/midnight/midnight-setup/index.mdx b/apps/docs/content/docs/midnight/midnight-setup/index.mdx index f9da7e6..be4dbbf 100644 --- a/apps/docs/content/docs/midnight/midnight-setup/index.mdx +++ b/apps/docs/content/docs/midnight/midnight-setup/index.mdx @@ -1,6 +1,7 @@ --- title: "Overview" description: "Complete development setup for building Midnight Network dApps" +icon: Cog6ToothIcon --- import {linksMidnightSetup} from "@/data/links-midnight"; @@ -21,3 +22,4 @@ import { ))} + diff --git a/apps/docs/content/docs/midnight/midnight-setup/meta.json b/apps/docs/content/docs/midnight/midnight-setup/meta.json index a84ae0a..fed1834 100644 --- a/apps/docs/content/docs/midnight/midnight-setup/meta.json +++ b/apps/docs/content/docs/midnight/midnight-setup/meta.json @@ -1,4 +1,6 @@ { "title": "Midnight Setup", + "icon": "WrenchScrewdriverIcon", "pages": ["index", "getting-started", "api", "wallet", "examples"] } + diff --git a/apps/docs/content/docs/midnight/midnight-setup/wallet.mdx b/apps/docs/content/docs/midnight/midnight-setup/wallet.mdx index 5b2d365..97c17c6 100644 --- a/apps/docs/content/docs/midnight/midnight-setup/wallet.mdx +++ b/apps/docs/content/docs/midnight/midnight-setup/wallet.mdx @@ -1,6 +1,7 @@ --- title: "Lace Wallet Integration" description: "Complete Lace Beta Wallet integration for Midnight Network dApps" +icon: WalletIcon --- import Link from "fumadocs-core/link"; diff --git a/apps/docs/data/links-midnight.ts b/apps/docs/data/links-midnight.ts index d848aa3..76028ca 100644 --- a/apps/docs/data/links-midnight.ts +++ b/apps/docs/data/links-midnight.ts @@ -34,9 +34,45 @@ export const linksMidnight = [ title: "Midnight Setup", desc: "Complete development setup for building Midnight Network dApps", link: "/midnight/midnight-setup" + }, + { + title: "Midnight Contracts Wizard", + desc: "CLI tool to scaffold Midnight smart contract projects with pre-built templates", + link: "/midnight/midnight-contracts-wizard" } ]; +export const metaMidnightContractsWizardInstallation = { + title: "Installation", + desc: "Install the CLI tool and get started with Midnight Contracts Wizard", + link: "/midnight/midnight-contracts-wizard/installation", +}; + +export const metaMidnightContractsWizardUsage = { + title: "Usage", + desc: "Learn how to use the interactive wizard to scaffold your project", + link: "/midnight/midnight-contracts-wizard/usage", +}; + +export const metaMidnightContractsWizardContracts = { + title: "Available Contracts", + desc: "Explore pre-built contract templates for tokenization, staking, identity, oracle, and lending", + link: "/midnight/midnight-contracts-wizard/contracts", +}; + +export const metaMidnightContractsWizardProjectStructure = { + title: "Project Structure", + desc: "Understanding the generated project structure and configuration files", + link: "/midnight/midnight-contracts-wizard/project-structure", +}; + +export const linksMidnightContractsWizard = [ + metaMidnightContractsWizardInstallation, + metaMidnightContractsWizardUsage, + metaMidnightContractsWizardContracts, + metaMidnightContractsWizardProjectStructure, +]; + export const metaMidnight = { title: "Midnight", desc: "Zero-knowledge privacy network for Cardano",