Skip to content

drasticstatic/dao

Repository files navigation

πŸ›οΈ Enhanced DAO Governance Platform

Live Demo License: MIT Deploy

β†’ View Live Demo

Note: The live demo runs against a local Hardhat node. Smart contract interaction requires the local node running with contracts deployed. The full UI and analytics dashboard are explorable without a wallet.

A production-ready decentralized autonomous organization (DAO) where token holders can create, vote on, and finalize funding proposals with advanced voting mechanisms, community features, and comprehensive analytics.

Β Β Β Β Screenshot of Startup Screen (w/ test data):

Welcome-to-our-DAO Β Β Β Β (see end of readme for additional screenshots)

πŸ”‘ Key Components

πŸ”— Smart Contract Features

  • Token Integration: Uses ERC-20 token for governance rights
  • Vote Weighting: Votes are weighted by token balance
  • Advanced Quorum System: Proposals require minimum votes to be finalized
  • Tri-State Voting: Support for For/Against/Abstain votes with separate tracking
  • Cancellation Mechanism: Proposals can be cancelled if they receive enough negative votes
  • Participation Tracking: Complete tracking of voter participation rates

✨ Core Features

  • Token-Based Governance: Only token holders can create proposals and vote
  • Proposal Management: Create, vote, finalize, or cancel proposals with optional deadlines
  • Community Engagement: Achievement system, anonymous leaderboards, and discussion features
  • Analytics Dashboard: Comprehensive metrics about proposal activity and voting patterns
  • Cross-Browser Sync: Robust data persistence with automatic corruption recovery
  • Mobile-Responsive: Optimized interface for all device types

πŸ—³οΈ Advanced Voting System

  • Tri-State Voting: Vote For, Against, or Abstain on proposals
  • Deadline Management: Optional voting deadlines with automatic enforcement
  • Vote Confirmation: Smart confirmation dialogs with voting power display
  • Real-time Status: Live updates on proposal states and voting progress

πŸ“Š Advanced Analytics

  • Participation Tracking: See exactly how much of the community has participated
  • Vote Distribution: Visual breakdown of For/Against/Abstain votes
  • Quorum Progress: Real-time tracking of quorum achievement
  • Comprehensive Metrics: Detailed statistics on DAO activity

πŸ† Community Engagement

  • Achievement System: Progressive levels based on voting participation
  • Anonymous Leaderboards: Privacy-preserving rankings with fun generated names
  • Proposal Comments: Modal-based discussion threads with on-chain storage
  • Smart Notifications: Cross-browser alerts for new proposals and deadlines
  • User Analytics: Personal voting patterns and response time tracking

🎨 Enhanced User Experience

  • Progress Bars: Dual-function bars showing both vote distribution AND total participation
  • Smart Quorum Detection: Visual indicators when proposals are ready for finalization or cancellation
  • Sticky Table Headers: Enhanced UX with persistent always-visible column headers during scrolling
  • Mobile-Responsive Design: Optimized interface for all device sizes

πŸš€ Latest Enhancements

User Experience Improvements

  • βœ… Enhanced Tooltips: Clear explanations for comment counts and form fields
  • βœ… Robust Data Persistence: Automatic cleanup of corrupted localStorage data
  • βœ… Consistent Notifications: Cross-browser notification state synchronization with demo data
  • βœ… Improved Spacing: Better visual hierarchy with centered navbar layout
  • βœ… Timestamp Display: Enhanced timestamps with date and time for all actions
  • βœ… Mobile Navigation: Responsive navbar with collapsible menu and mobile-optimized dropdowns
  • βœ… Success Modals for All Actions: Voting, finalizing, cancelling, AND proposal creation
  • βœ… User-Controlled Page Refresh: Blockchain data only reloads AFTER user dismisses success modal
  • βœ… Accurate Test Scenarios: Dual collapsible controls for documentation at bottom of DAPP to deatil deployed test sequence
  • βœ… Persistent Footer: Always-visible "Create Proposal" button at bottom of page to scroll user to entry form

