Description -> Web3 based battle game.
To run this project locally, follow these steps.
- Install Git
- Install Node.js version "v18.16.0" for this dapp, use nvm for better management of node versions.
- Install Yarn (optional)
- Install Metamask
- Create RPC API Enpoint for Avalanche Test Network Fuji(C-chain)
Please follow screenshots
-
-
Fuji url: '[https://app.zeeve.io/shared-api/avax/100eff9d918b3e643441492c6aa5b2794dbffa7326e42e5d/]
Fuji's C-Chain: (https://app.zeeve.io/shared-api/avax/3fa74ad9c39f971208a9fe279896372d3ccf05c05dad07c0/ext/bc/C/rpc)'
-
Chain Id: 43113
-
-
Fund your wallet from the Avax Faucet
git clone https://github.com/Zeeve-App/sample-dapps.git
cd sample-dapps/dapps/project_web3_battle_game
cd web3
-
npm install
-
Create a
.env
file and specify a PRIVATE_KEY variable. -
To get to the private key, do the following steps:
- Click on the identicon in the top right.
- Select the account you'd like to export.
- On the account page, click on the menu (three dots) in the upper right corner, and then on the "Account Details" button.
- Click “Export Private Key”.
- To access your private key, you'll now need to enter your wallet password. Once you've done so, click “Confirm” to proceed.
- Your private key will now be revealed. Click to copy it, and save it somewhere safe. (Note: we aren't showing it in the below screenshot for obvious reasons -- but yours will be there.)
- Click “Done” to close the screen.
and update .env file
-
Compile the contract by running the
npx hardhat compile
command -
To deploy to Fuji Avalanche test network, update the configurations located in hardhat.config.ts to use a private key and, deploy to a private RPC like Zeeve.
Go to Zeeve RPC endpoint
Click on View Chains and copy HTTPS e.g. for reference and update config file. https://app.zeeve.io/shared-api/avax/3fa74ad9c39f971208a9fe279896372d3ccf05c05dad07c0/ext/bc/C/rpc
import dotenv from 'dotenv';
import '@nomiclabs/hardhat-ethers';
dotenv.config();
export default {
solidity: {
version: '0.8.16',
settings: {
viaIR: true,
optimizer: {
enabled: true,
runs: 100,
},
},
},
networks: {
fuji: {
url: 'https://app.zeeve.io/shared-api/avax/3fa74ad9c39f971208a9fe279896372d3ccf05c05dad07c0/ext/bc/C/rpc',
gasPrice: 225000000000,
chainId: 43113,
accounts: [process.env.PRIVATE_KEY],
},
},
}
- Deploy the smart contract on the Fuji test network by running the
npx hardhat run scripts/deploy.ts --network fuji
command
Move the /artifacts/contracts/AVAXGods.json
file to the /contract
folder on the frontend application client
Copy the address of the deployed contract from the terminal and paste it into the /src/contract/index.js
file of the frontend application client
-
cd client
-
npm install
-
npm run dev