This directory contains the Solidity smart contracts for the Web3 Gaming Platform.
- Node.js and npm installed
- Hardhat development environment
- Wallet with funds for deployment (testnet or mainnet)
- RPC endpoint for your target network
- (Optional) Block explorer API key for contract verification
- Install dependencies:
cd contracts
npm install
- Configure your network settings in
hardhat.config.js
- Add your private key and API keys to environment variables
Create a .env
file in the contracts directory with:
# Private key of the deploying wallet (without 0x prefix)
PRIVATE_KEY=your_private_key_here
# Network RPC URLs
POLYGON_RPC_URL=https://polygon-rpc.com/
MUMBAI_RPC_URL=https://rpc-mumbai.maticvigil.com/
BSC_RPC_URL=https://bsc-dataseed.binance.org/
XDC_RPC_URL=https://rpc.xinfin.network
# Block explorer API keys for verification
POLYGONSCAN_API_KEY=your_polygonscan_api_key
BSCSCAN_API_KEY=your_bscscan_api_key
npx hardhat compile
npx hardhat run scripts/deploy.js --network mumbai
npx hardhat run scripts/deploy.js --network polygon
# BSC Testnet
npx hardhat run scripts/deploy.js --network bscTestnet
# BSC Mainnet
npx hardhat run scripts/deploy.js --network bsc
# XDC Network
npx hardhat run scripts/deploy.js --network xdc
-
Update Frontend: Copy the deployed contract address and update
FACTORY_ADDRESS
insrc/hooks/useBlockchainDeploy.ts
-
Verify Contract (optional but recommended):
npx hardhat run scripts/verify.js --network <network> <contractAddress> <deploymentFee> <feeRecipient>
- Test Deployment: Use the admin panel to create a test collection and verify it deploys correctly
Keep track of your deployed contracts:
- Mumbai (Polygon):
0x...
- BSC Testnet:
0x...
- Polygon:
0x...
- BSC:
0x...
- XDC:
0x...
- Insufficient funds: Ensure your wallet has enough native tokens (MATIC, BNB, XDC) for gas
- Network connection: Verify your RPC URLs are working
- Private key format: Remove '0x' prefix from private key in .env
- Gas estimation: Some networks may require manual gas settings
The contracts are optimized for gas efficiency:
- CollectionFactory: ~2.5M gas
- GameNFTCollection: ~3M gas per deployment
- Never commit private keys to version control
- Use testnet first before mainnet deployment
- Verify contracts on block explorers
- Test all functions after deployment