-
Set up your
.envfile with the following variables:PRIVATE_KEY=your_private_key_without_0x_prefix BASE_MAINNET_RPC_URL=https://mainnet.base.org ETHERSCAN_API_KEY=your_etherscan_api_key
-
Ensure you have ETH on Base Mainnet for gas fees:
- You need at least 0.001-0.01 ETH (gas prices vary)
- Bridge ETH to Base Mainnet if needed
-
Check your balance:
# Get your address cast wallet address --private-key $PRIVATE_KEY # Check balance on Base Mainnet cast balance <YOUR_ADDRESS> --rpc-url base_mainnet
Simulate the deployment to check for any issues without actually deploying:
forge script script/DeployTriviaBattle.s.sol:DeployTriviaBattle \
--rpc-url base_mainnetThis will show you:
- Estimated gas costs
- Contract addresses that will be used
- Any potential errors before spending real ETH
Once you're satisfied with the simulation, deploy with verification:
forge script script/DeployTriviaBattle.s.sol:DeployTriviaBattle \
--rpc-url base_mainnet \
--broadcast \
--verifyWhat this does:
--rpc-url base_mainnet: Uses the Base Mainnet RPC endpoint (from your.env)--broadcast: Actually sends the transaction to the network--verify: Automatically verifies the contract on Basescan after deployment
If you want to verify manually later, or if automatic verification fails:
forge script script/DeployTriviaBattle.s.sol:DeployTriviaBattle \
--rpc-url base_mainnet \
--broadcastThen verify manually:
forge verify-contract <CONTRACT_ADDRESS> \
contracts/TriviaBattle.sol:TriviaBattle \
--chain-id 8453 \
--etherscan-api-key $ETHERSCAN_API_KEY-
Save the contract address from the deployment output
-
Update your frontend configuration:
- Update
lib/blockchain/contracts.tswith the new contract address
- Update
-
Verify on Basescan:
- Visit:
https://basescan.org/address/<CONTRACT_ADDRESS> - Confirm the contract is verified and shows source code
- Visit:
-
Test the deployment:
- Ensure you have USDC on Base Mainnet
- Test basic contract functions
- Verify Chainlink integration if applicable
The contract is deployed with:
- USDC Address:
0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913(Base Mainnet USDC) - LINK Address:
0x88DFAAABAf06f3A41d260Bea10568C1B4794334C(Base Mainnet LINK) - Session Interval: 1 week (604800 seconds)
- Entry Fee: 1 USDC (1e6)
- Never commit your
.envfile to version control - Keep your private key secure
- Double-check all addresses before deploying
- Test thoroughly on Base Sepolia before mainnet deployment
📋 Post-Deployment Checklist:
- Contract deployed and verified on Basescan
- Contract address saved and updated in frontend
- Basic contract functions tested
- USDC balance sufficient for testing
- Chainlink addresses configured (if needed)
If deployment fails:
- Check your ETH balance is sufficient
- Verify RPC URL is correct and accessible
- Ensure private key is correct (without 0x prefix)
- Check gas prices - try during lower traffic times
If verification fails:
- Wait a few minutes and try manual verification
- Ensure ETHERSCAN_API_KEY is correct
- Check that contract code matches exactly
- Basescan: https://basescan.org
- Base Docs: https://docs.base.org
- Forge Docs: https://book.getfoundry.sh