On-Chain Game Mechanics: The Toshimon Story
Full-stack solution providers that are experienced in multiple disciplines, languages, and blockchain ecosystems are crucial as development partners.
Authored by Timothy Hao Chi Ho
Thank you to Willem Olding and Megs Doyle for their contributions to this article.
The potential of blockchain technology in gaming is rarely understated by players in this space. However, blockchain game development is still in its infancy. Blockchain games, touting implied digital asset ownership, tend to garner a modest but loyal player base in today's ecosystem, partially due to a recent emphasis on meta-game experiences, like digital asset purchases and community engagement initiatives. For a time, the potential audience was limited.
While early blockchain games appeared experimental and unconcerned with user experience at all, one-to-one parity between web3 and traditional games is fast approaching. Today, the tell-tale wrinkles of a blockchain game are being smoothed out, opening the door to gaming's massive, vibrant community.
That's why we've put together this article—so game developers can take inspiration from ChainSafe's solutions to build quality digital experiences for wider audiences in the years ahead.
Fundamentally, the hope of using blockchain technology in game development is to promote new ways of making games more accessible to all types of gamers. While there is an ongoing debate as to whether blockchain elements and web3 principles genuinely enhance the gaming experience, the advantages of web3 are clear: decentralization, provenance, true ownership, composable applications, and trust-minimization frameworks.
Full-stack solution providers will drive blockchain gaming
Big game studios have already begun exploring blockchain game development with use cases spanning game marketplaces, online gaming, and collectibles.
Even smaller-scale indie gaming teams are beginning to explore new primitives such as non-fungible tokens (NFTs), GameFi, and play-to-earn mechanics, as well as how each of these technological innovations can be leveraged in service of advancing today's gaming experiences. NFTs expanding beyond images to all manner of digital assets is particularly important, as it allows virtually any element of a game (items, skins, maps and more) to be marked for true ownership.
While the future of blockchain gaming is bright and on track to become the frontrunner for web3 adoption, there are still a number of challenges to overcome. Traditional game development teams must foster blockchain expertise in-house or collaborate with an external organization in order to decrease the human and economic capital associated with building a blockchain-enabled game.
As a result, full-stack solution providers that are experienced in multiple disciplines, languages, and blockchain ecosystems are crucial as development partners. They point to a future where they are increasingly relied on for the buffing effect they have on web3 game development.

