Overview
TheAgoraDaoFactory contract is the main factory responsible for creating new DAO instances in the Agora ecosystem. It manages DAO creation, categorization, and tracking of all DAOs and users across the platform. The contract inherits from OpenZeppelin’s Ownable and the custom Validation contract.
Contract: AgoraDaoFactory.solInherits:
Ownable, ValidationAuthor: NightmareFox12
State Variables
Core Counters
userCounter: Tracks the total number of unique users across all DAOsdaoCounter: Tracks the total number of DAOs created
Storage
daoCategories: Array storing available DAO category namesallDaos: Array containing all created DAOs
Mappings
daosByUser: Maps creator addresses to their created DAOsisUser: Tracks whether an address has been counted as a userisDao: Verifies if an address is a canonical DAO contract
Structs
Dao
Represents a DAO instance with its metadata.Unique identifier for the DAO
Address of the DAO creator
Deployed contract address of the DAO
Name of the DAO
Description of the DAO’s purpose
Category classification (e.g., “SERVICE”, “GOVERNANCE”)
URI pointing to the DAO’s image/logo
Block timestamp when the DAO was created
Functions
createDao
Creates a new DAO instance with the specified parameters.Name of the DAO (1-50 characters)
Description of the DAO (1-500 characters)
Index of the category in the daoCategories array
URI for the DAO’s image/logo
- Validates input parameters through
_createDaovalidation - Deploys a new
AgoraDaocontract instance - Creates a
Daostruct with metadata - Stores the DAO in
daosByUserandallDaos - Marks the address as a canonical DAO
- Increments
daoCounter - Updates user counter for the creator
- Emits
DaoCreatedevent
addDaoCategory
Adds a new category to the available DAO categories. Only callable by the contract owner.Name of the new category to add
- Category name must not be empty
- Category must not already exist (prevents duplicates)
- Only callable by contract owner
addUserCounter
Increments the user counter if the address is a new user.Address to check and potentially add to user count
- Only increments if address is not already counted
- Excludes zero address and contract address
- Can be called by child DAO contracts
withdraw
Withdraws all Ether from the contract to the owner. Only callable by the contract owner.- Only callable by contract owner
- Transfers entire contract balance to owner
getAllDaoCategories
Returns all available DAO categories.Array of all available DAO category names
- SERVICE
- GOVERNANCE
- SOCIAL IMPACT
- ENERGY
getAllDaos
Returns all created DAOs.Array of all DAO structs created through the factory
getTotalDaoCount
Returns the total number of DAOs created.Total number of DAOs in the allDaos array
Events
DaoCreated
Emitted when a new DAO is successfully created.The ID assigned to the newly created DAO
Address of the DAO creator
Name of the created DAO
Constructor
- SERVICE
- GOVERNANCE
- SOCIAL IMPACT
- ENERGY
Address that will own the factory contract