From 54f97b3e16fe11c80c4c0c4f2390e871cab256da Mon Sep 17 00:00:00 2001 From: luislucena16 Date: Fri, 31 Oct 2025 14:23:21 +0100 Subject: [PATCH] feat: add midnight contracts wizard docs and improve midnight setup --- apps/docs/content/docs/midnight/meta.json | 5 +- .../midnight-contracts-wizard/contracts.mdx | 135 +++++++++ .../midnight-contracts-wizard/index.mdx | 25 ++ .../installation.mdx | 38 +++ .../midnight-contracts-wizard/meta.json | 5 + .../project-structure.mdx | 155 +++++++++++ .../midnight-contracts-wizard/usage.mdx | 81 ++++++ .../midnight/{ => midnight-setup}/api.mdx | 1 + .../{ => midnight-setup}/examples.mdx | 1 + .../{ => midnight-setup}/getting-started.mdx | 1 + .../docs/midnight/midnight-setup/index.mdx | 25 ++ .../docs/midnight/midnight-setup/meta.json | 6 + .../midnight/{ => midnight-setup}/wallet.mdx | 1 + apps/docs/content/docs/midnight/setup.mdx | 263 ------------------ apps/docs/data/links-midnight.ts | 53 +++- 15 files changed, 526 insertions(+), 269 deletions(-) create mode 100644 apps/docs/content/docs/midnight/midnight-contracts-wizard/contracts.mdx create mode 100644 apps/docs/content/docs/midnight/midnight-contracts-wizard/index.mdx create mode 100644 apps/docs/content/docs/midnight/midnight-contracts-wizard/installation.mdx create mode 100644 apps/docs/content/docs/midnight/midnight-contracts-wizard/meta.json create mode 100644 apps/docs/content/docs/midnight/midnight-contracts-wizard/project-structure.mdx create mode 100644 apps/docs/content/docs/midnight/midnight-contracts-wizard/usage.mdx rename apps/docs/content/docs/midnight/{ => midnight-setup}/api.mdx (99%) rename apps/docs/content/docs/midnight/{ => midnight-setup}/examples.mdx (99%) rename apps/docs/content/docs/midnight/{ => midnight-setup}/getting-started.mdx (99%) create mode 100644 apps/docs/content/docs/midnight/midnight-setup/index.mdx create mode 100644 apps/docs/content/docs/midnight/midnight-setup/meta.json rename apps/docs/content/docs/midnight/{ => midnight-setup}/wallet.mdx (99%) delete mode 100644 apps/docs/content/docs/midnight/setup.mdx diff --git a/apps/docs/content/docs/midnight/meta.json b/apps/docs/content/docs/midnight/meta.json index edcb732..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": ["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/api.mdx b/apps/docs/content/docs/midnight/midnight-setup/api.mdx similarity index 99% rename from apps/docs/content/docs/midnight/api.mdx rename to apps/docs/content/docs/midnight/midnight-setup/api.mdx index e997205..60bef9d 100644 --- a/apps/docs/content/docs/midnight/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/examples.mdx b/apps/docs/content/docs/midnight/midnight-setup/examples.mdx similarity index 99% rename from apps/docs/content/docs/midnight/examples.mdx rename to apps/docs/content/docs/midnight/midnight-setup/examples.mdx index 22cbc99..c6fd9bc 100644 --- a/apps/docs/content/docs/midnight/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/getting-started.mdx b/apps/docs/content/docs/midnight/midnight-setup/getting-started.mdx similarity index 99% rename from apps/docs/content/docs/midnight/getting-started.mdx rename to apps/docs/content/docs/midnight/midnight-setup/getting-started.mdx index 57171e6..9e266de 100644 --- a/apps/docs/content/docs/midnight/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 new file mode 100644 index 0000000..be4dbbf --- /dev/null +++ b/apps/docs/content/docs/midnight/midnight-setup/index.mdx @@ -0,0 +1,25 @@ +--- +title: "Overview" +description: "Complete development setup for building Midnight Network dApps" +icon: Cog6ToothIcon +--- + +import {linksMidnightSetup} from "@/data/links-midnight"; +import Link from "next/link"; +import { + Card, + CardDescription, + CardTitle, +} from "@/components/ui/card"; + +
+ {linksMidnightSetup.map((card) => ( + + + {card.title} + {card.desc} + + + ))} +
+ diff --git a/apps/docs/content/docs/midnight/midnight-setup/meta.json b/apps/docs/content/docs/midnight/midnight-setup/meta.json new file mode 100644 index 0000000..fed1834 --- /dev/null +++ b/apps/docs/content/docs/midnight/midnight-setup/meta.json @@ -0,0 +1,6 @@ +{ + "title": "Midnight Setup", + "icon": "WrenchScrewdriverIcon", + "pages": ["index", "getting-started", "api", "wallet", "examples"] +} + diff --git a/apps/docs/content/docs/midnight/wallet.mdx b/apps/docs/content/docs/midnight/midnight-setup/wallet.mdx similarity index 99% rename from apps/docs/content/docs/midnight/wallet.mdx rename to apps/docs/content/docs/midnight/midnight-setup/wallet.mdx index 5b2d365..97c17c6 100644 --- a/apps/docs/content/docs/midnight/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/content/docs/midnight/setup.mdx b/apps/docs/content/docs/midnight/setup.mdx deleted file mode 100644 index b09dfe0..0000000 --- a/apps/docs/content/docs/midnight/setup.mdx +++ /dev/null @@ -1,263 +0,0 @@ ---- -title: "Midnight Setup" -description: "Complete development setup for building Midnight Network dApps" ---- - -import Link from "fumadocs-core/link"; - -`@meshsdk/midnight-setup` - Complete development setup for building Midnight Network dApps with zero-knowledge privacy and TypeScript support. - -## Getting Started - -Install and set up @meshsdk/midnight-setup for building zero-knowledge privacy dApps on Midnight Network. - -### Installation - -Install the Midnight setup package using your preferred package manager: - -```bash -# Using npm -npm install @meshsdk/midnight-setup - -# Using yarn -yarn add @meshsdk/midnight-setup -``` - -### Quick Start - -```typescript -import { MidnightSetupAPI } from '@meshsdk/midnight-setup'; - -// Deploy a new contract -const api = await MidnightSetupAPI.deployContract(providers, contractInstance); - -// Join an existing contract -const api = await MidnightSetupAPI.joinContract(providers, contractInstance, contractAddress); - -// Get contract state -const state = await api.getContractState(); - -// Get ledger state -const ledgerState = await api.getLedgerState(); -``` - -## Core API Methods - -Complete reference for MidnightSetupAPI methods and provider setup. - -### MidnightSetupAPI - -The `MidnightSetupAPI` is the main class for interacting with Midnight Network contracts. - -| Method | Description | Usage | -|--------|-------------|-------| -| `deployContract(providers, contractInstance)` | Deploy a new contract | Creates new contract instance | -| `joinContract(providers, contractInstance, address)` | Join existing contract | Connect to deployed contract | -| `getContractState()` | Read contract state | Get current contract data | -| `getLedgerState()` | Read ledger state | Get blockchain data | - -### Deploy Contract - -```typescript -import { MidnightSetupAPI } from '@meshsdk/midnight-setup'; - -const api = await MidnightSetupAPI.deployContract(providers, contractInstance); -console.log('Contract deployed:', api.deployedContractAddress); -``` - -### Join Contract - -```typescript -import { MidnightSetupAPI } from '@meshsdk/midnight-setup'; - -const contractAddress = "contract_address_here"; -const api = await MidnightSetupAPI.joinContract(providers, contractInstance, contractAddress); -console.log('Connected to contract:', contractAddress); -``` - -## Lace Wallet Integration - -Complete Lace Beta Wallet integration for Midnight Network dApps. - -### Wallet Features - -| Feature | Description | Implementation | -|---------|-------------|----------------| -| Connect Wallet | Connect to Lace Beta Wallet | `wallet.enable()` | -| Disconnect Wallet | Disconnect from wallet | `wallet.disconnect()` | -| Get Wallet State | Retrieve wallet address and keys | `wallet.state()` | -| Deploy Contract | Deploy contracts through wallet | `wallet.submitTransaction()` | -| Join Contract | Join existing contracts | `wallet.balanceAndProveTransaction()` | -| Balance Transactions | Balance and prove transactions | Wallet API integration | - -### Wallet Provider Setup - -```typescript -// Connect to Lace Wallet -const wallet = window.midnight?.mnLace; -if (!wallet) { - throw new Error('Please install Lace Beta Wallet for Midnight Network'); -} - -// Enable wallet and get state -const walletAPI = await wallet.enable(); -const walletState = await walletAPI.state(); -const uris = await wallet.serviceUriConfig(); -``` - -### React Wallet Hook - -```typescript -import { useMidnightWallet } from './hooks/useMidnightWallet'; - -function App() { - const { - connectWallet, - disconnectWallet, - walletState, - isConnected - } = useMidnightWallet(); - - return ( -
- {isConnected ? ( - - ) : ( - - )} -
- ); -} -``` - -## Integration Examples - -The fastest way to build on Midnight Network with pre-built smart contracts, complete API, and ready-to-use code snippets. - -### Installation - -```bash -npm install @meshsdk/midnight-setup \ - @midnight-ntwrk/dapp-connector-api@3.0.0 \ - @midnight-ntwrk/midnight-js-fetch-zk-config-provider@2.0.2 \ - @midnight-ntwrk/midnight-js-http-client-proof-provider@2.0.2 \ - @midnight-ntwrk/midnight-js-indexer-public-data-provider@2.0.2 \ - @midnight-ntwrk/midnight-js-level-private-state-provider@2.0.2 \ - @midnight-ntwrk/midnight-js-network-id@2.0.2 -``` - -### Features - -- **Type-safe SDK** - Full TypeScript support -- **Provider abstraction** - Easy wallet and network integration -- **Contract state management** - Query contract and ledger states -- **Flexible contract support** - Works with any Midnight smart contract -- **Lightweight** - Only 10.4 KB package size -- **ESM & CJS** - Supports both module systems - -### Quick Start - -#### 1. Setup Providers - -```typescript -import { FetchZkConfigProvider } from "@midnight-ntwrk/midnight-js-fetch-zk-config-provider"; -import { httpClientProofProvider } from "@midnight-ntwrk/midnight-js-http-client-proof-provider"; -import { indexerPublicDataProvider } from "@midnight-ntwrk/midnight-js-indexer-public-data-provider"; -import { levelPrivateStateProvider } from "@midnight-ntwrk/midnight-js-level-private-state-provider"; - -import type { MidnightSetupContractProviders } from "@meshsdk/midnight-setup"; - -export async function setupProviders(): Promise { - const wallet = window.midnight?.mnLace; - if (!wallet) { - throw new Error("Please install Lace Beta Wallet for Midnight Network"); - } - - const walletAPI = await wallet.enable(); - const walletState = await walletAPI.state(); - const uris = await wallet.serviceUriConfig(); - - return { - privateStateProvider: levelPrivateStateProvider({ - privateStateStoreName: "my-dapp-state", - }), - zkConfigProvider: new FetchZkConfigProvider( - window.location.origin, - fetch.bind(window), - ), - proofProvider: httpClientProofProvider(uris.proverServerUri), - publicDataProvider: indexerPublicDataProvider( - uris.indexerUri, - uris.indexerWsUri, - ), - walletProvider: { - coinPublicKey: walletState.coinPublicKey, - encryptionPublicKey: walletState.encryptionPublicKey, - balanceTx: (tx, newCoins) => { - return walletAPI.balanceAndProveTransaction(tx, newCoins); - }, - }, - midnightProvider: { - submitTx: (tx) => { - return walletAPI.submitTransaction(tx); - }, - }, - }; -} -``` - -#### 2. Deploy a Contract - -```typescript -import { MidnightSetupAPI } from "@meshsdk/midnight-setup"; - -import { setupProviders } from "./providers"; - -async function deployContract() { - const providers = await setupProviders(); - const contractInstance = new MyContract({}); - - const api = await MidnightSetupAPI.deployContract( - providers, - contractInstance, - ); - - console.log("Contract deployed at:", api.deployedContractAddress); - return api; -} -``` - -#### 3. Join Existing Contract - -```typescript -async function joinContract(contractAddress: string) { - const providers = await setupProviders(); - const contractInstance = new MyContract({}); - - const api = await MidnightSetupAPI.joinContract( - providers, - contractInstance, - contractAddress, - ); - - return api; -} -``` - -#### 4. Read Contract State - -```typescript -// Get contract state -const contractState = await api.getContractState(); -console.log("Contract data:", contractState.data); - -// Get ledger state -const ledgerState = await api.getLedgerState(); -console.log("Message:", ledgerState.ledgerState?.message); -``` - -## Resources - -- [Midnight Network Documentation](https://docs.midnight.network/) -- [Mesh SDK Documentation](https://midnight.meshjs.dev/en) -- [Lace Beta Wallet](https://chromewebstore.google.com/detail/lace-midnight-preview/hgeekaiplokcnmakghbdfbgnlfheichg) diff --git a/apps/docs/data/links-midnight.ts b/apps/docs/data/links-midnight.ts index 185435e..76028ca 100644 --- a/apps/docs/data/links-midnight.ts +++ b/apps/docs/data/links-midnight.ts @@ -1,35 +1,78 @@ export const metaMidnightGettingStarted = { title: "Getting Started", desc: "Install and set up @meshsdk/midnight-setup for building zero-knowledge privacy dApps", - link: "/midnight/getting-started", + link: "/midnight/midnight-setup/getting-started", }; export const metaMidnightAPI = { title: "Core API Methods", desc: "Complete reference for MidnightSetupAPI methods and provider setup", - link: "/midnight/api", + link: "/midnight/midnight-setup/api", }; export const metaMidnightWallet = { title: "Lace Wallet Integration", desc: "Complete guide for integrating Lace Beta Wallet with Midnight Network dApps", - link: "/midnight/wallet", + link: "/midnight/midnight-setup/wallet", }; export const metaMidnightExamples = { title: "Integration Examples", desc: "React hooks, contract management, and complete dApp examples for Midnight Network", - link: "/midnight/examples", + link: "/midnight/midnight-setup/examples", }; +export const linksMidnightSetup = [ + metaMidnightGettingStarted, + metaMidnightAPI, + metaMidnightWallet, + metaMidnightExamples, +]; + export const linksMidnight = [ { title: "Midnight Setup", desc: "Complete development setup for building Midnight Network dApps", - link: "/midnight/setup" + 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",