Reference for the DAOFactory.sol contract.
Source: contracts/DAOFactory.sol
(Note: Update link if necessary)
The DAOFactory
is the central deployment contract for the CreateDAO ecosystem. It is responsible for creating new DAO instances and managing the implementation addresses for the core DAO components and optional modules. It utilizes the UUPS proxy pattern, meaning the factory itself can be upgraded by its owner.
DAO
, DAOToken
, DAOTreasury
, DAOStaking
, and optional modules like DAOPresale
. These are registered by version ID.createDAO
is called, the factory deploys new proxy contracts (DAOProxy
, DAOTokenProxy
, etc.) for the new DAO. These proxies are initialized to point to the latest registered implementation addresses stored in the factory.The contract uses ERC-7201 namespaced storage to minimize storage collisions during upgrades. Key storage variables include:
coreImplementations
: Mapping from versionId
string to a CoreImplementation
struct containing the addresses for DAO, Token, Treasury, and Staking implementations for that version.moduleImplementations
: Mapping from ModuleType
enum and versionId
string to a ModuleImplementation
struct.availableVersions
: Array storing the registered version IDs for core implementations.moduleVersions
: Mapping from ModuleType
to an array of registered version IDs for that module.createDAO
Deploys a new suite of DAO contracts (DAO, Token, Treasury, Staking proxies) using the implementations registered for the specified versionId
(must be the latest).
msg.sender
and the rest to the Treasury).DAOCreated
event.registerCoreImplementation
(Owner only) Registers the implementation addresses for the core DAO components under a specific versionId
. Adds the versionId
to availableVersions
. Emits CoreImplementationRegistered
.
registerModuleImplementation
(Owner only) Registers an implementation address for an optional module (e.g., Presale) under a specific moduleType
and versionId
. Adds the versionId
to the moduleVersions
mapping for that type. Emits ModuleImplementationRegistered
.
getCoreImplementation(string versionId)
: Returns the registered core implementation addresses for a given version.getModuleImplementation(IDAOModule.ModuleType moduleType, string versionId)
: Returns the registered implementation address for a given module type and version (must be the latest active version for that module type).getLatestVersion()
: Returns the latest registered versionId
for core implementations.getAvailableVersions()
: Returns an array of all registered versionId
s for core implementations.getModuleVersions(IDAOModule.ModuleType moduleType)
: Returns an array of registered versionId
s for a specific module type.getLatestModuleVersion(IDAOModule.ModuleType moduleType)
: Returns the latest registered versionId
for a specific module type.FACTORY_VERSION()
/ getFactoryVersion()
: Returns the hardcoded version string of the DAOFactory
contract itself.DAOCreated(address indexed daoAddress, address indexed tokenAddress, address indexed treasuryAddress, address stakingAddress, string name, string versionId)
: Emitted when a new DAO is successfully deployed.CoreImplementationRegistered(string versionId, address daoImpl)
: Emitted when new core implementations are registered.ModuleImplementationRegistered(IDAOModule.ModuleType indexed moduleType, string versionId, address implementation, string moduleTypeName)
: Emitted when a new module implementation is registered.The DAOFactory
itself is upgradeable via the UUPS pattern. The _authorizeUpgrade
function restricts upgrades to the owner()
.