Saving game state
How to save the state of a game in a Solana program
You can use Solana blockchain to save the state of your game in program
accounts. These are accounts that are owned by your program and they are derived
from the program ID and some seeds. These can be thought of as database entries.
We can for example create a PlayerData account and use the players public key as
a seed. This means every player can have one player account per wallet. These
accounts can be up to 10Kb by default. If you need a bigger account look into
how to handle big accounts
This can be done in a program like this:
You can then interact with this player data via transaction instructions. Lets
say we want the player to get experience for killing a monster for example:
This is how this would look like from a JavaScript client:
How to actually build this energy system you can learn here:
Building an Energy system