Skip to content

7BlockLabs/dao-voting-dapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

DAO Voting dApp

A production-ready decentralized autonomous organization (DAO) voting application built with Next.js and Solidity.

Demo

Wallet Connection & Overview

Wallet Connection

Creating a Proposal

Creating Proposal

Voting on Proposals

Voting Demo 1

Voting Demo 2

Real-time Updates

Real-time Updates

Proposal Execution

Proposal Execution

UI Interactions

UI Interactions

Features

  • Create Proposals: Submit governance proposals with custom voting durations
  • Democratic Voting: Vote for or against proposals
  • Proposal Execution: Execute passed proposals after voting period ends
  • Real-time Updates: Live proposal updates using contract events
  • Modern UI: Beautiful glassmorphic design with smooth animations
  • Wallet Integration: Connect with MetaMask, Rainbow, and other popular wallets

Tech Stack

Smart Contract

  • Solidity ^0.8.28
  • Hardhat 2.22.17
  • Ethers v6

Frontend

  • Next.js 15 (App Router)
  • React 19
  • TypeScript
  • Wagmi v2 (Ethereum interactions)
  • RainbowKit (Wallet connection)
  • Shadcn UI (Component library)
  • Tailwind CSS (Styling)

Quick Start

Prerequisites

  • Node.js 18+
  • npm or yarn
  • MetaMask or compatible Web3 wallet

Installation

  1. Clone the repository
cd dao-voting-dapp
  1. Install contract dependencies
cd packages/contract
npm install
  1. Install frontend dependencies
cd ../frontend
npm install

Running Locally

  1. Start Hardhat local node (in terminal 1)
cd packages/contract
npx hardhat node
  1. Deploy the contract (in terminal 2)
cd packages/contract
npx hardhat run scripts/deploy.js --network localhost

Note the deployed contract address (should be 0x5FbDB2315678afecb367f032d93F642f64180aa3)

  1. Start the frontend (in terminal 3)
cd packages/frontend
npm run dev
  1. Open your browser Navigate to http://localhost:3000

  2. Connect your wallet

  • Click "Connect Wallet" in the top right
  • Select your wallet (MetaMask, Rainbow, etc.)
  • Important: Switch to "Localhost 8545" network in MetaMask
  • Import a test account from Hardhat (use private key from terminal 1)

Test Accounts

Hardhat provides test accounts with 10,000 ETH each. Import these into MetaMask:

Account #0: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
Private Key: 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

Account #1: 0x70997970C51812dc3A010C7d01b50e0d17dc79C8
Private Key: 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d

Smart Contract

DAOVoting.sol

The main contract implements:

  • createProposal(description, durationInMinutes): Create a new proposal
  • vote(proposalId, support): Vote on a proposal (true = for, false = against)
  • executeProposal(proposalId): Execute a passed proposal
  • getProposal(proposalId): Get proposal details

Contract Address

  • Local Network: 0x5FbDB2315678afecb367f032d93F642f64180aa3
  • Sepolia Testnet: Deploy using your own RPC URL

Usage Guide

Creating a Proposal

  1. Connect your wallet
  2. Fill in the "Create New Proposal" form
  3. Set a duration (in minutes)
  4. Click "Submit Proposal"
  5. Confirm the transaction

Voting

  1. Find an active proposal
  2. Click "Vote For" or "Vote Against"
  3. Confirm the transaction
  4. Watch the vote count update in real-time

Executing a Proposal

  1. Wait for the voting period to end
  2. If proposal passed (more votes for than against)
  3. Click "Execute Proposal"
  4. Confirm the transaction

Project Structure

dao-voting-dapp/
├── packages/
│   ├── contract/           # Hardhat project
│   │   ├── contracts/      # Solidity contracts
│   │   ├── scripts/        # Deployment scripts
│   │   ├── test/           # Contract tests
│   │   └── hardhat.config.js
│   └── frontend/           # Next.js application
│       ├── app/            # Next.js app router
│       ├── components/     # React components
│       ├── lib/            # Utilities & contract config
│       └── public/         # Static assets

Deployment to Sepolia

  1. Get Sepolia ETH from a faucet
  2. Update hardhat.config.js:
networks: {
  sepolia: {
    url: `https://sepolia.infura.io/v3/YOUR_INFURA_KEY`,
    accounts: [process.env.PRIVATE_KEY]
  }
}
  1. Deploy:
npx hardhat run scripts/deploy.js --network sepolia
  1. Update frontend contract address in lib/contract.ts

Security Considerations

  • ✅ Production-ready contract code
  • ✅ No reentrancy vulnerabilities
  • ✅ Proper access control
  • ✅ Event logging for transparency
  • ⚠️ For testnet/demo purposes - conduct professional audit before mainnet

License

MIT

Contributing

Pull requests welcome! Please ensure tests pass before submitting.


Built with ❤️ using Next.js, Hardhat, and RainbowKit

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published