This project implements a decentralized battle game using Ethereum smart contracts. Players can mint tokens, battle with mages, and interact with the blockchain through MetaMask. The game integrates various smart contracts such as ChronoToken
, MageNFT
, and BattleManager
to manage in-game functionality and assets.
ethers.js
.Before you begin, ensure you have the following installed:
ChronoToken
, MageNFT
, and BattleManager
.git clone https://github.com/your-username/chrono-battle-game.git
cd chrono-battle-game
Copy
Edit
npm install
Deploy the smart contracts for:
ChronoToken (ERC-20 Token)
MageNFT (ERC-721 NFT)
BattleManager (Battle logic)
Ensure you update the app.js with the correct deployed contract addresses and ABIs.
Start a local development server to host the frontend:
Copy
Edit
npm start
This will open the app in your browser, and you will be able to interact with the smart contracts via MetaMask.
The project contains the following contracts:
ChronoToken.sol: ERC-20 token for in-game currency.
MageNFT.sol: ERC-721 contract for creating Mage NFTs.
BattleManager.sol: Logic to manage battles, including interactions with Mages and bosses.
You can find the contract ABIs in the abi/ folder. These ABIs are needed to interact with the deployed contracts using ethers.js.
Connect Wallet: Click the “Connect Wallet” button to connect MetaMask.
Mint Tokens: You can mint ChronoTokens by entering the amount.
Mint Mage NFTs: Use the mint button to create new Mage NFTs.
Start Battle: Select your Mage NFT and start a battle against a boss using predefined moves.
Example: To start a battle, follow these steps:
Mint a Mage NFT.
Select a boss.
Choose the moves you want to execute (attack, heal, etc.).
Start the battle and watch the outcome!
MetaMask wallet connection may fail if not properly configured.
The BattleManager contract may fail with certain invalid inputs (ensure moves and Mage ID are valid).
Feel free to fork the repository and submit pull requests to improve the game functionality, fix bugs, or add new features.
This project is licensed under the MIT License.