Overview
TheAgoraDao contract represents an individual DAO instance within the Agora ecosystem. It inherits from the Rol abstract contract to provide role-based access control. Each DAO is created by the AgoraDaoFactory and manages its own members, roles, and user participation.
Contract: AgoraDao.solInherits:
Rol (which extends OpenZeppelin’s AccessControl)Author: NightmareFox12
State Variables
Core Variables
Address of the parent AgoraDaoFactory contract
Unique identifier for this DAO (assigned by factory)
Number of users who have joined this specific DAO
Internal storage for DAO categories
Constructor
Initializes a new DAO instance.Address of the AgoraDaoFactory contract that created this DAO
Address of the user creating the DAO (granted DEFAULT_ADMIN_ROLE)
- Stores the factory contract address
- Grants
DEFAULT_ADMIN_ROLEto the creator - Initializes
userCounterto 1 (counting the creator)
Functions
joinDao
Allows a user to join the DAO as a regular member.- User must not already have the
USER_ROLE - User cannot be the DAO creator (DEFAULT_ADMIN_ROLE)
- Validates that the user hasn’t already joined
- Validates that the caller is not the owner
- Calls the factory’s
addUserCounterto update global user count - Emits
UserJoinedevent - Calls internal
_joinDaoUserto grant USER_ROLE - Increments the DAO’s
userCounter
Events
UserJoined
Emitted when a user successfully joins the DAO.Address of the user who joined
The user counter value when they joined
Interface to Factory
IAgoraDaoFactory
The AgoraDao contract interacts with its parent factory through this interface.Role System Integration
TheAgoraDao inherits all role management functionality from the Rol abstract contract:
Available Roles
From theRol contract:
DEFAULT_ADMIN_ROLE: DAO creator/administratorUSER_ROLE: Regular DAO membersAUDITOR_ROLE: Members who can manage other rolesTASK_MANAGER_ROLE: Members who can manage tasksPROPOSAL_MANAGER_ROLE: Members who can manage proposals
Role Management Functions
Inherited fromRol:
registerRole(bytes32 _role, address _user): Assign a role to a userregisterRoleBatch(bytes32 _role, address[] _users): Assign role to multiple usersdeleteRole(bytes32 _role, address _user): Remove a role from a usergetMemberByRole(bytes32 _role): Get all members with a specific roleisRole(bytes32 _role, address _user): Check if a user has a role
Usage Example
Receive Function
The contract can receive Ether directly:Access Control Flow
Integration Points
With AgoraDaoFactory
- Created by factory’s
createDao()function - Reports new users back to factory via
addUserCounter() - Factory stores DAO metadata and address
With Rol System
- Extends
Rolabstract contract - Inherits all role management capabilities
- Uses
_joinDaoUser()internal function for user onboarding - Leverages OpenZeppelin’s AccessControl for permissions