Contract architecture
The system is built around a factory pattern with two core contracts:- AgoraDaoFactory - Factory contract for deploying new DAO instances
- AgoraDao - Individual DAO contract with role-based access control
- Rol - Abstract contract handling role-based permissions
- Validation - Input validation logic for DAO creation
Key contracts
AgoraDaoFactory
The factory contract (contracts/AgoraDaoFactory.sol:15) manages the creation and registry of all DAOs in the system.
Key features:
- Creates new DAO instances via the factory pattern
- Maintains a global registry of all DAOs
- Tracks DAO categories (Service, Governance, Social Impact, Energy)
- Counts unique users across the platform
- Inherits from OpenZeppelin’s
Ownablefor admin controls
AgoraDao
Individual DAO contract (contracts/AgoraDao.sol:17) that manages members and roles.
Key features:
- Role-based access control via the
Rolabstract contract - User membership management
- Integration with parent factory contract
- Built on OpenZeppelin’s
AccessControl
Rol (Role management)
Abstract contract (contracts/AgoraDao/Rol.sol:6) providing comprehensive role-based access control.
Available roles:
DEFAULT_ADMIN_ROLE- Full administrative privileges (DAO creator)AUDITOR_ROLE- Can assign roles (except admin)TASK_MANAGER_ROLE- Manages tasks (future functionality)PROPOSAL_MANAGER_ROLE- Manages proposals (future functionality)USER_ROLE- Standard DAO member
Validation
Abstract contract (contracts/AgoraDaoFactory/Validation.sol:4) that validates DAO creation parameters.
Validation rules:
- Name: 1-50 characters
- Description: 1-500 characters
- Category ID must be valid
Validation logic
OpenZeppelin dependencies
The contracts leverage battle-tested OpenZeppelin libraries:- AccessControl - Role-based permission system used in
Rol.sol - Ownable - Single owner pattern used in
AgoraDaoFactory.sol
package.json:
Security features
Role-based access control
Role-based access control
Every privileged operation requires specific role permissions. Admins cannot assign roles to themselves, and only admins can assign auditor roles.
Input validation
Input validation
All user inputs are validated for length and format before storage, preventing excessive gas costs and invalid data.
Reentrancy protection
Reentrancy protection
Follows checks-effects-interactions pattern. State changes occur before external calls.
Factory pattern
Factory pattern
New DAOs are deployed via a trusted factory, ensuring consistent initialization and proper tracking.
OpenZeppelin libraries
OpenZeppelin libraries
Built on audited, industry-standard contracts for ownership and access control.
Events
Contracts emit events for important state changes: AgoraDaoFactory:DaoCreated(uint256 indexed daoID, address indexed creator, string indexed name)
UserJoined(address indexed user, uint256 userID)
RoleRegistered(bytes32 indexed role, address indexed user, address indexed executor)RoleDeleted(bytes32 indexed role, address indexed user, address indexed executor)
Next steps
Architecture
Deep dive into contract relationships and inheritance
Deployment
Learn how to deploy and verify contracts