Skip to content

marcusmattus/blockchain-voting-system

Repository files navigation

🗳️ Blockchain Voting System

A secure, decentralized voting system built with Solidity smart contracts and Web3 technology. This project features complete blockchain integration with transparent, immutable, and verifiable elections.

✨ Features

  • Smart Contract Security: OpenZeppelin-based contracts with access controls and reentrancy protection
  • Voter Registration: Secure voter registration and verification system
  • Transparent Voting: All votes recorded on blockchain for complete transparency
  • Real-time Results: Live voting results with blockchain verification
  • Administrative Controls: Owner-only functions for managing elections
  • Time-bound Elections: Configurable voting periods with automatic closure
  • Web3 Integration: Full blockchain interaction through ethers.js

🛠️ Technology Stack

  • Smart Contracts: Solidity ^0.8.19
  • Blockchain Framework: Hardhat
  • Web3 Library: ethers.js v6
  • Security: OpenZeppelin Contracts
  • Backend: Node.js + Express.js

📦 Installation

  1. Install dependencies

    npm install
  2. Set up environment variables

    cp .env.example .env

    Edit .env with your configuration

  3. Compile smart contracts

    npx hardhat compile

🚀 Quick Start

  1. Start local blockchain

    npx hardhat node
  2. Deploy smart contract

    npx hardhat ignition deploy ignition/modules/VotingContract.js --network localhost
  3. Start the server

    npm start
  4. Access application Open http://localhost:3000 in your browser

🏗️ Smart Contract Features

  • Candidate Management: Add candidates before voting
  • Voter Registration: Register eligible voters
  • Secure Voting: Vote casting with validation
  • Results Calculation: Transparent winner determination
  • Access Control: Owner-only administrative functions
  • Time Management: Configurable voting periods

🌐 API Endpoints

Voter Functions

  • GET /api/candidates - Get all candidates
  • POST /api/vote - Cast a vote
  • GET /api/results - Get voting results

Admin Functions

  • POST /api/admin/add-candidate - Add candidate
  • POST /api/admin/register-voter - Register voter
  • POST /api/admin/start-voting - Start voting

🔒 Security Features

  • Access Control: Owner-only admin functions
  • Reentrancy Protection: OpenZeppelin security
  • Vote Validation: Prevent double voting
  • Time Controls: Voting only during active periods
  • Blockchain Transparency: All transactions auditable

🧪 Testing

npx hardhat test
npx hardhat coverage

Built with ❤️ using Solidity and Web3 technology

About

🗳️ Secure blockchain-based voting system with Solidity smart contracts, Web3 integration, and transparent election management

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors