Unlocking new games with Cairo and Starknet

Blockchain technology has been at the forefront of technological innovation, and the gaming space is no exception. The rise of onchain decentralized games has created opportunities for developers and players alike, and Starknet is one of the most promising platforms in this space. In this article, we explore the key features of an onchain game, the challenges developers face, and the technological advantages Starknet brings to revolutionize the space.

Introduction to onchain games

Onchain games are games that use blockchain technology to some degree. This technology can take the form of NFTs as in-game items, ERC20 tokens as in-game currencies, or the game logic running on a smart contract. Depending on the use of the blockchain stack, onchain games provide different levels of control to game players. For example, some onchain games may not require players to use a wallet to play the game. These are usually called ‘crypto games' rather than blockchain games, but the terms are sometimes used synonymously. Nico Verecke from Bitkraft defines these types of games as web2.5 games. In web2.5 games, the assets are decentralized, while in pure web3 and fully onchain games, the utility is also decentralized.

Web2.5 games usually use blockchain technology for cosmetic purposes, such as issuing in-game items as NFTs or in-game currencies as tokens. However, the core gameplay and logic are not reliant on the blockchain. It means the developers still use the traditional technology stack for the game mechanics, which runs on a centralized server with the game’s logic off-chain. These games usually, but not exclusively, involve incentivized gameplay with play-to-earn elements.

The use of onchain asset management is still an advantage, as it gives the players true ownership over their in-game items, with the potential for these items to be interoperable. Interoperability grants you the ability to transfer in-game items, characters, and abilities that could be applicable in other contexts or sell them on the open market.

The disadvantage of web2.5 games is that players can still be at the mercy of the developers. The players are powerless if they wish to move the game in a different direction or change the rules.

Fully onchain games operate entirely on a blockchain. All assets and game logic live onchain. Like DeFi, it imparts the underlying benefits of blockchain technology to games, including transparency, immutability, and decentralization. With fully onchain games, players have full control over their in-game items and the parameters and logic of the game they want to play. Generally, a central entity (the developer) will determine starting parameters, but players are free to fork a game and continue on their own. It means fully onchain games are unstoppable. Anyone can fork and start the new server if the server starts acting maliciously. It means the game cannot be shut down, as anyone can spin up the network and continue its development even after the original creator departs. Participants are also free to create their own rules rather than being forced to adopt predefined ones designed by the original developer. It reimagines games as worlds (aka. autonomous worlds) that can endure for hundreds of years and fosters the creation of unique and organic decentralized structures.

The challenge with onchain games is that they require a large number of computational resources, storage needs, and expenses in the form of gas fees. There’s also a huge risk to player security and privacy, as players expose their data to a fully onchain environment. And not to forget, you also need to have a good UX for games to be sticky. These are some key hurdles that the latest onchain game developers are trying to solve. Starknet emerges as a promising solution because it enables computations off-chain, alleviating the computational and storage demands of onchain games while maintaining decentralization's benefits. However, trade-offs will always exist when determining a game's optimal balance between onchain and off-chain components. By selectively incorporating onchain elements, developers can optimize the game's performance, user experience, cost-effectiveness, and privacy.

Benefits of Onchain Games

Before we get into how Starknet is unique for onchain games, it is important to understand why we must care about them. What benefit do they bring to game developers and players? Just like DeFi brings many benefits to finance, onchain games bring similar benefits to players and game developers.


While levels of empowerment players can experience in onchain games vary, one concept of particular importance is 'hardness.’ “Hardness” is defined as the capacity of a system to make something very likely to be true in the future. In the context of a game, it is the hardness of the rules of a game that is decided. No one can change those rules arbitrarily. It doesn’t mean changes are prevented from occurring altogether, but it ensures that due process exists for changing those rules at the very least.

