Miden game that showcases (almost) all Miden features
- 主要語言
- Rust
- 星號
- 18
- 分支
- 34
- PR 合併指標
- 30 天內沒有已合併 PR
描述
# Miden book - example application
So my current idea for the Miden book would be to merge the tutorial and the protocol sections into one section.
I took my inspiration from the Rust book. So ideally, we also have the user to build an application that incrementally gets more complex by adding more and more features. Until all main Miden features are explained conceptually and with code examples. Ideally, we have the `midenup` command already. But the the structure should not change much.
I am not sure yet which application we want the user to build. But I have one suggestion.
## Suggestion - Avalon like game
We could let users build a simple game - like Avalon. This will let the user learn all Miden concepts, I believe. And it shows Miden's hybrid approach of private and public transactions and state.
### Avalon - Game Flow
See [here](https://en.wikipedia.org/wiki/The_Resistance_(game)) for a game explainer
1. **Game Setup**
- Each player deploys a private account (stores their personal state) and generates a secret `s`.
- A public game account is initialized.
- Each player registers his identity commitment (=`H(s)`) in a `StorageMap` of the public account.
2. **Role Assignment**
- An oracle assigns secret roles (seeded from randomness).
- Each player receives their role as a private note (NFT) from the game account. There are _traitors_ and _knights_.
3. **Team Proposals** (Round-based)
- A player proposes a team for the mission (a set of `N` selected players) to the game account (direct execution).
- Other players approve or reject the proposal via a network note to the game account.
- If the proposal passes:
- A new `missionID` is assigned
- The selected players' commitments are collected into a new Merkle tree (root stored as `missionRoot` in the game account)
- The game account emits `N` `VotingSwapNotes` with `missionRoot`
- If three proposals fail in a row, the traitors win.
4. **Mission Execution** (Semaphore Voting)
- Each selected player creates a new private account locally (to break linkability).
- Each selected player consumes one `VotingSwapNote` with the new private account. That automatically creates
- A network note `voteNote` back to the game account that includes the players `vote` and `nullifier` = `H(secret || missionID)`.
- Consumption fails, if the player cannot prove his identity commitment is in the `missionRoot`
5. **Mission reveal**:
- Game account consumes all `voteNote` checking that each nullifier has not been used before.
- Updates the mission vote tally (successCount / failCount). As each vote arrives, the game account only updates the aggregate tally.
- Once all votes are in, the game account determines mission success or failure based on the fail count.
6. **Endgame**
- After 5 missions (3 wins needed to succeed), the game ends.
- The game account determines the winning team.
### Miden learnings
In building this game, builders would learn a lot of Miden concepts and use the Rust and the WebClient.
Chapter | Goal | Miden Concepts
-- | -- | --
Game setup | Account creation | Private and public accounts, clients
Role Assignment | Send private notes to players | Notes, oracle, FPI, NFTs
Team proposals | Simple public smart contract interaction | Network notes, custom notes and smart contracts
Mission Execution | Private smart contract interaction | Custom note swap logic, nullifiers, note tags and recipient logic
Mission Reveal | Autonomous smart contracts | Complex smart contract logic
From Rust to Web | Rust client and WebClient interaction | Frontend integration, wallet adapter
貢獻指南
研究方向
該 issue 描述了一個用於 Miden 書籍的綜合性範例應用程式。首先,請回顧現有的 Miden 教學和書籍結構,以了解當前內容。檢查列出的 Miden 概念(私有/公開帳戶、notes、NFT、智能合約、nullifiers),並查看它們目前的解釋方式。目標是設計一個教學,逐步構建一個類似《阿瓦隆》的遊戲,因此請概述章節,並將每一章映射到現有的 Miden 範例和程式碼。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- rust
- 領域
- blockchain, documentation, game-dev
- Issue 類型
- 文件
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 30/100