How NFT and items will be transferred in and out of the game?

Details can differ a bit depending on the blockchain, but in the case of solidity smart contracts the flow is the following:

  1. User registers a game account.

  2. User logs into the blockchain wallet (metamask, trust, etc).

  3. User securely links the wallet to the game account via signing a message with Private Key from the wallet and sending a rest API call to the backend. The backend then verifies the sig in order to make sure that was an intended and secure action.

  4. After that user can initiate, let’s say, minting a game item into NFT or burning an NFT to transfer it into the game.

4.1. In order to deposit the NFT (in case of EVM compatible networks) the user calls nftContract.approve() and calls nftGate.depositNft(), where the contract does transferFrom, burns the nft and emits the event. Observer service (the one monitoring blockchain for new events on specified contracts) catches that ‘NftDeposited’ event, and sends a command to RabbitMQ. Game Backend receives that command and issues the item in the ingame database.

4.2. In order to withdraw the nft user calls nftGate.withdrawNftRequest(), and the contract emits the corresponding event. The Observer service catches the eveand nt, sends it to RabbitMQ. Game Backend receives that command and securely checks if the user can really mint an item (meaning he really has it in the game). If all is fine during the security checks - Game Backend sends a Mint command to RabbitMQ. NFT Gate receives the command and mints the NFT to the user’s address using the server Private Key.

5. All data received from the Observer is stored in a so-called ‘data warehouse’ (database), so it is easier to read data from the web frontend, backend and game client.

Last updated