Welcome to Avax Gods, an immersive Web3-powered multiplayer NFT card game built on the Avalanche blockchain! ๐โก This game lets players battle in a decentralized environment, trade unique NFT cards, and experience the power of smart contracts in gaming.
To deploy and interact with the smart contract, follow these steps carefully:
Move into the Web3 folder where the smart contract and blockchain logic are stored:
cd web3Set up Hardhat, the Ethereum development environment, by running:
npx hardhat- Select TypeScript when prompted (
y โ typescript โ enter โ enter). - This sets up a project with TypeScript support for better security and development experience.
You'll need several dependencies to work with smart contracts and blockchain interactions:
๐น OpenZeppelin Contracts for secure smart contract development:
npm install @openzeppelin/contracts dotenv @nomiclabs/hardhat-ethers๐น Hardhat Development Toolbox to ease contract deployment and testing:
npm install --save-dev "hardhat@^2.12.0" "@nomicfoundation/hardhat-toolbox@^2.0.0"For seamless interaction with the Avalanche blockchain, install Core Wallet, a Metamask alternative designed for Avalanche dApps.
After installing Core Wallet:
- Open the Core extension.
- Click the hamburger menu (โฐ) in the top left.
- Navigate to Advanced Settings.
- Turn on Testnet Mode to interact with the Fuji test network.
You need testnet AVAX tokens to deploy and interact with the smart contract.
- Visit the AVAX Faucet.
- Enter your wallet address and request free testnet AVAX.
To securely store your private key, create a .env file inside the web3 directory:
touch .envInside .env, add your PRIVATE_KEY:
PRIVATE_KEY=your_private_key_here- Open Core Wallet โ Click โฐ (menu).
- Go to Security & Privacy โ Click Show Recovery Phrase.
- Enter your password and copy the mnemonic phrase.
- Go to wallet.avax.network โ Click Access Wallet.
- Select Mnemonic Key Phrase โ Paste your recovery phrase.
- In the sidebar, go to Manage Keys โ View C-Chain Private Key.
- Copy your private key and paste it into the
.envfile.
๐ด WARNING: Never share your private keyโtreat it like your password!
hardhat.config.tsโ Configuration file for Hardhat.deploy.tsโ Deployment script.AvaxGods.solโ The actual smart contract.
Ensure there are no syntax errors before deployment:
npx hardhat compileIf everything is correct, youโll see a success message confirming compilation.
Run the following command to deploy your smart contract:
npx hardhat run scripts/deploy.ts --network fujiAfter deployment, copy the contract address displayed in the terminal.
Once the contract is deployed, move the compiled AVAXGods.json file into the frontend:
mv artifacts/contracts/AVAXGods.json frontend/contractOpen /contract/index.js in the frontend and paste the contract address you copied earlier.
๐ Now your Avax Gods NFT card game is fully deployed on the Avalanche Fuji Testnet! Players can battle, trade NFTs, and experience decentralized gaming like never before.
๐ก Want to customize the game? Modify the Solidity smart contract and React frontend to add new features!
๐ฌ If you run into any issues, feel free to ask for help or contribute to the project!
Happy coding, and may the best player win! ๐๐ฅ