You may recall Ethereum founder Vitalik Buterin’s famous story of how he found inspiration to build the Ethereum network after playing World of Warcraft. The developers removed the damage component from his Warlock's Siphon Life spell, which brought home to Vitalik, quite starkly, the horrors of centralized services. Onchain games provide hardness to games, meaning their rules are immutable and transparent. It provides a high level of trust and security for game players. It is important for gamers, as it ensures they’re not at risk of losing their assets or progress due to game rule changes.


Another key benefit of an onchain game is composability. Composability is the capacity to freely use smart contracts in another smart contract without requiring permission from a centralized authority. Onchain games allow developers to build games that interact with other onchain games, dApps, and DeFi protocols. For example, an onchain game can use assets and some game logic from another onchain game and use AMMs for in-game currency swaps.

It is not possible in traditional games. Most of the time, the mechanics and assets of games are tightly controlled, and the terms and conditions players agree to are made to prevent other use. With onchain games, developers can create assets that can be used in multiple games or create game logic that can be easily integrated into other games. It gives developers more freedom in creating innovative and exciting game worlds, giving players more flexibility in what and how they play.


Interoperability allows the players to transfer or use their game assets between different gaming worlds or dApps. Traditional games have closed ecosystems where players can’t use their assets outside of those games. On the other hand, fully onchain games give players true ownership and control over their in-game assets, allowing them to freely move, trade, and utilize them across various gaming environments. Interoperability not only empowers players with the freedom to navigate a diverse gaming landscape but also drives innovation and creativity by facilitating the emergence of unique cross-game interactions, economies, and potentially vast player-driven ecosystems.

Challenges faced by onchain game developers and how Starknet solves them

Though onchain games promise to open new opportunities and expand the gaming industry, they also present novel challenges for game developers. Blockchains are known for high transaction fees and slow finality. A game might have millions of users with billions of actions daily, presenting huge challenges for developers regarding scalability, privacy, and user experience. Additionally, it is complex to build games using blockchain infrastructure. Let’s address some of these technical challenges and how Starknet seeks to solve them.

Contract Size

Solidity, the programming language for Ethereum smart contracts, presents several challenges to onchain game developers. One significant drawback is the fixed contract size limit imposed by Ethereum. A Solidity contract can be a maximum of 24KB, or it will run out of gas. It creates significant challenges for game developers, as games usually have a large and complex codebase. Developers may need to split their code arbitrarily and duplicate certain codes across contracts.

On the other hand, Cairo, Starknet’s programming language, is a superior programming language for large smart contracts and applications, thanks to features such as "components," which allow reusing stuff more easily. It allows developers to be more innovative in their game design, creating richer, more immersive gaming experiences without being hampered by contract size constraints.


Blockchains often struggle to handle the high transaction volumes and computational requirements of processing complex gaming applications. Additionally, the high transaction fees associated with this level of computation create barriers to entry for developers and players alike. For example, a single potential game like Minecraft has 10M+ users completing billions of in-game actions daily. According to L2Beat, all L2s combined only process roughly 50 transactions per second today. With a single transaction on an L2 costing approximately 1-10 cents, it is impossible, both in terms of network capacity and cost-wise, to run such a game on any L2 today. That’s where appchains (or app rollups) and Layer 3s come in.

Appchains or App rollups are tailored to suit a particular application's needs and requirements, offering high customization and optimization. Starknet's architecture makes it easy for developers to spin up their appchain. These appchains can run all the computation on a centralized server, which gives them almost the same computational power as any web2 game. Periodically, these appchains can submit a validity proof on a blockchain to prove the integrity of the game logic following the rules of the smart contracts. Developers can submit this proof on Ethereum and pay gas costs for a batch of transactions, making the cost significantly lower for individual transactions. Game developers can also submit this proof on Starknet and share the proof verification cost with multiple applications, making it significantly cheaper for individual transactions.

On the cost side, most of the cost for any Layer 2 is the data availability cost of Ethereum. For financial applications, it makes sense to store data on Ethereum since they require more security. However, gaming applications can choose a cheaper data availability layer as they don’t need the same level of security as financial applications. One of the alternative data availability layers is Celestia.

