Factory Deployment Guide¶
Overview¶
ClearPath now supports factory-based deployment, allowing multiple DAO instances to be created and managed from a single factory contract. This enables the platform to support many different DAOs with role-based access control.
New Features¶
1. DAOFactory Contract¶
The DAOFactory.sol contract provides:
- Factory Pattern: Deploy complete DAO instances on-demand
- Role Management: OpenZeppelin AccessControl for administrators, participants, and custom roles
- DAO Registry: Track all DAOs and their associated users
- Multi-DAO Support: Support multiple independent DAO instances
Role Hierarchy¶
Platform Roles:
├── DEFAULT_ADMIN_ROLE (Super admin)
├── PLATFORM_ADMIN_ROLE (Platform management)
└── DAO_CREATOR_ROLE (Can create new DAOs)
DAO-Specific Roles (per DAO):
├── DAO_ADMIN_ROLE (DAO administration)
├── DAO_PARTICIPANT_ROLE (Can participate in governance)
├── DAO_PROPOSER_ROLE (Can submit proposals)
└── DAO_ORACLE_ROLE (Can submit oracle reports)
2. Enhanced Welfare Metrics¶
The WelfareMetricRegistry.sol has been enhanced with:
Metric Categories¶
- Governance Metrics: On-chain governance activity
- Proposal submission rates
- Voting participation
-
Voting power distribution
-
Financial Metrics: Private-sector style metrics
- Revenue
- Profit/ROI
-
Treasury value (TWAP)
-
Betting Metrics: Prediction market analytics
- Trading volume
- Market accuracy
-
Liquidity depth
-
Private Sector Metrics: Traditional company metrics
- For accredited investor decision-making
- Similar to private company performance indicators
Aggregated Analytics¶
The registry now provides: - Category-based metric aggregation - Overall performance scores - Historical metric tracking - Multi-metric welfare calculations
3. Comprehensive Dashboard¶
The frontend now includes a full dashboard with:
Dashboard Tabs¶
- My DAOs: View all DAOs associated with your wallet
- DAO details and metadata
- Contract addresses
- Creation date and creator
-
Active/inactive status
-
Active Proposals: See proposals across all your DAOs
- Filter by status (all, active, pending, completed)
- View proposal details
-
Quick access to trading markets
-
Welfare Metrics: Multi-metric analytics dashboard
- Overall performance scores
- Category breakdowns
- Visual metric cards
-
DAO-specific metrics
-
Launch DAO: Create new DAO instances
- Guided wizard interface
- Set DAO name and description
- Configure treasury vault
-
Assign initial administrators
-
Admin Panel: Role-based admin features (when applicable)
- Manage DAO settings
- Grant/revoke roles
- Update DAO status
Usage¶
Creating a New DAO¶
From Frontend¶
- Connect your wallet
- Navigate to "Launch DAO" tab
- Fill in DAO details:
- Name (required, minimum 3 characters)
- Description (required)
- Treasury vault address (required)
- Admin addresses (optional, comma-separated)
- Click "Launch DAO"
- Approve the transaction in your wallet
- Wait for confirmation
From Smart Contract¶
// Get factory contract
const factory = new ethers.Contract(factoryAddress, factoryABI, signer);
// Create DAO
const tx = await factory.createDAO(
"My DAO", // name
"DAO description", // description
treasuryVaultAddress, // treasury vault
[admin1, admin2] // optional admin addresses
);
const receipt = await tx.wait();
const daoId = receipt.events[0].args.daoId;
Managing DAO Roles¶
Grant Role¶
const DAO_PARTICIPANT_ROLE = await factory.DAO_PARTICIPANT_ROLE();
await factory.grantDAORole(
daoId, // DAO ID
userAddress, // user to grant role to
DAO_PARTICIPANT_ROLE // role to grant
);
Check Role¶
Revoke Role¶
Querying DAOs¶
Get User's DAOs¶
Get DAO Details¶
const dao = await factory.getDAO(daoId);
console.log(dao.name);
console.log(dao.futarchyGovernor);
console.log(dao.welfareRegistry);
// ... etc
Get All DAOs (Paginated)¶
Working with Enhanced Metrics¶
Record Metric Value¶
const registry = new ethers.Contract(
dao.welfareRegistry,
registryABI,
signer
);
await registry.recordMetricValue(
metricId,
value
);
Get Aggregated Metrics¶
const aggregated = await registry.getAggregatedMetrics();
console.log("Overall Score:", aggregated.overallScore);
console.log("Governance Score:", aggregated.governanceScore);
console.log("Financial Score:", aggregated.financialScore);
console.log("Betting Score:", aggregated.bettingScore);
console.log("Private Sector Score:", aggregated.privateSectorScore);
Get Metrics by Category¶
const GOVERNANCE = 0;
const FINANCIAL = 1;
const BETTING = 2;
const PRIVATE_SECTOR = 3;
const governanceMetrics = await registry.getMetricsByCategory(GOVERNANCE);
Deployment¶
Important Note: Contract Size Limitation¶
The DAOFactory.sol contract exceeds the Ethereum contract size limit (24KB) due to its comprehensive functionality. There are several deployment options:
Option 1: Individual Component Deployment (Recommended)¶
Use the existing deployment script which deploys each DAO component individually:
This is the recommended approach for production deployments.
Option 2: Factory with External Libraries¶
For future versions, consider refactoring the factory to use external libraries to reduce contract size:
// Move deployment logic to separate library contracts
library DAODeployer {
function deployComponents(...) external returns (...) {
// Deployment logic here
}
}
Option 3: Frontend Factory Pattern¶
Implement the factory pattern in the frontend instead of on-chain:
// Frontend code to deploy all components
async function createDAO(name, description, treasury, admins) {
// Deploy each contract individually
const welfareRegistry = await deployWelfareRegistry();
const proposalRegistry = await deployProposalRegistry();
// ... deploy other components
// Deploy governor with component addresses
const governor = await deployGovernor(...componentAddresses);
// Register DAO in a simple registry contract
await daoRegistry.registerDAO(daoId, componentAddresses);
}
Recommended Production Setup¶
- Deploy Core Template Contracts: Deploy one set of template contracts
- Use Clones/Proxies: Use EIP-1167 minimal proxy pattern to clone template contracts
- Simple Registry: Use a lightweight registry contract to track DAO instances
This approach significantly reduces gas costs and contract size limitations.
Frontend Integration¶
Environment Setup¶
Add to .env:
Dashboard Usage¶
The dashboard automatically: - Loads all DAOs for the connected wallet - Shows active proposals across DAOs - Displays multi-metric analytics - Enables DAO creation for authorized users - Renders admin features based on user roles
Role-Based UI¶
The UI automatically adapts based on user roles: - Admin Badge: Displayed when user has admin role in any DAO - Admin Tab: Only shown to users with admin privileges - Create DAO: Available to users with DAO_CREATOR_ROLE - Proposal Creation: Limited to DAO_PROPOSER_ROLE holders
Testing¶
Run All Tests¶
Run Factory Tests Only¶
Note: DAOFactory tests may fail with "code is too large" error due to contract size. This is expected and doesn't affect the other components.
Security Considerations¶
- Role Management: Carefully control who has PLATFORM_ADMIN_ROLE and DAO_CREATOR_ROLE
- Treasury Security: Ensure treasury vault addresses are secure and properly configured
- Admin Assignment: Verify admin addresses before deploying DAOs
- Access Control: Regularly audit role assignments
- Contract Size: Be aware of deployment limitations with large factory contracts
Migration Path¶
For existing deployments:
- Deploy Factory: Deploy the factory contract (or use frontend factory pattern)
- Register Existing DAOs: Add existing DAO instances to the registry
- Assign Roles: Grant appropriate roles to existing administrators
- Update Frontend: Point frontend to factory address
- Test Thoroughly: Verify all functionality before production use
Support & Resources¶
- Documentation: See README.md and ARCHITECTURE.md
- Examples: Check frontend components for implementation examples
- Issues: Report bugs via GitHub Issues
- Security: Email security concerns to [email protected]
Future Enhancements¶
Planned improvements:
- Proxy Pattern: Implement EIP-1167 minimal proxies for efficient DAO cloning
- DAO Templates: Pre-configured DAO templates for common use cases
- Cross-DAO Operations: Facilitate coordination between DAOs
- Advanced Analytics: More sophisticated metric aggregation and visualization
- Mobile Support: Native mobile app with full factory support
License¶
Apache License 2.0
Last Updated¶
December 2025