Skip to main content

Game Template Library: On-Chain Game Patterns for Every Chain

7 min read

The best way to learn a framework is to see it in action. We've built five game templates, each one showing a different chain integration, cryptographic technique, or architectural pattern. They're all open-source, playable live, and ready to fork.

Safe Solver: multichain L2 on Arbitrum + Midnight

Safe Solver is a fast, interactive puzzle game that runs multichain on Arbitrum and Midnight. It demonstrates EffectStream working as an L2 across both chains, with deterministic randomness derived per block and L2 interaction for game execution.

The game itself is a puzzle where players solve safe combinations on-chain. The random puzzle generation is deterministic per block, so all nodes reach the same result. EffectStream handles game logic and state transitions as an L2, while Arbitrum and Midnight provide the settlement layers. This is a good example of how a fast, interactive game can work on-chain without sacrificing responsiveness.

Most on-chain games either commit to a single chain or accept inconsistent state across chains. Safe Solver runs the same game logic over Arbitrum and Midnight blocks simultaneously, with EffectStream computing the deterministic result both chains independently agree on — and this multichain L2 pattern is the foundation the other four templates build on.

Kachina Kolosseum: multiplayer Midnight ZK game

Kachina Kolosseum is a multiplayer PvP game built entirely on Midnight, demonstrating commit-reveal schemes written in Compact (Midnight's ZK language). All proofs are generated in the browser, so players don't need any backend infrastructure to play.

In PvP on a public blockchain, the second player has an inherent advantage: they can see the first player's move and counter it. The commit-reveal scheme in Compact fixes this. Both players commit their moves privately, then reveal simultaneously. ZK proofs verify the revealed move matches the original commitment without exposing it early. If someone refuses to reveal (griefing), a timeout kicks in and they forfeit. Proof generation happens client-side and completes in under a second.

The protocol is named after the academic work it builds on — Kachina: Foundations of Private Smart Contracts (Kerber, Kiayias, Kohlweiss; University of Edinburgh, 2020) and the extended 2021 manuscript, which formalises the model for private smart contracts that underlies Midnight's design. Kachina Kolosseum is the gameplay-shaped instantiation of those ideas: a trustless commit-reveal arena where the cryptography is the rulebook.

Block Kart Legends: on-chain TypeScript simulation on Arbitrum + Midnight

Block Kart Legends is a racing game that runs complex TypeScript on-chain code cross-chain on Arbitrum and Midnight. It generates a deterministic L2 based on EVM + Midnight blocks, where it executes the race simulations. The entire race physics run deterministically in the L2, so every node computes the same result.

"On-chain TypeScript code" is the unusual part. Most chains run a custom VM (EVM, Move, Cairo) or expose a constrained DSL. Block Kart's game loop is plain TypeScript — collisions, friction, momentum, lap detection — running as the L2's state transition function and replayed identically by every full node. The language doesn't change between local development, testing, and on-chain execution, which is what makes it practical to ship a real physics simulation as on-chain logic rather than as a thin coordination layer over an off-chain server.

Arbitrum handles the transaction layer (race entries, rewards, leaderboard updates), while Midnight provides ZK verification of race results. This means a player's race time is provably legitimate without needing a centralized game server to validate every result.

Dust-2-Dust: large-scale ZK game in Compact

The most technically complex template, by a clear margin. Dust-2-Dust is a roguelike deck builder written entirely in Compact (Midnight's ZK language), proving that ZK languages can encode and execute complex game behaviors. All proofs are calculated with WASM in the browser.

This isn't a simple proof-of-concept. It's a full game with hidden inventory, private resource management, and strategic decisions that stay secret until their effects show up in gameplay. Multiple interacting ZK circuits compose together for complex game logic while preserving privacy throughout.

Where most ZK games stop at a single circuit — one private state, one reveal — Dust-2-Dust threads many circuits together: drawing cards, using items, combat resolution, level progression, each with their own private state, all composed into one game session that lasts dozens of turns. The template is deliberately pushing the limits of state-of-the-art ZK circuit complexity: how much logic can you fit in a single Compact program, how many circuits can compose without proof generation becoming impractical, how much hidden state can persist between rounds without leaking through the public commitment? Dust-2-Dust's answers to those questions are the upper bound for what's currently shippable as a browser-side ZK game.

Go Fish: ZK Mental Poker

Go Fish is a ZK implementation of "Mental Poker," the classic cryptographic problem of playing a fair card game without a trusted dealer. It's built entirely on a ZK contract, which means any card-like game can be implemented on top of the same protocol. Trustless card games, no server needed.

The protocol uses a commit-reveal scheme combined with shared secret derivation. When cards are "dealt," the deck is encrypted so that neither player can read it alone. Each card reveal requires cooperative decryption: both players contribute their share to reveal a card, which means neither side can peek ahead or manipulate the draw order. A fair deal is enforced by the math, not by trusting a server.

Once you have a trustless deck, the protocol generalises. Poker, blackjack, and trick-taking games all fall out of the same foundation. So do trading-card games with hidden hands — a Magic: The Gathering-style game, where each player has a private hand drawn from a shuffled deck and cards are revealed when played, is exactly the shape of the problem Go Fish solves. The same circuit that makes "Go Fish" trustless makes a full Magic-style card game trustless too: the only thing that changes is the card definitions and the turn rules, both of which run on top of the shared deck-and-hand primitive.


All templates at a glance

TemplateChainWhat's novelLive URL
Safe SolverArbitrum + MidnightMultichain L2, deterministic random per blocksafesolver.midnight.fun
Kachina KolosseumMidnightMultiplayer ZK game, browser proofs, Compact commit-reveal (based on the Kachina academic work)kachina.midnight.fun
Block Kart LegendsArbitrum + MidnightOn-chain TypeScript code, deterministic L2 physicsblockkart.paimastudios.com
Dust-2-DustMidnightFull roguelike deck builder in Compact, multi-circuit ZK at the limit of the current state of the artdust2dust.midnight.fun
Go FishMidnightZK Mental Poker, foundation for any trustless trading-card game (Magic-style hidden hands, poker, blackjack)Local only

Every template is a complete, deployable game you can fork, modify, and ship. The game templates repository is the fastest way to start building with EffectStream.