A comprehensive implementation of the microDAO system using Solidity and Foundry, featuring multichain multisig functionality, ENS integration, EAS attestations, and ERC20 tokenization.
The microDAO system consists of three core smart contracts:
- MicroDAOFactory: Handles DAO creation, ENS setup, and initial configuration
- MicroDAOManager: Manages ongoing operations, transactions, and member management
- MicroDAOBadges: Handles achievement system and EAS attestations
- Multichain multisig wallet creation
- Configurable consensus threshold
- Dynamic member management
- ENS domain integration
- Achievement badge system
- EAS attestation support
- ERC20 token deployment
- Role-based access control
- Reentrancy protection
- Multi-signature transaction approval
- CREATE2 deterministic addresses
MicroDAOFactory
├── Creates new DAOs using CREATE2
├── Manages ENS domain registration
├── Coordinates with badges contract
└── Tracks all created DAOs
MicroDAOManager (per DAO)
├── Multisig transaction management
├── Member add/remove functionality
├── ERC20 token deployment
├── Threshold management
└── Treasury management
MicroDAOBadges
├── Achievement tracking
├── EAS attestation creation
├── Badge requirement verification
└── Custom achievement support
- Clone the repository:
git clone <repository-url>
cd microDAO_implementation- Install dependencies:
forge install- Build the contracts:
forge buildRun the comprehensive test suite:
# Run all tests
forge test
# Run tests with verbose output
forge test -vv
# Run specific test file
forge test --match-contract MicroDAOFactoryTest
# Run with gas reporting
forge test --gas-reportThe test suite covers:
- DAO creation and configuration
- Multisig transaction workflows
- Member management operations
- Badge granting and verification
- Access control mechanisms
- Edge cases and error conditions
- Start a local Anvil node:
anvil- Deploy contracts:
forge script script/Deploy.s.sol --rpc-url http://localhost:8545 --private-key <PRIVATE_KEY> --broadcast- Set environment variables:
export PRIVATE_KEY=<your-private-key>
export ALCHEMY_API_KEY=<your-alchemy-key>
export ETHERSCAN_API_KEY=<your-etherscan-key>- Deploy to Sepolia:
forge script script/Deploy.s.sol --rpc-url sepolia --private-key $PRIVATE_KEY --broadcast --verifyforge script script/Deploy.s.sol --rpc-url mainnet --private-key $PRIVATE_KEY --broadcast --verify- Use the deployment script:
export FACTORY_ADDRESS=<deployed-factory-address>
forge script script/CreateDAO.s.sol --rpc-url <network> --private-key $PRIVATE_KEY --broadcast- Or interact directly with the factory:
IMicroDAOFactory.DAOConfig memory config = IMicroDAOFactory.DAOConfig({
members: [address1, address2, address3],
threshold: 2,
ensName: "my-dao",
easSchemas: new bytes32[](0)
});
address daoAddress = factory.createMicroDAO(config);// Submit a transaction
uint256 txIndex = dao.submitTransaction(target, value, data);
// Confirm transaction (requires threshold confirmations)
dao.confirmTransaction(txIndex);
// Add new member (requires DAO approval)
bytes memory addMemberData = abi.encodeWithSignature("addMember(address)", newMember);
dao.submitTransaction(address(dao), 0, addMemberData);// Grant creation badge (automatic on DAO creation)
badges.grantCreationBadge(daoAddress, members);
// Grant Mirror badge
badges.grantMirrorBadge(daoAddress, "https://mirror.xyz/article-url");
// Check achievements
bool hasCreationBadge = badges.hasAchievement(daoAddress, badges.CREATION_BADGE());Create a .env file:
PRIVATE_KEY=<your-private-key>
ALCHEMY_API_KEY=<your-alchemy-api-key>
ETHERSCAN_API_KEY=<your-etherscan-api-key>
POLYGONSCAN_API_KEY=<your-polygonscan-api-key>
ARBISCAN_API_KEY=<your-arbiscan-api-key>The foundry.toml file includes configurations for:
- Mainnet
- Sepolia (testnet)
- Polygon
- Arbitrum
createMicroDAO(DAOConfig)- Create a new DAOsetupENSForDAO(address, string)- Configure ENS domainisValidDAO(address)- Check if address is a valid DAO
submitTransaction(address, uint256, bytes)- Submit multisig transactionconfirmTransaction(uint256)- Confirm pending transactionaddMember(address)- Add new member (requires DAO approval)deployDAOToken(TokenConfig)- Deploy ERC20 governance token
grantCreationBadge(address, address[])- Grant creation achievementgrantMirrorBadge(address, string)- Grant Mirror publication badgeaddNewAchievement(bytes32, string, string, BadgeRequirements)- Add custom achievement
- Factory owner can update system contracts
- DAO members control DAO operations
- Badge contract owner manages achievement system
- Configurable threshold requirements
- Transaction confirmation tracking
- Reentrancy protection on execution
- Contracts use OpenZeppelin's battle-tested libraries
- Role-based permissions prevent unauthorized access
- Emergency pause functionality (can be added)
The contracts are optimized for gas efficiency:
- Packed structs where possible
- Efficient storage patterns
- Minimal external calls
- Batch operations support
-
"forge: command not found"
- Install Foundry:
curl -L https://foundry.paradigm.xyz | bash && foundryup
- Install Foundry:
-
"Invalid threshold" error
- Ensure threshold ≤ number of members and > 0
-
"ENS name already taken"
- Choose a unique ENS name for your DAO
-
Transaction execution fails
- Check that enough members have confirmed the transaction
- Verify the target contract and data are correct
# Check contract size
forge build --sizes
# Analyze gas usage
forge test --gas-report
# Debug specific transaction
forge debug <tx-hash> --rpc-url <network>- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.