So, with a centralized execution environment, validity of the execution via validity proofs, and cheaper data availability via something like Celestia, game developers can create a similar level of game experience as web2 games. Starknet is making it easy to spin up these appchains/app rollups using Madara. Madara is a Substrate-based sequencer that projects building on Starknet can use to run their own appchain. Projects can utilize Madara to process their user transactions in a dedicated environment with high transactions per second (TPS) and low latency, enabling them to generate a proof of execution and verify it on Starknet. Madara leverages the power of the Cairo Virtual Machine and Blockifier (a block processing optimizer) to execute Cairo programs and Starknet smart contracts. It then offers a provable execution mechanism, allowing settlement on any L1 or L2 solution. Game developers building complex gaming ecosystems need this flexible infrastructure to use different blockchain stacks seamlessly.


Privacy plays a fundamental role in many game designs. For example, in a game of poker, if your opponent already knows your cards, you are already at a game-breaking disadvantage, or in a game of tower defense, if your opponent can already see your defense set up, they can easily defeat you by creating the counter units.

In these scenarios, you don’t even want the game developer to know your cards; otherwise, the game developer could play poker against you, knowing all your cards, and easily beat you. It is where zk proofs come in.

To achieve privacy against other players and game developers, game developers must use client-side zk proof creation and verification. Cairo will allow managing the privacy and game logic using the same language vs. solidity, requiring the game devs to build their custom circuit with Circom, which is much more difficult.

Also, since you want to make it very cheap for the games, Cairo makes it possible to use recursion to keep the verification to a single proof. Like in a turn-based game such as Poker, you can play your turn and create a zk proof on your device and send it to the other user’s device. The next users then can verify that you played your turn according to the game's rules, play their turn, and create a new zk proof using your zk proof and send it to the next player. It allows you to keep recreating a new zk proof with each turn until the game finishes and then submit the final proof onchain. This final proof can verify that all the turns have been played correctly and update the final result of the game onchain. In this way, you only pay the verification cost once for the whole game instead of paying the verification cost for each single turn.

User Experience

All actions need to be verified on the blockchain for an onchain game. However, developers can’t ask for wallet approval for every action taken in-game to be successful. Imagine being bombarded with pop-up notifications to sign a transaction every time you did anything in a game. It would also cause network congestion, making the game unresponsive while incurring gas fees that players would have to pay for any in-game action they repeatedly do. It would be highly impractical for such a game to be successful.

Starknet implemented account abstraction natively into the chain to solve these issues. Account Abstraction allows developers to create accounts (wallets) as a programmable smart contract. With smart contract wallets, it becomes possible to code various logic to customize transactions and add other features to the wallet itself.

Here are some examples of how account abstraction can enhance gaming experiences on the blockchain:

Seedless wallets

Using wallet plugins is not user-friendly. Dealing with seed phrases is not secure for most users. Thanks to account abstraction, we can use web wallets and webauthn to simplify the user onboarding experience. Web wallets enable the creation of a wallet object within your browser that can be used across applications. You don’t need to install any extension.

Webauthn makes it even easier by enabling authentication from your registered devices(phone) instead of a username/password.

Multi-Call Transactions

Multi-call transactions offer a streamlined and efficient way to process multiple transactions within a single operation. Rather than executing transactions individually, developers can bundle multiple transactions into a single "transaction cart" and submit them as a single onchain call. This approach reduces the number of interactions and actions a user has to complete while playing a game.

Session Keys

Session Keys are like "hot private keys" that can sign transactions on behalf of a user for a limited time within a specific scope. The user is guaranteed that a dApp can only execute transactions that comply with the rules set up for that session until the session expires. Game developers can use session keys to give users a more seamless experience by temporarily delegating the user's transaction signing capabilities to the dApp during a gaming session. Session keys ensure that users don't need to repeatedly interact with a wallet for authorization during the game.

Fee Abstraction

