Skip to content

Het2239/VoteUp-DApp

Repository files navigation

πŸ—³οΈ VoteUp – Decentralized E2E Verifiable Voting DApp

VoteUp is a decentralized voting platform built on the Ethereum blockchain that supports end-to-end verifiable elections. It ensures transparency, integrity, and voter privacy through a commit-reveal voting scheme. The system supports role-based permissions (admin, voters, candidates), on-chain result validation, and real-time frontend interactions β€” all in a trustless, decentralized environment.


MIT License Built with Solidity

πŸŽ₯ Demo Video

Watch the full demo on YouTube: Watch the video

Click the thumbnail above or watch it here


πŸ“Œ Table of Contents


βœ… Features

  • πŸ“Ώ Candidate & Voter Registration Users can request registration; election admins must approve to ensure legitimacy.

  • πŸ” End-to-End Verifiable Voting Uses a commit-reveal scheme to keep votes private and later verifiable.

  • 🧠 Election Lifecycle Management Admins can create elections, approve users, start/end elections, and fetch results.

  • πŸ”  Responsive React Frontend Built with React, Tailwind, and Framer Motion for smooth UX.

  • ⚑ Real-Time Feedback Users get live election updates, success/failure toasts, countdowns, and more.

  • βš™οΈ Automatic Smart Contract Deployment Each election triggers a fresh contract deployment on Sepolia via ethers.js.


🧠 Tech Stack

React TypeScript HTML5 Vite Vercel Tailwind CSS Framer Motion Solidity Ethereum Ethers.js Web3.js MetaMask Foundry

Layer Tools / Frameworks
Frontend React 18, TypeScript, Vite, Tailwind CSS, Framer Motion, React Router DOM
Blockchain Solidity, Ethereum (Sepolia), Ethers.js
Tooling Foundry (smart contract testing), Dexie.js (IndexedDB), Canvas Confetti, XLSX
Web3 MetaMask, Wallet API via Ethers.js

πŸ—οΈ Architecture

Browser UI (React + Tailwind + Framer)
   |
   |---> Web3 Provider (MetaMask)
   |
   |---> Web3Context & Contract Utility Layer (ethers.js)
   |
Smart Contract Layer (Solidity on Sepolia)
   |
   |---> Voting.sol (deployed per election)
  • Frontend: Fully interactive UI for elections, voting, results, and admin actions.
  • Contract Deployment: Done dynamically from the frontend using a deploy function in contract.ts.
  • Storage: Temporary frontend state stored using IndexedDB (dexie).
  • Interaction: Ethers.js handles commitVote, revealVote, and other contract interactions.

πŸ” Smart Contract Overview

File: contracts/Voting.sol

Core Modules:

Function Description
createElection() Deploys new election contract
requestCandidateRegistration() Candidate applies for a role
requestVoterRegistration() Voter applies for a role
approveCandidate() Admin approves candidates
approveVoter() Admin approves voters
commitVote(bytes32 hash) Voter commits a hashed vote (hash of candidateId + salt)
revealVote(candidateId, salt) Reveals original vote during reveal phase
getResults() Returns election results after reveal period ends

βš™οΈ Installation and Running Locally

πŸ–₯️ Clone the Repository

git clone https://github.com/Het2239/VoteUp.git
cd VoteUp

πŸ—† Install Dependencies

npm install

πŸš€ Run the Development Server

npm run dev

Navigate to: http://localhost:3000

πŸ“ You do not need to manually deploy contracts. The app auto-deploys a new smart contract to Sepolia testnet whenever a new election is created. The actual port/URL may vary; check your terminal after starting the server.


πŸ§ͺ Usage Flow

1. Election Creation

  • Admin creates an election via frontend.
  • Contract is deployed to Sepolia dynamically.

2. Candidate & Voter Registration

  • Users apply via the frontend.
  • Admin views pending requests and approves them on-chain.

3. Commit Phase (Voting Period)

  • Voter casts a hash of (candidateId + salt) using commitVote.

4. Reveal Phase (Post-Voting)

  • Voter reveals original (candidateId, salt) using revealVote.
  • Contract verifies: keccak256(candidateId + salt) === committedHash.

