Solana Game Examples includes many open source game examples and tools for game development. Looking at these examples and seeing how certain features are implemented can vastly improve your development speed. If you have other example games feel free to submit a PR.
Using create-solana-game #
A simple npx command that sets up a new Solana game project with a Unity client, Anchor program and a Next.js frontend. Supported features are:
- Wallet adapter
- Anchor program
- Unity client
- Next.js frontend
- Renaming all mentions of the project to your own game's name
- NFT and compressed NFT support
- Session keys for auto approving transactions
With this command you can easily set up a new game with all these features working and ready go:
npx create-solana-game your-game-name
Here you can learn how it works:
Interacting with Anchor Programs from Unity #
Tiny adventure is a simple example moving a player left and right onchain using Anchor framework and Unity SDK.
Saving SOL in a PDA #
Learn how to save SOL in a PDA seed vault and send it back to a player. This backend is written in Anchor and the frontend is using the Unity SDK.
Use Solana Pay QR codes to control a game #
Solana Pay transaction requests can not only be used for payments but for signing any transactions on a phone wallet or a link, including for games. Tug of war is a multiplayer game which can be player with many people on a big screen, using Solana Pay QR codes to pull the rope one way or the other, which in turn changes data in an account. The rewards will be payed out to the team that manages to the rope pull completely to one side. The backend is Anchor and the frontend is React.js and Next.js 13.
How to build a round-based multiplayer game #
A simple multiplayer tic tac toe game written in Anchor
Onchain Chess #
Complete onchain playable chess game written in Anchor with a 3D Unity implementation. Send someone a link to start a game.
Multiplayer Game using voting system #
A Pokemon-style game where people collectively vote on moves. Every move is recorded and each move can be minted as an NFTs.
Entity component system examples #
MagicBlock Bolt #
MagicBlock Bolt is an onchain entity component system. MagicBlock is also
working on an ephemeral rollup system for super fast transactions.
Arc Framework #
Kyoudai Clash is an on chain realtime strategy game using the Jump Crypto Arc framework which is an onchain entity component system for Solana (not maintained anymore).
Hide game state from other players #
Hiding data on chain is difficult because all accounts, including data accounts, are public and can be read by anyone. There are some solutions to the problem though.
Light protocol #
Light protocol is a ZK layer solution on Solana that lets you built on Solana
with ZK compression, a new primitive that enables the secure scaling of state
directly on the L1.
Race Protocol #
Race protocol is building an on chain poker game and have two solutions for
hiding data. One is server-based and one relies on players sending encrypted
data to each other.
Stone paper scissors #
A game where onchain data is hidden by saving a hash in the client until reveal. SPL Tokens are given as prizes for the winner.
Tilted Fish Games #
Another example submitted for the Grizzlython hackathon, which encrypts entries and sends them to the next player with an additional encryption:
Adventure killing monsters and gaining xp #
Lumia online was a hackathon submission and is a nice reference for a little adventure game.
Real-time pvp onchain game #
Solana Civ #
A Civilization-style game where you can build cities, trade with other players and fight wars. Progress through the ages by unlocking new technologies, conquer lands and build a civilization that will stand the test of time. All open source and crowd-built by the Solana community, through gib.work.
Seven Seas #
Seven Seas is a real-time Solana Battle Royale game. Using an Anchor program, the UnitySDK, and WebSocket account subscriptions. Players can spawn their ships represented as NFTs on a grid and move around. If a player hits another player or chest he collect its SOL and some Pirate Coin SPL tokens. The grid is implemented as a two dimensional array where every tile saves the players wallet key and the NFT public key. There is also a QR code in the top left corner that triggers a Solana Pay transaction request, which players can sign on their phones, to let Cthulhu shoot at the closest ship.
Blob Wars onchain strategy game ala Dark Forest #
Blob Wars shows you how you can build a strategy game like Dark Forest or Tribal Wars, but without the ZK features. Every player spawns their home blob with a color that is derived from their public key. These blobs can then be used to attack other blobs and conquer them. Blobs regenerate color over time, so there are lots of tactics involved on where to spawn blobs and how to combine attacks.
Tale of Kentridge #
This is a game built with the Turbo game engine. Turbo is a from the ground up freshly written Rust game engine which focuses on lightweight architecture and fast iteration times always with Solana in mind. It is beginner friendly and comes with full Solana RPC support. You can even use its AI tools to generate complete games.
Roguelike game #
A game where you can explore a cave and find treasures. The game is written in Anchor and the frontend is a Unity client. You progress through a cave from level 0 to 100 to fight the ultimate enemy. Every time you die you start again from level 1. There are chests that offer items and resources and the items from blue chests can be kept for the next run. A special feature is that a floor can be owned by a certain player and when you pass that floor you either need to fight that player or pay a little fee to be able to pass.
On-chain city builder example #
This example shows you how you can build an onchain city builder. The special feature is that it is a competitive but also cooperative city builder since all resources are shared between the players, but depending if you build your
buildings on the left or the right you either support the goblins or the humans.
Rebirth rumble PVP battler #
A 5 vs 5 PVP game where you can fight against other players. The game is written in Anchor and the frontend is a Unity client. You can choose between different characters and fight against other players. The game is still in development and was the winner of the second Solana Speedrun.
onchain matchmaking #
A multiplayer match three game which uses NFT stats for the character stats in the game and has an interesting onchain matchmaking system.