Another interesting benefit of account abstraction is that it simplifies how users pay transaction fees. Fee abstraction allows fees to be paid in any token a user might have, or the game developers can sponsor fees for their users. It enables game developers to level up user experience to the same level as any web2 game.

Games Building on Starknet

Now that we've explored the key features of Starknet and the advantages it offers to game players and developers, let's take a closer look at some of the smartest teams working in this cutting-edge space.


Briq is an innovative NFT building protocol that enables users to collect construction blocks stored on the blockchain, known as briqs. These briqs are ERC-1155 tokens that reside on Starknet. Users can collect and assemble their briqs to create unique NFTs (ERC-721s). These can be transferred, sold, lent, or broken apart, giving users complete control over their NFTs. Users who wish to disassemble their set can retrieve their briqs and use them to build something new. Briq empowers users to unleash their creativity and use these assets in highly interoperable environments, such as metaverses. Users have the flexibility to integrate briqs in various ways, allowing for unique opportunities for creation, exploration, and innovation within the NFT ecosystem.


Realms is an onchain game world that operates as an "Autonomous World," where players known as Realm Lords hold dominion over the land and drive the expansion and economy of the realm. Realm Lords engage in wars, form alliances, and compete for scarce resources in this dynamic and strategic game. The success of a Realm Lord depends on their ability to balance resource acquisition, expansion, and defense of their realm. The game features 8,000 procedurally generated realms that have transitioned to high-fidelity 3D renders. Realms originated from the Loot phenomenon and was envisioned as a modular and continually evolving game that seamlessly incorporates Loot assets. Initially known as "Eternum" or "Eternal Game," it later embraced the concept of "Autonomous Worlds" to describe the larger framework in which the game operates. Realms aims to be the first title launched within the broader Realms Autonomous World, offering players an immersive and ever-expanding gaming experience.


Influence is an immersive and persistent space strategy game set in a distant asteroid belt. Players can compete through various activities such as mining, building, trading, researching, and fighting. With a game-first approach, Influence prioritizes the economy and offers a play-to-earn model, making it one of the first fully playable MMOs on Starknet. The game introduces a novel game mechanic of realistic orbital mechanics, resulting in the real-time movement of 250,000 asteroids and creating a dynamic and ever-changing strategic setting. Inspired by science fiction works like Eve Online and The Expanse, Influence aims to provide a decentralized gaming experience where players' transactions are recorded onchain, leveraging Starknet's Layer 2 scaling to ensure efficient and cost-effective transactions. With a player-owned open economy and a focus on deep strategy and virtual economies, Influence offers players a gripping journey in a vast and immersive space universe.


Cartridge makes it easier to build autonomous worlds by providing the fundamental building blocks and infrastructure for onchain games. Cartridge supports developers in fully realizing the possibilities within the onchain gaming world, allowing them to go beyond simple asset-based gameplay and incorporate sophisticated game logic. Cartridge is paving the way for an expanding ecosystem of onchain games on Starknet.


Dojo is a crucial part of the onchain gaming and autonomous worlds development on Starknet. Dojo provides game developers with a software framework for producing high-quality games by acting as a verifiable game engine and a toolchain. The main goal of Dojo is to simplify the difficulties that come with onchain games so that creators can focus on the innovative aspects of game development without getting bogged down by infrastructure needs.


The JediSwap community would like to express our sincere gratitude to Sylve (Briq, Dojo), Tarrence (Cartridge, Dojo), Loaf (Realms, Dojo), Chris (Influence), Liron (Starkware) and Eli (Starkware) for generously sharing their time and expertise during our interviews and article reviews. Their valuable input has greatly contributed to the creation of this article. We appreciate their insights and their willingness to share their expertise. We're excited to follow their progress as they continue to build and lead the onchain gaming space. Thanks to Glyn (Writers Guild at JediSwap) and Rohit (Co-Founder at JediSwap) for writing this article. Thanks to Chesse and Roxter for reviewing the draft and making it a powerful piece.

Subscribe to JediSwap
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
This entry has been permanently stored onchain and signed by its creator.