Skip to main content
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
Variables prefixed with NEXT_PUBLIC_ are accessible on the client side. More info: Next.js Environment Variables

Getting API keys

Alchemy API Key
  1. Sign up at Alchemy Dashboard
  2. Create a new app
  3. Copy your API key
WalletConnect Project ID
  1. Sign up at WalletConnect Cloud
  2. Create a new project
  3. 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

1

Clone the repository

git clone <repository-url>
cd agora-dao
2

Install dependencies

yarn install
3

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.
4

Generate deployer account

yarn generate
This creates an encrypted private key in your .env file.
5

Start local blockchain

yarn chain
Starts a local Hardhat network on http://localhost:8545.
6

Deploy contracts

In a new terminal:
yarn deploy
This deploys contracts and generates TypeScript ABIs.
7

Start the frontend

In a new terminal:
yarn start
Frontend runs on http://localhost:3000.

Production deployment

Deploying contracts

1

Configure target network

Update scaffold.config.ts with your target network:
targetNetworks: [chains.sepolia]
2

Fund deployer account

Ensure your deployer account has sufficient funds for deployment and gas fees.
3

Deploy to network

yarn deploy --network sepolia
4

Verify contracts

yarn verify --network sepolia

Deploying frontend

For Vercel deployment:
  1. Push your code to GitHub
  2. Import project in Vercel
  3. Add environment variables in Vercel dashboard:
    • NEXT_PUBLIC_ALCHEMY_API_KEY
    • NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID
  4. 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:
  1. Verify your NEXT_PUBLIC_ALCHEMY_API_KEY is correct
  2. Check network connectivity
  3. Try using an RPC override in scaffold.config.ts

Contract deployment fails

  1. Ensure deployer account has sufficient funds
  2. Check network configuration in hardhat.config.ts
  3. Verify ALCHEMY_API_KEY is set correctly

TypeScript ABI errors

Regenerate ABIs after contract changes:
yarn deploy
The deploy task automatically runs generateTsAbis script.

Next steps

Build docs developers (and LLMs) love