Now there are regular announcements about NFT-metaverse-blockchain-games that have attracted investments of millions of dollars estimated at billions, but when studying projects, there are either Coming Soon dice, or the sale of JPG-pictures at auctions of NFT-tokens, or centralized projects with homeopathic doses of blockchain. Before calling it all a hype bubble, I decided to figure out the technology stack on my own and make my own NFT blockchain game with a minimum of resources. Read under the cut how I did it in just 2 days, and also buy my NFTs (no).
The main criteria for creating a game for me were the following:
- Victory is determined by skill, not randomness
- Ability to play against real people for real money
Problems to be solved:
- Confidence. Before putting money on the line, the player must be sure that he will definitely receive the pot if he wins, and the rules of the game will not be changed.
- Simplicity. If it is difficult to deposit/withdraw money or understand the game, this narrows the circle of players.
- Lack of personal resources. I need to do this with minimal time and, preferably, without legal consequences.
There was no need to accept payments because, in the blockchain, each account is automatically a wallet. If the whole game is put into a smart contract, then it will turn out to be trustless, since it does not require a server/backend and therefore does not imply the presence of a trust center. You just need to trust the code. Players send all their actions to a smart contract, which processes them and at the end decides who won and then automatically pays the prize.
A smart contract (or decentralized application, dApp) is a kind of autonomous immutable entity (microservice) that operates in a distributed network (blockchain) and runs in containers on validator servers. Validators have a financial incentive to behave correctly and remain accessible. In this way, game users can trust that the code will work in a predictable way, and its author will not be able to run away with money by shutting down the servers.
It was quite expensive to execute transactions on the “first wave” blockchains, but in recent years there have been many solutions with extremely cheap transactions, something like $0.001 per “turn” with a confirmation time of 1 second. Of course, you can’t build RTS or shooters here, but at least board and logic games already look suitable. Also, the use of new Wasm blockchains as a virtual machine allows us not to reinvent the wheel of our own game mechanics, but to use something previously written and laid out in Open Source.
I decided to start with a regular game of checkers, using someone else’s ready-made code to the maximum. I opened git, ran a search, and took the first links from the search results: ready-made code for the game logic ( rusty-checkers ) and JS UI for the frontend ( checkers ).