A complete Decentralized Autonomous Organization (DAO) system with transparent on-chain governance, quadratic voting, and Sybil-resistant mechanisms.
- Quadratic Voting: Vote cost = votesΒ² to prevent plutocracy
- Token-based Membership: ERC-20 governance tokens with delegation
- Proposal System: IPFS-stored metadata with on-chain voting
- Sybil Resistance: Token thresholds, cooldowns, and vote limits
- Treasury Management: Multi-token treasury with automated execution
- OpenZeppelin Integration: Battle-tested security patterns
- Vote Delegation: Liquid democracy with delegation chains
- Emergency Controls: Pausable contracts and emergency withdrawals
- Comprehensive Testing: 22 passing tests covering all scenarios
- IPFS Integration: Decentralized metadata storage with pinning
- Budget Management: Category-based spending with approval workflows
- Analytics: Vote distribution analysis and Gini coefficients
- Real-time Tracking: Live proposal status and voting progress
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β GovernanceTokenβ β DAOGovernance β β DAOTreasury β
β β β β β β
β β’ ERC-20 + VotesβββββΊβ β’ Proposals βββββΊβ β’ Multi-token β
β β’ Delegation β β β’ Quadratic Voteβ β β’ Budget Mgmt β
β β’ Minting/Burn β β β’ IPFS Metadata β β β’ Auto Execute β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
βββββββββββββββββββββββββΌββββββββββββββββββββββββ
β
βββββββββββββββββββ
β IPFS Network β
β β
β β’ Metadata β
β β’ Attachments β
β β’ Pinning β
βββββββββββββββββββ
- Node.js 18+
- npm or yarn
- IPFS node (optional, uses public gateways as fallback)
# Clone the repository
git clone <repository-url>
cd decentralized-autonomous-organization
# Install dependencies
npm install
# Compile contracts
npm run compile
# Run tests
npm test
# Deploy to local network
npm run node # Terminal 1: Start local Hardhat network
npm run deploy:localhost # Terminal 2: Deploy contracts# Deploy to testnet (configure network in hardhat.config.ts)
npm run deploy:sepolia
# Verify contracts on Etherscan
npx hardhat verify --network sepolia <contract-address> <constructor-args>βββ contracts/ # Smart contracts
β βββ GovernanceToken.sol # ERC-20 governance token
β βββ DAOGovernance.sol # Main DAO contract
β βββ DAOTreasury.sol # Treasury management
β βββ VotingMechanisms.sol # Voting utilities
βββ scripts/ # Deployment scripts
β βββ deploy.ts # Main deployment script
βββ ipfs/ # IPFS integration
β βββ client.js # IPFS client setup
β βββ metadata.js # Metadata management
β βββ pinning.js # Pin management
β βββ example.js # Usage examples
βββ frontend/ # React frontend (TODO)
βββ tests/ # Test suites
β βββ DAO.test.ts # Comprehensive tests
βββ docs/ # Documentation
// 1. Upload metadata to IPFS
const proposalData = {
title: "Fund Open Source Library",
description: "Proposal to fund development...",
proposer: "0x742d35Cc6634C0532925a3b8D4C9db96590c6C87",
// ... additional fields
};
const { hash } = await metadataService.uploadProposalMetadata(proposalData);
// 2. Create on-chain proposal
await daoGovernance.propose("Fund Open Source Library", hash);// Vote with 4 votes (costs 16 tokens)
const votes = 4;
const cost = votes * votes; // 16 tokens
// Approve token spending
await governanceToken.approve(daoGovernance.address, ethers.parseEther("16"));
// Cast vote
await daoGovernance.vote(proposalId, votes);// Alice delegates her voting power to Bob
await daoGovernance.connect(alice).delegateVotes(bob.address);
// Bob can now vote with Alice's tokens + his own
const bobVotingPower = await governanceToken.getVotes(bob.address);The system includes a complete demo scenario:
- Alice proposes funding for an open-source library
- Bob votes with 4 votes (16 tokens deducted via quadratic cost)
- Carol delegates her votes to Bob
- Voting closes, quorum is met, proposal passes
- Treasury automatically executes fund transfer
# Run the demo
npm test -- --grep "Complete Proposal Lifecycle"struct VotingConfig {
uint256 proposalThreshold; // 1,000 tokens to create proposal
uint256 votingDelay; // 1 day delay before voting starts
uint256 votingPeriod; // 7 days voting duration
uint256 quorumThreshold; // 100,000 tokens minimum participation
uint256 maxVotesPerWallet; // 10,000 max votes per wallet
uint256 proposalCooldown; // 1 day cooldown between proposals
}const IPFS_CONFIG = {
host: process.env.IPFS_HOST || 'localhost',
port: process.env.IPFS_PORT || 5001,
protocol: process.env.IPFS_PROTOCOL || 'http',
timeout: 30000
};β
22 tests passing
π 100% test coverage for core functionality
π Security patterns verified
β‘ Gas optimization confirmed
- GovernanceToken: Minting, burning, delegation
- DAOGovernance: Proposals, voting, delegation
- DAOTreasury: Deposits, budgets, spending
- Integration: Complete proposal lifecycle
- Token Threshold: Minimum tokens required to create proposals
- Vote Limits: Maximum votes per wallet to prevent centralization
- Cooldowns: Time delays between actions from same address
- Quadratic Cost: Exponential cost scaling discourages vote buying
- Role-based Permissions: Owner, treasury managers, emergency managers
- Pausable Contracts: Emergency stop functionality
- Reentrancy Guards: Protection against reentrancy attacks
- Safe Math: Overflow protection with Solidity 0.8+
- Structured Format: JSON schema for proposal metadata
- Attachment Support: Images, documents, data files
- Pinning Management: Automatic pinning with retention policies
- Fallback Gateways: Multiple IPFS gateways for reliability
{
"version": "1.0.0",
"type": "dao-proposal",
"proposal": {
"title": "Fund Open Source Library",
"description": "...",
"proposer": "0x...",
"budget": { "total": "50,000 DAOGOV" }
},
"attachments": [...],
"links": [...]
}- Smart contracts development
- IPFS integration
- Comprehensive testing
- Deployment scripts
- React application
- MetaMask integration
- Proposal management UI
- Voting interface
- Real-time analytics
- Snapshot.js integration
- Multi-signature proposals
- Lens Protocol integration
- Mobile application
- Fork the repository
- Create a feature branch
- Write tests for new functionality
- Ensure all tests pass
- Submit a pull request
MIT License - see LICENSE file for details.
- OpenZeppelin: Security-focused smart contract library
- Hardhat: Ethereum development environment
- IPFS: Decentralized storage network
- Ethers.js: Ethereum library for JavaScript
Full-Stack Developer & Blockchain Enthusiast
"Building the future of cross-chain infrastructure, one commit at a time."
Passionate about blockchain technology and decentralized systems, I specialize in creating robust, scalable solutions for the Web3 ecosystem. This project represents my commitment to building production-ready tools that enhance the security and reliability of cross-chain operations.
Areas of Expertise:
- π Blockchain Development (Ethereum, Polygon, BSC)
- βοΈ Full-Stack Development (React, Node.js, TypeScript)
- π Security & Anomaly Detection Systems
- π Real-Time Data Processing & Visualization
- ποΈ Scalable System Architecture
β Star this repository if you find it useful!
π Watch this repository to stay updated with the latest features and improvements!