Privacy & Community Features

  • βœ… Anonymous Names: Fun, consistent pseudonyms in leaderboards and comments
  • βœ… Smart Badge Display: Context-aware voting status indicators with timestamps
  • βœ… Enhanced Comments: Improved comment refresh with automatic data reload
  • βœ… Robust Error Handling: Graceful fallbacks for BigNumber and data parsing errors
  • βœ… Forced Blockchain Sync: Notifications always reflect current on-chain state

Technical Robustness

  • βœ… Contract Optimization: Simplified struct design to avoid stack depth issues
  • βœ… Comprehensive Testing: 66 passing tests with robust error handling (100% pass rate)
  • βœ… Cross-Browser Compatibility: Enhanced data persistence across all browsers
  • βœ… Deadline Functionality: Advanced proposal deadline management with time-based voting restrictions
  • βœ… Enhanced Error Messages: Clear, descriptive error messages for all contract operations
  • βœ… Ultra-Sticky Headers: Maximum browser compatibility with fixed column widths
  • βœ… Smart Data Management: Automatic cleanup of stale data across deployments

πŸš€ Getting Started

Deployment Options

# Option 1: Clean slate (no test proposals)
npx hardhat run scripts/deploy.js --network localhost
npx hardhat run scripts/seed.js --network localhost
# Skip all test scripts, start frontend: npm start

# Option 2: Full test sequence (recommended for testing)
npx hardhat run scripts/deploy.js --network localhost
npx hardhat run scripts/seed.js --network localhost
npx hardhat run scripts/test-initial-proposals.js --network localhost
npx hardhat run scripts/test-abstain.js --network localhost
npx hardhat run scripts/test-oppose.js --network localhost
npx hardhat run scripts/test-ready-cancel.js --network localhost
npx hardhat run scripts/test-ready-finalize.js --network localhost
npx hardhat run scripts/test-additional-proposals.js --network localhost
npm run start

