How to build a Web3 Play-to-Earn P2E game: architecture

In this series we’ll explore how to build a Web3 game from scratch based on one of the games that the Fungies team has built, which is Ultimate Battle Arena – a trading card game on Polygon blockchain. 

Ultimate Battle Arena is a blockchain game on the Polygon / Matic Chain Network that allows players to purchase, collect, fuse and sell ultimates. More details are available in our Web3 game whitepaper.

Ultimate Battle Arena is an NFT game that's built on Polygon
Ultimate Battle Arena is an NFT game that’s built on Polygon

Assumptions:

  • The game will be a basic 2-D version.
  • The intent is to build a game which features similiar gameplays as AFK Arena and Hearthstone.
  • The game will be built on Unity WebGL.

Game Overview

Game Concept

Ultimate Battle Arena is an Axie Infinity-inspired universe where anyone can earn tokens through skilled gameplay and contributions. It’s a digital collection where players can battle, collect, modify and fuse their ultimates. Each ultimate has different stats which determine their role in the battle.  

Each ultimate is a non-fungible token (NFT). Each is unique and owned by the user, validated through block chain, and its value can be appreciated or depreciated based on the marketplace. Since ultimates are tokens on a blockchain, they can be bought, sold, or transferred digitally, with a guarantee of ownership.

Ultimates have an infinite number of copies on the Marketplace. Each copy has distinct stats stored in a smart contract. 

Target Audience 

The intended audience for this game are people aged eighteen and above. Due to the legalities associated with cryptocurrency, and in-game purchases; audiences under 18 will be excluded from the target market. Instead the application will focus on a market that encompasses the following: 

  • Can partake in buying and selling cryptocurrency.
  • Have an interest in blockchain and NFTs.
  • Users who are interested in a more interactive form of crypto-trading. 
  • Genre

The main genres of focus are: Non-fungible token, collectible card game.

  • Game Flow Summary 

In Ultimate Battle Arena, players will collect, modify, and battle NFT-based ultimates to earn tokens through their gameplay and contributions to the digital world. Players battle against other non-player characters in teams of 10 Cards to earn Benders of Valor (BOV) Token, with battle outcomes determined by cards played and the type of cards fighting. Players can fuse ultimates to produce new and unique ultimates, requires BOV, and is limited in the number of times each card may be fused.

The core loop diagram: 

Here’s a simple representation of UBA’s game – blockchain NFT Web3 game architecture:

Web3 Game Architecture
Web3 Game Architecture

Wallet Authorization for the game

Wallet Authorization

Before starting the game, players need to connect to a digital wallet, Meta mask. If a player has already added an extension in Chrome, a Meta Mask popup would be opened on the right side of the screen. 

If the player hasn’t added an extension, clicking on the connect wallet button takes the user to the MetaMask Chrome Extension page. 

There are multiple cases: 

  1. If the metamask extension is not installed.
  2. If the wallet is not logged in and the user clicks on the connect wallet button.
  3. If the user has entered the password to log into the meta mask wallet and then connect the wallet.
  4. If the user rejects the signature request.
  5. Upon buying the cards from the shop, the user rejects the mint request.
  6. Upon buying the cards from the shop, the user rejects the approval for the ULTI request.
Cryptocurrencies can be used to upgrade the NFT cards ingame
Cryptocurrencies can be used to upgrade the NFT cards ingame
  • If the metamask extension is not installed:


If the metamask extension is not installed in the browser, the user will be redirected to the https://metamask.io/download/ on another tab. Upon clicking the “Install Metamask for Chrome” button, users will be redirected to the chrome extension page where they can install the extension.After installation, users will set up their wallet accordingly. 

  • If the wallet is locked and the user clicks on the connect wallet button:


Users will click on the “Connect Wallet” button and a metamask pop up will appear asking for a password from users. Users will enter the password and click on the “Unlock” button. After unlocking, the pop up will ask to select the account. Two buttons at the bottom will decide the connection.
If users click the “Cancel” button, the metamask pop up will be closed and the users will have to click on “Connect Wallet” again.
If the users select an account and click on the “Next” button, step 2 pops up where users can cancel or connect to the wallet. On clicking “Connect”, the wallet will be connected.

  • If the user has entered the password to unlock the meta mask wallet and then connect the wallet:


A pop up will open that asks to select the account. Two buttons at the bottom will decide the connection.
If users click the “Cancel” button, the metamask pop up will be closed and the users will have to click on “Connect Wallet” again.
If the users select an account and click on the “Next” button, step 2 pops up where users can cancel or connect to the wallet. On clicking “Connect”, the wallet will be connected.

  • If the users rejects the signature request:


The flow won’t proceed and users will be redirected back to the previous screen. A pop up should appear that displays “ Canceled or Invalid Signature”. Users will only proceed if they sign the signature request. Users will stay on the current screen.

  • Upon buying the cards from the shop, the user rejects mint request:


If the user rejects a mint request, the user will be unable to buy packs from the shop. A pop up message should be displayed “Transaction Canceled” .The user will have to try again unless he/she approves the mint request.

  • Upon buying the cards from the shop, the user rejects the approval for the ULTI request:


If the user rejects approval for ULTI, the user will be unable to buy packs from the shop. Pop up should appear that displays the message “Transaction Canceled” and the previous state is shown.The user will have to try again unless he/she approves the transaction request.

Wallet authorization in a Web3 game
Wallet authorization in a Web3 game

A detailed view how to buy in-game currencies (soft currencies or blockchain tokens):

How the game's backend interacts with Blockchain data
How the game’s backend interacts with Blockchain data

NFT Settlements inside the game. Why is it important?

  • Everytime a player upgrates NFT card, the NFT needs to burned and a new one will be replaces with different metadata,
  • We didn’t implement dNFT’s (Dynamic NFT’s yet) – so in this case this was the only solution,
  • Settlement is important to keep the game’s database consistent with what’s on Blockchain

NFT Settlement flow with Game's Back-end
NFT Settlement flow with Game’s Back-end

End of Part 1. Stay tuned for Part 2 in which we’ll discuss the game’s smart contracts!

author avatar
Fungies
Fungies.io helps game developers create their own storefronts or marketplaces to sell directly to players. Web2 and Web3 compatible.

 

Fungies.io helps game developers create their own storefronts or marketplaces to sell directly to players. Web2 and Web3 compatible.

Post a comment

Your email address will not be published. Required fields are marked *