This document outlines all the changes needed to deploy the Harbor App to Ethereum mainnet.
The following features automatically work in production:
- Anvil-specific hooks -
useAnvilContractReadanduseAnvilContractReadsautomatically use wagmi in production (whenNODE_ENV !== 'development') - Environment detection -
shouldUseAnvil()returnsfalsein production by default - Fallback price - Only applies in development mode, won't affect production
- Debug logging - All
process.env.NODE_ENV === 'development'checks are automatically disabled in production
File: src/config/contracts.ts
Replace the Anvil contract addresses with your mainnet deployment addresses:
export const contracts = {
minter: "0x...", // Mainnet minter address
peggedToken: "0x...", // Mainnet pegged token address
leveragedToken: "0x...", // Mainnet leveraged token address
genesis: "0x...", // Mainnet genesis address
reservePool: "0x...", // Mainnet reserve pool address
stabilityPoolManager: "0x...", // Mainnet stability pool manager address
feeReceiver: "0x...", // Mainnet fee receiver address
priceOracle: "0x...", // Mainnet price oracle address (Chainlink or similar)
collateralToken: "0x...", // Mainnet stETH address
wrappedCollateralToken: "0x...", // Mainnet wstETH address
} as const;File: src/config/markets.ts
Update the market addresses to reference the new mainnet contract addresses from contracts.ts. The file already imports from contracts.ts, so updating contracts.ts should be sufficient, but verify the stability pool addresses are correct.
Environment Variable: NEXT_PUBLIC_GRAPH_URL
Set this in your production environment (e.g., Vercel, Netlify, etc.):
NEXT_PUBLIC_GRAPH_URL=https://api.studio.thegraph.com/query/<your-subgraph-id>/harbor-marks/latestOr if using The Graph Network:
NEXT_PUBLIC_GRAPH_URL=https://gateway.thegraph.com/api/<api-key>/subgraphs/id/<subgraph-id>File: src/config/graph.ts - Update the default production URL if needed.
File: src/config/wagmi.ts
✅ Already handled automatically! The wagmi config now:
- Automatically removes Anvil from chains in production
- Puts mainnet first in production
- Uses environment variables for RPC URLs
Optional: Set custom RPC URLs in production (recommended for better performance):
NEXT_PUBLIC_MAINNET_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/your-api-key
NEXT_PUBLIC_BASE_RPC_URL=https://mainnet.base.org
NEXT_PUBLIC_ARBITRUM_RPC_URL=https://arb1.arbitrum.io/rpcFile: subgraph/subgraph.yaml
Update the network and contract addresses:
dataSources:
- kind: ethereum
name: Genesis
network: mainnet # Change from 'anvil'
source:
address: "0x..." # Your mainnet Genesis contract address
abi: Genesis
startBlock: 12345678 # Block where Genesis was deployedSet these in your production environment:
# Required
NEXT_PUBLIC_GRAPH_URL=https://api.studio.thegraph.com/query/...
NEXT_PUBLIC_USE_ANVIL=false # Explicitly disable Anvil mode (optional, defaults to false in production)
# Optional (recommended for better performance)
NEXT_PUBLIC_MAINNET_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/your-api-key
NEXT_PUBLIC_BASE_RPC_URL=https://mainnet.base.org
NEXT_PUBLIC_ARBITRUM_RPC_URL=https://arb1.arbitrum.io/rpcFile: src/app/genesis/page.tsx
The fallback price (line ~867) only applies in development mode, so it won't affect production. However, if you want to remove it entirely or change the logic:
// Current: Only uses fallback in development
if (collateralPriceUSD === 0 && process.env.NODE_ENV === "development") {
// fallback logic
}
// For production, you might want to:
// - Remove the fallback entirely (let it fail if oracle is down)
// - Or add a production fallback with a warningBefore deploying to mainnet:
- Test with
NEXT_PUBLIC_USE_ANVIL=falselocally to ensure production mode works - Verify contract addresses are correct for mainnet
- Test GraphQL queries against your production subgraph
- Verify price oracle is working (no fallback in production)
- Check RPC endpoints are accessible and rate-limited appropriately
- Test wallet connections on mainnet
- Update all contract addresses
- Set environment variables in your hosting platform
- Deploy subgraph to The Graph Network
- Build and deploy the frontend
- Verify all features work on mainnet
- The code automatically switches to production mode when
NODE_ENV=production - Anvil-specific behavior is disabled by default in production
- All debug logging is automatically disabled in production builds
- The fallback price only applies in development, so production will use the actual oracle price