5. Results

  • After reveal deadline, results are computed and displayed.

  • Frontend shows:

    • πŸ† Winner(s) (with tie handling)
    • πŸ“Š Vote breakdown
    • βœ… Reveal status per voter

🧠 Commit-Reveal Voting Explained

What is Commit-Reveal Voting?

Commit-reveal is a two-phase voting scheme:

  1. Commit Phase: Voters submit a hashed version of their vote (typically hash(vote + secret)), committing to their choice without revealing it.
  2. Reveal Phase: Voters later disclose their vote and secret. The system verifies that the original hash matches.

This ensures:

  • Privacy: Votes remain hidden during the election.
  • Verifiability: Everyone can later verify each vote.
  • Fairness: No early reveals influence others.

✨ Benefits

πŸ”’ Privacy and Secrecy

  • Votes are hidden during the commit phase.
  • Prevents vote buying or coercion since votes aren’t visible.

πŸ—žοΈ Verifiability

  • Each voter can verify their vote via their hash.
  • Anyone can audit if results match committed and revealed votes.

🏧 Decentralization

  • Elections aren’t controlled by a central authority.
  • Contracts enforce rules in a censorship-resistant way.

πŸ”„ Fairness

  • All votes are revealed at the same time, or none.
  • Prevents influencing voters based on early disclosures.

πŸ” Security

Aspect Contribution of Commit-Reveal Voting
Immutability Contracts can't be modified post-deployment
Vote Secrecy Hash prevents early knowledge
Integrity Reveal must match prior commitment
Double Voting Tracked per voter address
Transparency All logic is on-chain and inspectable

⚑ Efficiency

  • Gas-efficient: only a hash is stored during commit.
  • Minimal on-chain data usage.
  • No need to store full vote data on-chain.

⚠️ Requires users to interact twice (commit + reveal)

πŸ›‘οΈ Reliability

  • Deterministic: Results are final once reveals are done.

  • Robust: Cannot be taken down or altered.

  • Graceful Failure Handling:

    • Votes not revealed can be skipped.
    • Reveal reminders and auto-enforced deadlines can help.

πŸ“Š Comparison with Traditional Voting

Feature Traditional Voting VoteUp (Commit-Reveal)
Transparency Low High
Tamper-proof No Yes
Privacy Medium Strong (commit phase)
Cost High Low (post-deployment)
Accessibility Limited Global (Web3 wallet)
End-to-End Verifiability No Yes

🎯 Summary

VoteUp delivers a secure, decentralized, and verifiable voting experience through commit-reveal logic.

Property Strength
Security βœ…βœ…βœ…βœ…
Efficiency βœ…βœ…βœ…
Reliability βœ…βœ…βœ…βœ…
Privacy βœ…βœ…βœ…βœ…
Transparency βœ…βœ…βœ…βœ…

It’s ideal for:

  • DAOs
  • Campus/University elections
  • Local and community decision-making

πŸ“ File Structure

VoteUp/
β”œβ”€β”€ contracts/                  # Voting.sol smart contract
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/             # UI components (Cards, Modals, Voting UI)
β”‚   β”œβ”€β”€ contexts/               # Web3 & Theme context
β”‚   β”œβ”€β”€ utils/                  # Ethers interaction, deployment, vote logic
β”‚   β”œβ”€β”€ App.tsx                 # Root React component
β”‚   β”œβ”€β”€ main.tsx                # Entry point
β”‚   └── index.css               # Global styles
β”œβ”€β”€ public/
β”œβ”€β”€ index.html                  # Base HTML
β”œβ”€β”€ tailwind.config.js
β”œβ”€β”€ vite.config.ts
β”œβ”€β”€ tsconfig.json
β”œβ”€β”€ package.json
└── README.md

πŸ“š Contributing

We welcome contributions from the community! If you'd like to contribute:

  1. Fork the repository.
  2. Create a new branch.
  3. Make your changes.
  4. Submit a pull request with a clear description.

Whether it's bug fixes, feature additions, or documentation updates β€” all contributions are appreciated.


πŸ“œ License

This project is licensed under the MIT License. See LICENSE for more details.


πŸ“¬ Contact

Created with ❀️ by Het Chavadiya

If you use this project or find it helpful, feel free to ⭐ the repo!

About

A Decentralized End 2 End Verifiable Voting System created using Solidity and ReactJS

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published