CHAIN BATTLES

On-Chain Dynamic Changing NFT Gaming

Description

Chain Battles is an NFT Game deployed on Mumbai Polygon test network.

You can mint and own a Warrior or Mage character of your choice with a started-base Statistics and a random Rarity (between 0 and 100).

After that, you can Train your NFT or character to increment its level and stats. Your character level and stats will change dynamically on your NFT!!

How it works

  1. Open the Contract on the Polygonscan test network Mumbai to interact with it: https://mumbai.polygonscan.com/address/0xa2d946c1e8317085aafb21c109dd58d20c802750#writeContract

  2. Connect your wallet to interact with the Contract (make sure you have MATIC in the Polygon Testnet (Mumbai) in your Metamask)

  3. Call the mintWarrior or mintMage function depending on the character class you desire to mint

  4. Check your NFT minted on Opensea testnets: https://testnets.opensea.io/

  5. Call the train function on the Contract introducing the id (number) of your token to increase the stats of your character

  6. Push the "Refresh metadata" button of your NFT on Opensea and reload the page after a minute to witness the magic of a dynamic changing NFT

  7. You can keep training your character and see how it levels up and gets BIGGER and STRONGER

Example Warrior and Mage NFTs

(click on them to check the NFT on polygon scan)

Features

  • Class: You can be a Warrior or a Mage depending on which class you minted. Warriors have a red background. Mages have a blue background.

  • Token Id: Each NFT is unique and has a token id associated with it (#1, #2, #3...., #n).

  • Level: Defines your Character level and count how many times you trained it. All characters start at level 1.

  • Health: Defines the Health or Hit Points (HP) of your character. Starting Health is 100 for all characters.

  • Attack: Defines the Attack points of your character. The base Attack is 10.

  • Defense: Defines the Defense points of your character. The base Defense is 10.

  • Speed: Defines the Speed points of your character. The base Speed is 10.

  • Rarity: Defines the Rarity of your character between 0 and 100. The value is defined randomly when the NFT is minted and never can be changed.

Training Mechanics

Every time you train your NFT by calling the train function of the Contract, the Statistics of your character will be modified randomly as follows:

  • Level: Increases by 1.

  • Health: Increases a random amount between 0 and 100.

  • Attack: Increases a random amount between 0 and 10.

  • Defense: Increases a random amount between 0 and 5.

  • Speed: Increases a random amount between 0 and 3.

  • Class, Token Id, and Rarity are defined when the NFT is minted and can not be changed.

Tech Stack

  • IDE: Visual Studio Code

  • Programming languages and libraries: Solidity, JavaScript, Hardhat, Ethers.js

  • Mumbai Node connection for contract deployment: Alchemy platform

Credits

This project is part and was inspired by the RoadToWeb3 challenge conducted by the Alchemy team