Installation & Setup

  1. Clone the repository

    git clone <repository-url>
    cd dao
  2. Install dependencies

    npm install
  3. Start local blockchain

    npx hardhat node
  4. Deploy contracts (in a new terminal)

    npx hardhat run scripts/deploy.js --network localhost
  5. Seed initial data

    npx hardhat run scripts/seed.js --network localhost
  6. Run test scenarios (optional)**

    # Test initial proposals
    npx hardhat run scripts/test-initial-proposals.js --network localhost
    
    # Test abstain voting functionality
    npx hardhat run scripts/test-abstain.js --network localhost
    
    # Test oppose voting and cancellation
    npx hardhat run scripts/test-oppose.js --network localhost
    
    # Test proposals ready for cancellation
    npx hardhat run scripts/test-ready-cancel.js --network localhost
    
    # Test proposals ready for finalization
    npx hardhat run scripts/test-ready-finalize.js --network localhost
    
    # Test additional proposals with comments
    npx hardhat run scripts/test-additional-proposals.js --network localhost
  7. Start frontend

    npm run start
  8. Configure MetaMask

    • Add localhost network (RPC: http://localhost:8545, Chain ID: 31337)
    • Import test accounts using private keys from Hardhat node output

πŸ“– Usage Guide

Basic Operations

  1. Create Proposals: Fill out the form with proposal details and funding amount
  2. Vote on Proposals: Use "πŸ‘ For", "πŸ‘Ž Against" buttons, or abstain
  3. Finalize Proposals: Click "Finalize" when positive votes reach quorum (🀩 Ready to Finalize)
  4. Cancel Proposals: Click "Cancel" when negative votes reach quorum (😞 Ready to Cancel)
  5. View Analytics: Monitor DAO activity through the comprehensive analytics dashboard

Understanding the Interface

  • Status Badges: Show current proposal state (In Progress 😁, Ready to Finalize 🀩, etc.)
  • Progress Bars: Display both vote distribution AND total participation percentage
  • Participation Tracking: See how much of the community has voted
  • Real-time Updates: Page automatically refreshes after transactions

πŸ› οΈ Developer Tools & Debugging

Development Features

  • βœ… Flexible Deployment: Choose between clean slate or pre-populated test data
  • βœ… Organized Test Scripts: Separated initial proposals from additional test data with deadline examples
  • βœ… Automatic Data Cleanup: Detects contract address changes and clears stale data
  • βœ… Robust Error Handling: Comprehensive validation with descriptive error messages
  • βœ… Cross-Deployment Persistence: Smart data management across contract deployments
  • βœ… Debug Functions: Global functions for data inspection and cleanup
  • βœ… Blockchain Notifications: Auto-generated notifications from on-chain events
  • βœ… Optimized Cross-Browser Sync: BroadcastChannel and storage events without resource-intensive polling
  • βœ… Event-Driven Updates: Real-time sync using modern web APIs without periodic checks

πŸ§ͺ Comprehensive Testing

Test Suites

Our testing framework covers all aspects of the DAO functionality:

Core DAO Tests (test/DAO.js) βœ… PASSING

npx hardhat test test/DAO.js
  • βœ… Contract deployment and initialization
  • βœ… Token holder validation and access control
  • βœ… Proposal creation with comprehensive validation
  • βœ… Multi-type voting mechanisms (For/Against/Abstain)
  • βœ… Quorum requirements and proposal finalization
  • βœ… Secure fund distribution and error handling

Deadline Features (test/DeadlineFeatures.js)

npx hardhat test test/DeadlineFeatures.js
  • βœ… Proposal creation with optional deadlines
  • βœ… Deadline validation (future dates only)
  • βœ… Voting enforcement before/after deadlines

Community Features (test/CommunityFeatures.js)

npx hardhat test test/CommunityFeatures.js
  • βœ… Multi-user voting power scenarios
  • βœ… Participation tracking across multiple proposals
  • βœ… Vote distribution analysis and metrics
  • βœ… Complex governance scenarios and edge cases

Running Tests

# Run all tests
npx hardhat test

# Run with detailed output
npx hardhat test --verbose

# Run specific test file
npx hardhat test test/DeadlineFeatures.js

# Run specific test by name (using grep)
npx hardhat test --grep "Should reject voting after deadline"

# Run with gas reporting
REPORT_GAS=true npx hardhat test
# or
npx hardhat test --gas-report

# Generate coverage report
npx hardhat coverage

Testing Guide

# Core DAO Test
npx hardhat test test/DAO.js

# Deadline Features
npx hardhat test test/DeadlineFeatures.js

# Community Features
npx hardhat test test/CommunityFeatures.js

Data Management Tools

// Clear all localStorage data (available in browser console)
window.forceClearAllData()

// Check current contract address
localStorage.getItem('daoContractAddress')

// View stored notifications
JSON.parse(localStorage.getItem('daoNotifications') || '[]')

πŸ› οΈ Technical Details

Technology Stack

  • Frontend: React 18, Bootstrap 5, Ethers.js
  • Blockchain: Hardhat, Solidity ^0.8.0
  • Styling: Custom CSS with glassmorphism effects
  • State Management: React Hooks

Prerequisites

  • Node.js (v14 or higher)
  • Hardhat (v2.10 or higher)
  • MetaMask browser extension
  • Git

Smart Contract Architecture

  • DAO.sol: Main governance contract with tri-state voting
  • Token.sol: ERC-20 token for governance rights
  • Quorum System: 500,000+ tokens required for proposal finalization/cancellation

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Additional Screenshots:

Β Β Β Desktop:

Engagement-Leaderboard-Analytics Proposals|Governance9-12 Proposals|Governance2-6 Test-Voting-Senarios DemoSetup-desktop

Β Β Β Mobile:

DemoSetup_mobile1 DemoSetup_mobile2 Notifications_mobile Success_votedFor_mobile

πŸ‘·πŸΌ Create your first proposal and start voting πŸ₯³!

For questions or support, please open an issue in the 'dao' repository

About

πŸŽ“ DappU-Mentorship πŸ—³οΈ A production-ready decentralized autonomous organization (DAO) where token holders can create, vote on, and finalize funding proposals with advanced voting mechanisms, community features, and comprehensive analytics

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors