Prerequisites
Before deploying, ensure you have:- Node.js and Yarn installed
- A funded wallet for deployment
- RPC provider access (Alchemy, Infura, etc.)
- Etherscan API key for verification (optional)
Quick start
Available commands
Frompackages/hardhat/package.json:
Key deployment commands
yarn compile
yarn compile
Compiles all Solidity contracts in Output: Artifacts in
contracts/ directory.artifacts/ and type definitions in typechain-types/yarn deploy
yarn deploy
Runs deployment scripts in Scripts are executed in alphabetical order:
deploy/ directory in order.00_deploy_agora_factory.ts01_deploy_agora_dao.ts
yarn verify
yarn verify
Verifies deployed contracts on Etherscan-compatible explorers.Requires
ETHERSCAN_V2_API_KEY in .envyarn test
yarn test
Runs test suite with gas reporting.Tests are located in
test/ directoryNetwork configuration
Supported networks fromhardhat.config.ts:48-129:
Mainnet networks
Ethereum
Arbitrum
Optimism
Polygon
Base
Scroll
Celo
Gnosis
Testnet networks
Sepolia
Arbitrum Sepolia
Optimism Sepolia
Polygon Amoy
Base Sepolia
Scroll Sepolia
Network configuration details
All networks use Alchemy RPC endpoints (except Gnosis, Chiado, Base, and Celo which use public RPCs):From hardhat.config.ts:61-64
.env:
Constructor parameters
AgoraDaoFactory
The factory contract requires one parameter: the initial owner address.From AgoraDaoFactory.sol:43
deploy/00_deploy_agora_factory.ts:25-34):
The deployer address is automatically used as the initial owner. This can be changed to a multisig or DAO governance address.
AgoraDao
Individual DAO contracts require two parameters:From AgoraDao.sol:27-32
deploy/01_deploy_agora_dao.ts:25-34):
Deployment scripts
Deployment scripts are located inpackages/hardhat/deploy/ and use Hardhat Deploy.
Factory deployment
File:deploy/00_deploy_agora_factory.ts
Custom deployment script
To deploy with custom parameters:deploy/00_deploy_agora_factory.ts
Verification process
After deployment, verify your contracts on block explorers:Automatic verification
hardhat-deploy’s built-in verification using configuration from hardhat.config.ts:135-139:
Manual verification
For manual verification or troubleshooting:Etherscan API key
Set in.env:
- Ethereum: https://etherscan.io/myapikey
- Polygon: https://polygonscan.com/myapikey
- Arbitrum: https://arbiscan.io/myapikey
- Optimism: https://optimistic.etherscan.io/myapikey
- Base: https://basescan.org/myapikey
Production deployment example
Complete deployment flow for production:Post-deployment configuration
After deployment, you may want to:Add custom DAO categories
Transfer ownership
Create initial DAOs
Troubleshooting
Insufficient funds error
Insufficient funds error
Error: Send ETH to the displayed address on your target network.
sender doesn't have enough funds to send txSolution: Fund your deployment account:Nonce too high error
Nonce too high error
Error:
nonce has already been usedSolution: Reset your local deployment state:Verification failed
Verification failed
Error:
already verified or does not matchSolution: Ensure constructor args match exactly:Network connection issues
Network connection issues
Error:
request failed or timeoutSolution: Check RPC endpoint:- Verify Alchemy API key in
.env - Try alternative RPC (Infura, QuickNode)
- Check network status
Gas optimization
The contracts are compiled with optimizer settings fromhardhat.config.ts:31-36:
- Lower runs (100) = cheaper deployment, higher execution cost
- Higher runs (1000) = expensive deployment, cheaper execution
- 200 is a good balance for most use cases
Next steps
Architecture
Understand contract structure and relationships
Overview
Return to smart contracts overview