npm installCopy .env.example to .env.local and fill in:
cp .env.example .env.localKey variables:
PRIVATE_KEY— Testnet wallet private key for deploymentsNEXT_PUBLIC_BTQ_ADDRESS— Deployed contract addressNEXT_PUBLIC_BTQ_RATE_NATIVE_PER_BTQ— Exchange rate (default: 0.001)- RPC URLs for each chain
npm run deploy:arbitrum-sepolianpm run deploy:arbitrum-onenpm run deploy:robinhoodAfter deployment, add the contract address to .env.local:
NEXT_PUBLIC_BTQ_ADDRESS=0x<contract-address>
npm run devVisit http://localhost:3000, connect your wallet, and buy BTQ!
Providers:
WalletProvider— Wraps app with Wagmi + RainbowKit- Supports Arbitrum Sepolia, Arbitrum One, and Robinhood testnet (configurable via env)
Components:
ConnectWallet— RainbowKit button; auto-saves wallet address to localStorage as player IDBuyBTQ— Purchase BTQ tokens; reads contract address and rate from env; uses wagmi hooks
Pages:
Lobby— Shows Connect Wallet button in headerProfile— Wallet status, BTQ balance, Buy BTQ form
BTQToken.sol:
- ERC20 token (OpenZeppelin)
buy()payable function: swap native → BTQ at configured rate- Owner can update rate and withdraw accumulated native currency
- Default rate: 1 BTQ = 0.001 native token (adjustable)
Deployment:
- Hardhat scripts deploy to multiple chains
- Uses environment variables for RPC URLs and keys
| Chain | Chain ID | RPC | Testnet |
|---|---|---|---|
| Arbitrum Sepolia | 421614 | https://sepolia-rollup.arbitrum.io/rpc |
✅ |
| Arbitrum One | 42161 | https://arb1.arbitrum.io/rpc |
❌ |
| Robinhood Testnet | ROBINHOOD_CHAIN_ID |
ROBINHOOD_TESTNET_RPC |
✅ |
When a user connects a wallet:
ConnectWalletcomponent captures wallet address- Address is formatted as short string (e.g.,
0x1234...abcd) - Stored in
localStorageasbattleq_user - Replaces guest ID; used throughout the game as player identifier
- Smart contract tracks tokens per wallet address
Default: 1 BTQ = 0.001 testnet native token
Example:
- User sends 0.1 testnet → receives 100 BTQ
- User sends 1 testnet → receives 1000 BTQ
To adjust rate after deployment:
const rate = ethers.utils.parseEther("0.002"); // 1 BTQ = 0.002 native
await btqContract.setRate(rate);- Use a testnet faucet to get test tokens (e.g., Arbitrum Sepolia faucet)
- Deploy BTQ to testnet via
npm run deploy:arbitrum-sepolia - Add contract address to
.env.local - Run dev server:
npm run dev - Connect wallet in browser; buy BTQ to test
- Click Connect Wallet in Lobby header
- Select wallet and approve connection
- Verify
NEXT_PUBLIC_BTQ_ADDRESSis set in.env.local - Ensure contract is deployed to the connected chain
- Get testnet tokens from official faucet (e.g., Arbitrum Sepolia Faucet)
- Check gas balance
- Verify RPC endpoint is working
- Ensure account has deployment permissions (for
setRateorwithdraw)
# Frontend
NEXT_PUBLIC_SOCKET_URL=http://127.0.0.1:3001
NEXT_PUBLIC_BTQ_ADDRESS=0x...
NEXT_PUBLIC_BTQ_RATE_NATIVE_PER_BTQ=0.001
NEXT_PUBLIC_ROBINHOOD_CHAIN_ID=1337
NEXT_PUBLIC_ROBINHOOD_RPC=https://testnet.chain.robinhood.com/rpc
NEXT_PUBLIC_ROBINHOOD_EXPLORER=https://explorer.robinhood.com
# Deployment
PRIVATE_KEY=your_testnet_key
ARBITRUM_SEPOLIA_RPC=https://sepolia-rollup.arbitrum.io/rpc
ARBITRUM_ONE_RPC=https://arb1.arbitrum.io/rpc
ROBINHOOD_TESTNET_RPC=https://testnet.chain.robinhood.com/rpc
ROBINHOOD_CHAIN_ID=1337
# Explorers (optional, for verification)
ARBISCAN_API_KEY=
ROBINHOOD_EXPLORER_API_KEY=- Testnet Testing — Deploy to all three testnets, run E2E tests
- Mainnet Ready — Prepare for Arbitrum One production deployment
- Player Wallets — Integrate wallet history & asset tracking
- Staking Contracts — Build escrow for match stakes