Documentation
👨‍💻 ZkNoid for developers
Technologies Architecture

Technologies architecture

Network architecture

Mina network has several limitations that makes it hard to implement on-chain gaming. Mina zkApps has limitation of 8 memory slots per smartcontract. It’s complicated to implement gasless transactions and block production is slower that required for realtime games. To solve this challenges our games use both Mina and Protokit networks
App chain is deployed to https://protokit.zknoid.io/graphql

What is Protokit

Protokit is a product developed by Mina Protocol team. Basically it’s a tool that allows to set up your own app-specific Zk Rollup network. This network is separated from the Mina network. It’s impossible to access Mina zkApps – the only contracts exist in the network are defined by network developer and known as runtime modules. As only they are presented in the network they can be identified by names instead of addresses.

The only connection between Mina and app specific networks is bridging. Mina token can be bridged to an internal user balance in an app smartcontract. Then other smartcontracts can check user balance and decrease it to pay for actions. For now only MINA native currency can be bridged. However it will be possible to bridge Mina tokens when the token inside Mina network is standardised. In this case user deposit amounts and token infos will be stored inside app network.

Bridging

Why Protokit

The app network works off the Mina chain but captures state changes and pushes proofs to the Mina network. It solves mina limitations of storing smart contract state in not more than 8 slots of 32-bytes size while inheriting the L1 network security. Allows to handy implement such features as leaderboards, players waiting room for matchmaking.

Another usefull fact about app network – you can decide whether to charge fee from users for transaction or to make transactions completely free.

Gassless transactions are crucial for gaming UX. Now a session key can be created on frontend, registered by user and used to sign game transactions in background without interruptions for transactions confirmation.

Networks interplay

To cook both Mina and Protokit app networks inside one application we decided to consider Protokit network as a game room network. User connects to it only when enters the game round. If game round is payed and required a fee to play, assets are bridged before entering

Networks interplay

Multiplayer architecture

Sources of the multiplayer system can be found here – MatchMaker.ts

When a multiplayer game started, match making occurs. A competitor is chosen from the waiting room pool based on similar game level or other conditions. If there’re no suitable opponents, user is registered in the waiting room pool and waits for someone else to join.

Once opponent is found, session key is generated on frontend and registered in the network. Now game can make background transaction with no players interruption

Players pool

After round created user1 move is awaited. If user haven’t made his move within allowed time, user2 can prove it and user1 move is skipped. Is user1 skipped several moves in a row, he disqualified and user2 wins. After user1 move transaction is executed and on-chain event is emitted. This event is processed by user2 frontend that displays the updated game state and asks user2 to move.

Multiplayer events

After one user won or there was a draw, competition is marked as finished and prize is unbridged to the winner to L1 network

This can be combined with game process proving since app network supports ZK proofs verification. While playing their move users recursively accumulate game process proofs, then final proof is verified in the move transaction.

Recuvrsive proofs