Toshimon chooses ChainSafe
As experts in infrastructure development and protocol engineering, ChainSafe has developed a reputation as one such full-stack solutions provider. This experience crosses over into ChainSafe Gaming, where our gaming SDK, web3.unity, deploys key infrastructure for Unity developers building blockchain-powered games. The library has over 10k downloads to date.
In addition, ChainSafe's R&D department, ChainSafe Solutions, has and continues to engineer innovative solutions for gaming teams exploring web3 integrations. Together, the two have helped thousands of gaming developers and studios to create games, build strong, active communities, and access recieve dedicated support.
It was ultimately ChainSafe's years of experience (we're pretty hardcore) and proven track record of infrastructure development that led the team at Toshimon to collaborate with us in developing new ways to innovate the blockchain gaming space.
Innovative solutions to fair, decentralized, and quality gameplay
Toshimon is a browser-based online player vs. player (PVP) battle-style trading card game (TCG) that requires the use of non-fungible tokens (NFTs) on the Ethereum/Polygon platforms to act as immutable in-game assets. The project takes after its predecessor, Pokémon, with a clear difference—bringing elements of the game design on-chain. Toshimon targets a wide array of end-users, including collectors, traders, and gamers. Toshimon's gamification of non-fungible tokens and other aspects of blockchain allows it to double as a fun educational tool for new web3 users.
As part of the solutions engagement between both organizations, the Toshimon team approached the experts at ChainSafe with the following question:
How can we make our PVP battle system provably fair and decentralized without compromising the player experience?
Increase decentralized mechanics, minimize player trust
Decentralization centers around the concept of immutability and trust minimization. Decentralization mechanics aim to decrease the amount of trust that users place in one another and dissuade their capacity to put forth authority or command over each other in a manner that corrupts the potency of the blockchain network. Any system devised should minimize (or require zero) trust between players and additionally minimize (or require zero) trust in a third party.
Do not compromise the user experience
In the dial-up era of blockchain, frequent writes to a blockchain state can quickly make a game prohibitively slow and expensive to play. Excessive token approvals, endless prompts by digital wallets to sign signatures or send game transactions, slow finality, and other web3-native UX could easily break player immersion.
For Toshimon, these are unimpeachable, foundational principles that needed a true web3 solution. Player expectations are justifiably high for today's traditional games—building a loyal player base requires an appeal to gaming's wider audience, most importantly through a smooth player experience.
For Toshimon, these are unimpeachable, foundational principles that needed a true web3 solution.
Battle game design: Toshimon mechanics
In order to better understand the approach ChainSafe took to solve the problem statement presented by Toshimon, it's important to break down the game mechanics at hand. The rules of Toshimon should be familiar to anyone who has played a mainline Pokemon game. However, for anyone unfamiliar, here is a high-level overview of the Toshimon gameplay:
There are over 160 different monsters in Toshimon, each with its own set of unique statistics and 140 different moves, as well as 10 different game items. "Moves" and "items" game assets have a varied effect on the monsters in battle, depending on each monster's stats. As an added layer of complexity, some aspects of the game have a randomized component. For example, a random chance of a critical hit (or miss) and random variation for attacks.
There are over 160 different monsters in Toshimon, each with its own set of unique statistics and 140 different moves, as well as 10 different game items.
Every move and item has a varied effect on the monsters in battle, depending on their stats. As an added layer of complexity, some aspects of the game have a randomized component. For example, a random chance of a critical hit (or miss) and random variation for attacks.
Technical aspects: Facilitating ‘proof of fairness' with Toshimon
As the Toshimon game mechanics do not expand beyond the 1v1 environment, there are useful two-party precedents to draw from: state channels and commit-reveal schemes.
State channels
State channels allow two participants to conduct off-chain game transactions directly with each other. Only two transactions are made on-chain: those confirming the initial and the final state. Otherwise, most of the game actions take place within the channel, which is off-chain, free, and has instant finality.
State channels were initially proposed as one scaling solution to Ethereum, where state changes are executed and validated by interested parties, minimizing computation on Ethereum's execution layer. It has seen limited adoption and has since been supplanted by rollups layer-2 solutions. There are a number of reasons for this, but the primary challenges of state channels include:
Liveness requirements
Participants must remain online to respond in case another player tries to cheat.
Complexity of implementation
For a dApp to be state channel compatible, it must be reducible to a state machine that can be implemented in a smart contract.
Restricted participants
Participants of a channel are fixed upon initialization and cannot be changed thereafter.
However, in the context of a 2-player game with relatively bounded complexity, state channels are a fitting implementation option and can be frequently seen being used in simple 2-player games such as tic-tac-toe and chess.
Points 1 and 3 In the above diagram are non-issues for a typical PVP card game. To put this into context, imagine two people playing cards together at a table. The games are generally quite short in duration, and the player set does not change. As a result, one unanswered question remained:
Is it possible to implement a game with a vastly more complex ruleset, like Toshimon, in a way that can still be played within a state channel?
Commit-reveal schemes
Commit-reveal schemes allow for hidden-information games to be played in public environments such as smart contracts and state channels. Without a commit-reveal phase, the player that goes first has a disadvantage as the other player can always see their movements and respond to them accordingly. With commit-reveal, both players submit a blind commitment to their move and only reveal what it is after the protocol has locked in both players' commitments.
This can also be used for creating shared randomness within a two-party protocol. In this scheme, both players commit to some element of randomness in addition to their moves. The contributions from both players can then be combined to determine the outcome of any move where randomness may be required (e.g., critical hits or misses). The two-state commit-reveal ensures that neither player can influence the outcome of the random moves in a predictable way and therefore gain an advantage.
While the above section aims to provide a high-level explanation of the solution ChainSafe designed for Toshimon, a more comprehensive and technical overview can be found here.
ChainSafe Solutions: proposal and game development
Keeping the aforementioned primitives and constraints in mind, ChainSafe proposed improved design mechanics for the Toshimon game.
The implementation of state channels for off-chain transactions makes battles in Toshimon fast, cheap, and transaction-minimizing - one of Toshimon's top concerns for enhanced UX. Within the state channel, an interactive commit-reveal scheme using a randomness protocol was devised to ensure a provably fair battle. The combination of these two elements allows Toshimon NFT holders to conduct off-chain battles with on-chain settlements.
State channel implementation
For the state channel implementation, channel smart contract code was written that allows two players to deposit some tokens on-chain. In doing so, they agree on some initial state (e.g., which cards they are using, the health and moves available to each monster, the cryptocurrency wager, etc.) and the rules by which the state can be updated. Players then take turns signing state updates — in Toshimon's case, these are attacks, using game items, or forfeiting the game. These updates modify the agreed-upon initial state according to the game's rules. At the end of the battle, the final state of the channel is committed to the blockchain (such as outstanding balances or the result of a battle).
Rolling commit-reveals
Since Toshimon battles have a probability associated with each action, a source of randomness must come from a random seed committed by each player during each turn. The action + random seed must then also be revealed along with the action at the end of each turn. This scheme is called a rolling commit-reveal. A clever bit of cryptography assures randomness in a provably fair way, which is then used to dictate the outcome of each state-evolving move. This is the aforementioned randomness protocol.
Extensibility of base game via state transition decomposition
One of the key innovations of this design is observing that the state itself can contain smart contract addresses for small pieces of the game logic (e.g. one move or one item). As a result, there's no need for a single registry for all of the game rules.
This has multiple useful outcomes:
- The game logic can be decomposed into small state-mutating functions. This allows for the large ruleset to be decomposed into a collection of contracts to be deployed incrementally. Much like how cards in games such as Magic: The Gathering or Pokemon TCG can add new rules to the existing game.
- It makes the game extensible. Anyone can add new functionality at any time, but it is only allowed in a game if both players agree when initializing the channel.
This is implemented in the state by having separate contract addresses for:
- Game items players may have.
- The moves each Toshimon is capable of making.
Again, it is the responsibility of the players to ensure the initial state is valid (e.g. Toshimon do not know moves they are incapable of). For players using the official Toshimon game client, this can be done automatically, but advanced players may choose to ignore this and play with their own custom rules. A useful analogy would be to imagine a group of individuals taking mainline Pokemon cards and using the printed stats and moves on each card to create their own custom variants of the game.
Composable, customizable gaming
In the near future, on-chain games with composable game logic will meaningfully modify the user experience, providing extensibility to the base game in infinitely creative ways. In fact, it's already being leveraged in games such as Dark Forest, where the active community iterates on the game by extending and modifying the base set rule. Players achieve this through composable, interoperable smart contracts. In many ways, this is the true promise of blockchain-enabled gaming.
ChainSafe and Toshimon: the outcome
ChainSafe is proud to have had the opportunity to share our expertise and experience in helping the Toshimon team understand and unlock the potential of state channels.
As a result of the schema recommended by ChainSafe, the Toshimon team went on to finish 2nd in the Grand Prize track at Polygon's BUIDL IT Summer 2022 hackathon.
Since Toshimon is built in Unity, we were also able to find natural synergies with ChainSafe Gaming's web3.unity team. In the proposed battle system, it was suggested that transactions and state channel messages be made through the web3.unity SDK. Incidentally, Toshimon had also previously engaged with ChainSafe by bootstrapping their game development with web3.unity—thanks to the web3 sign-in and check ERC-1155 balance prefabs, they were able to effortlessly implement core infrastructure for their game.
ChainSafe Gaming's web3.unity SDK
ChainSafe Gaming has already done a lot of the groundwork for Unity NFT game developers with its web3.unity SDK. In-game minting, in-game marketplace, provably-fair LootBoxes, web3 sign-in, social sign-in, verifying Solidity messages, sending transactions, and anti-cheat voucher systems are just a few of the features already available in web3.unity.
To learn more, check out NFT Minting And Marketplace for web3.unity or visit our page:

If you are a gaming team or blockchain game developer eager to design and implement real web3 solutions, look no further. Our around-the-clock and hands-on team of experts ensure that our services are suited to the needs of your project. We provide a solution for every game so that gamers can experience the new world of web3.
About ChainSafe
ChainSafe is a leading blockchain research and development firm specializing in innovative solutions for web3. Alongside its contributions to major blockchain ecosystems such as Ethereum, Polkadot, Filecoin, and more. ChainSafe creates solutions for developers and teams across the blockchain space utilizing our expertise in gaming, bridging, non-fungible tokens, and decentralized storage. As part of its mission to build innovative products for users and improved tooling for developers, ChainSafe embodies an open-source and community-oriented ethos to advance the future of the internet.