Transactions and querying local storage
Last updated
Last updated
As mentioned in a previous section, the game's graphical interface provides a nice way to interact with the data that sits on the Nine Chronicles blockchain. All game data sits on the blockchain which means a copy of this data is stored by all people who run the blockchain software.
It is worth noting that the storage component of any blockchain is a database. Whenever we want to extract data from a blockchain we are actually querying a database. One nice illustration of this is the in-game marketplace. Whenever players view the marketplace inside the game, the game's software queries a database that's stored locally on players' computers. One such query is to retrieve a list of “all items for sale”.
The various filters that players can select in the user interface are different queries built into the game client. As our code is open source, then any developer can figure out how to create their own queries. Planetarium has released an API which should make querying easier, as it offers an enhanced set of queries.
Making a purchase
We make queries in order to find something we want and in the case of the marketplace, we do this in order to make a purchase.
Once you have searched the market and found something you want to buy, then you click on the item and agree to the price by pressing “Buy”. This is perhaps the most obvious time that you expect to make a transaction to the blockchain since you are purchasing something.
As all actions that are stored on-chain, players sign their transaction with their private key. The game client signs the transaction and then sends it to the blockchain node software managed by the launcher software, which in turn broadcasts the transaction to the whole Nine Chronicles network.
This procedure of sending a signed transaction is similar for combat. In this case, the transaction the purchase of an item, while for combat a transaction is used to start the fight-sequence.
To re-iterate, all game actions that change the state of the game are recorded as transactions on the blockchain. Any 'action' that involves looking at something, such as clicking from one screen to another, or looking at items in the marketplace, are not recorded on-chain.
Making a sale
The process of selling is similar to buying. You select an item from your inventory then press “Sell”. This marks the item as “for sale”, which is also a transaction that tells everyone to update their database.
When items are marked for sale, or change ownership, there is an update to the game’s state. It is important that everyone playing the game agrees upon such changes, which is why all such changes are signed by your private key.
Only you have access to your private key which is one reason we have strong guarantees about the authenticity of actions within a blockchain.