0xMiden / 0xMiden/tutorials

Miden game that showcases (almost) all Miden features

Ouverte
#97 0 commentaires 2 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Rust
Étoiles
18
Forks
34
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

# 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

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

The issue describes a comprehensive example application for the Miden book. Start by reviewing the existing Miden tutorials and book structure to understand the current content. Examine the Miden concepts listed (private/public accounts, notes, NFTs, smart contracts, nullifiers) and see how they are currently explained. The goal is to design a tutorial that incrementally builds an Avalon-like game, so outline the chapters and map each to existing Miden examples and code.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
rust
Domaine
blockchain, documentation, game-dev
Type d'issue
Documentation
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
30/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.