This guide covers environment variables, network configuration, and deployment settings for the Agora DAO platform.
Environment variables
Agora DAO uses environment variables to configure both the frontend (Next.js) and smart contracts (Hardhat).
Frontend configuration
Create a .env.local file in the packages/nextjs/ directory:
# Alchemy API Key for RPC access
NEXT_PUBLIC_ALCHEMY_API_KEY=your_alchemy_api_key
# WalletConnect Project ID for wallet connections
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=your_walletconnect_project_id
Getting API keys
Alchemy API Key
- Sign up at Alchemy Dashboard
- Create a new app
- Copy your API key
WalletConnect Project ID
- Sign up at WalletConnect Cloud
- Create a new project
- Copy your Project ID
For local development, default API keys are provided in scaffold.config.ts, but you should obtain your own for production apps.
Hardhat configuration
Create a .env file in the packages/hardhat/ directory:
# Alchemy API Key for network access
ALCHEMY_API_KEY=your_alchemy_api_key
# Etherscan API Key for contract verification
ETHERSCAN_V2_API_KEY=your_etherscan_api_key
# Encrypted deployer private key (auto-generated)
DEPLOYER_PRIVATE_KEY_ENCRYPTED=
Never manually fill in DEPLOYER_PRIVATE_KEY_ENCRYPTED. Use yarn generate to generate a new account or yarn account:import to import an existing private key.
Network configuration
Network settings are configured in scaffold.config.ts:
const scaffoldConfig = {
// The networks on which your DApp is live
targetNetworks: [chains.hardhat],
// The interval at which your front-end polls the RPC servers for new data
pollingInterval: 30000,
// Alchemy API key
alchemyApiKey: process.env.NEXT_PUBLIC_ALCHEMY_API_KEY || DEFAULT_ALCHEMY_API_KEY,
// RPC overrides for specific networks
rpcOverrides: {
// Example:
// [chains.mainnet.id]: "https://mainnet.rpc.buidlguidl.com",
},
// WalletConnect project ID
walletConnectProjectId: process.env.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID || "3a8170812b534d0ff9d794f19a901d64",
// Only show the Burner Wallet when running on hardhat network
onlyLocalBurnerWallet: true,
} as const satisfies ScaffoldConfig;
From scaffold.config.ts
Changing target networks
To deploy on a different network, update the targetNetworks array:
import * as chains from "viem/chains";
// For Sepolia testnet
targetNetworks: [chains.sepolia]
// For multiple networks
targetNetworks: [chains.mainnet, chains.sepolia]
Custom RPC endpoints
Override RPC endpoints for specific networks:
rpcOverrides: {
[chains.mainnet.id]: "https://mainnet.rpc.buidlguidl.com",
[chains.sepolia.id]: "https://sepolia.rpc.buidlguidl.com",
}
Contract deployment configuration
Hardhat network configuration is defined in hardhat.config.ts:
Supported networks
networks: {
hardhat: {
forking: {
url: `https://eth-mainnet.alchemyapi.io/v2/${providerApiKey}`,
enabled: process.env.MAINNET_FORKING_ENABLED === "true",
},
},
mainnet: {
url: "https://mainnet.rpc.buidlguidl.com",
accounts: [deployerPrivateKey],
},
sepolia: {
url: `https://eth-sepolia.g.alchemy.com/v2/${providerApiKey}`,
accounts: [deployerPrivateKey],
},
arbitrum: {
url: `https://arb-mainnet.g.alchemy.com/v2/${providerApiKey}`,
accounts: [deployerPrivateKey],
},
optimism: {
url: `https://opt-mainnet.g.alchemy.com/v2/${providerApiKey}`,
accounts: [deployerPrivateKey],
},
polygon: {
url: `https://polygon-mainnet.g.alchemy.com/v2/${providerApiKey}`,
accounts: [deployerPrivateKey],
},
base: {
url: "https://mainnet.base.org",
accounts: [deployerPrivateKey],
},
// ... and more
}
From hardhat.config.ts:48-129
Solidity compiler settings
solidity: {
compilers: [
{
version: "0.8.20",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
],
}
From hardhat.config.ts:27-40
Etherscan verification
Configure Etherscan API key for contract verification:
etherscan: {
apiKey: `${etherscanApiKey}`,
},
verify: {
etherscan: {
apiKey: `${etherscanApiKey}`,
},
}
Contract addresses
Deployed contract addresses are stored in contracts/deployedContracts.ts. After deployment, this file is automatically updated with:
- Contract addresses
- ABIs
- Network information
Example structure:
const deployedContracts = {
31337: {
AgoraDaoFactory: {
address: "0x5FbDB2315678afecb367f032d93F642f64180aa3",
abi: [...],
},
AgoraDao: {
address: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
abi: [...],
},
},
};
Local development setup
Clone the repository
git clone <repository-url>
cd agora-dao
Set up environment variables
# Frontend
cp packages/nextjs/.env.example packages/nextjs/.env.local
# Hardhat
cp packages/hardhat/.env.example packages/hardhat/.env
Edit the files with your API keys.Generate deployer account
This creates an encrypted private key in your .env file. Start local blockchain
Starts a local Hardhat network on http://localhost:8545. Deploy contracts
In a new terminal:This deploys contracts and generates TypeScript ABIs. Start the frontend
In a new terminal:Frontend runs on http://localhost:3000.
Production deployment
Deploying contracts
Configure target network
Update scaffold.config.ts with your target network:targetNetworks: [chains.sepolia]
Fund deployer account
Ensure your deployer account has sufficient funds for deployment and gas fees.
Deploy to network
yarn deploy --network sepolia
Verify contracts
yarn verify --network sepolia
Deploying frontend
For Vercel deployment:
- Push your code to GitHub
- Import project in Vercel
- Add environment variables in Vercel dashboard:
NEXT_PUBLIC_ALCHEMY_API_KEY
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID
- Deploy
Vercel automatically detects Next.js and configures build settings.
Storage configuration
Agora DAO uses IPFS for storing DAO logos. The upload endpoint is at /api/upload-image/route.ts.
Image upload specifications
- Maximum file size: 1 MB
- Supported formats: JPEG, PNG, JPG
- Recommended dimensions: 100x100 pixels
- Storage: IPFS
Burner wallet configuration
For local development, burner wallets are enabled:
onlyLocalBurnerWallet: true
This restricts burner wallet to local networks only. For testnets and mainnet, users must connect with MetaMask or WalletConnect.
Troubleshooting
RPC errors
If you encounter RPC connection errors:
- Verify your
NEXT_PUBLIC_ALCHEMY_API_KEY is correct
- Check network connectivity
- Try using an RPC override in
scaffold.config.ts
Contract deployment fails
- Ensure deployer account has sufficient funds
- Check network configuration in
hardhat.config.ts
- Verify
ALCHEMY_API_KEY is set correctly
TypeScript ABI errors
Regenerate ABIs after contract changes:
The deploy task automatically runs generateTsAbis script.
Next steps