Skip to content

About

Educational blockchain voting prototype using Solidity smart contracts for voter registration, candidate management, one-vote-per-wallet enforcement, transparent counting, and auditable election state management

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blockchain-Based Voting System

An educational decentralized voting prototype built with Solidity, Hardhat, Ethereum-compatible blockchain technology, and Ethers.js.

The project demonstrates how blockchain technology can be used to implement a transparent and auditable voting system with voter registration, candidate management, election-state control, and one-vote-per-wallet enforcement.

Educational Purpose: This project is a prototype intended for learning, academic demonstration, and experimentation. It is not designed for real-world elections.

Features

  • Voter Registration — Maintains a blockchain-based registry of eligible voters.
  • Candidate Management — Allows authorized management of election candidates.
  • One Vote Per Wallet — Prevents a registered wallet from voting more than once.
  • Election State Management — Controls the lifecycle of an election.
  • Transparent Vote Counting — Votes and election state are stored on-chain.
  • Result Calculation — Provides a mechanism for determining election results.
  • Access Control — Restricts administrative operations to authorized accounts.
  • Auditable State — Blockchain transactions provide a transparent record of contract activity.
  • Hardhat Testing — Includes automated tests for core contract functionality.
  • Remix Compatibility — The contract can be deployed and tested using Remix for demonstration purposes.

Technology Stack

Technology Purpose
Solidity Smart contract development
Hardhat Development, compilation, and testing
Ethers.js Ethereum blockchain interaction
JavaScript Deployment scripts and tests
Ethereum / EVM Smart contract execution environment
Remix IDE Optional browser-based deployment and simulation
Git & GitHub Version control and project hosting

Project Structure

Blockchain-Based-Voting-System/
│
├── contracts/
│   └── VotingSystem.sol
│
├── scripts/
│   └── deploy.js
│
├── test/
│   └── VotingSystem.test.js
│
├── docs/
│   └── ...
│
├── hardhat.config.js
├── package.json
├── package-lock.json
├── .gitignore
└── README.md

How the System Works

The voting process follows a controlled election lifecycle:

Administrator
     │
     ├── Register Eligible Voters
     │
     ├── Register Candidates
     │
     ├── Start Election
     │
     ▼
Eligible Voters
     │
     ├── Connect Wallet
     │
     ├── Select Candidate
     │
     └── Cast Vote
     │
     ▼
Blockchain
     │
     ├── Verify voter eligibility
     ├── Verify voter has not voted
     ├── Record vote
     └── Update candidate vote count
     │
     ▼
Election Ends
     │
     ▼
Calculate / Display Results

Smart Contract Responsibilities

The VotingSystem.sol contract is responsible for maintaining the election state and enforcing the voting rules.

Typical responsibilities include:

Voter Management

The contract maintains information about eligible voters and ensures that only registered voters can participate.

Candidate Management

Candidates can be registered before the election begins according to the access-control rules implemented in the contract.

Voting

When a voter casts a vote, the contract verifies:

  1. The voter is eligible.
  2. The election is currently active.
  3. The voter has not already voted.
  4. The selected candidate is valid.

After successful validation, the vote is permanently recorded on the blockchain.

Election State

The election follows defined states such as:

Not Started
     ↓
Active
     ↓
Ended

Administrative actions can be restricted based on the current state.

Installation

Make sure you have Node.js and npm installed.

Clone the repository:

git clone https://github.com/rohitsingh83/Blockchain-Based-Voting-System.git
cd Blockchain-Based-Voting-System

Install dependencies:

npm install

Compile the Smart Contract

Run:

npx hardhat compile

A successful compilation should generate the required Hardhat artifacts.

Run Tests

Execute the automated test suite:

npx hardhat test

The tests are intended to verify important election and voting rules, including voter eligibility, candidate registration, election state transitions, and prevention of multiple votes from the same wallet.

Deploy Locally

Start a local Hardhat blockchain:

npx hardhat node

In a second terminal, deploy the contract:

npx hardhat run scripts/deploy.js --network localhost

The deployment script will deploy the VotingSystem contract to the local development blockchain.

Remix Simulation

The smart contract can also be tested through Remix IDE.

General workflow:

  1. Open Remix IDE.
  2. Upload contracts/VotingSystem.sol.
  3. Select an appropriate Solidity compiler version.
  4. Compile the contract.
  5. Select Remix VM or an injected wallet environment.
  6. Deploy the contract.
  7. Register candidates and eligible voters.
  8. Start the election.
  9. Cast votes using different accounts.
  10. Verify vote counts and election results.

Security and Design Considerations

This project demonstrates several useful blockchain security concepts:

One Vote Per Wallet

The contract maintains voting status so that a wallet cannot cast multiple votes during the same election.

Access Control

Administrative functions should only be callable by the authorized administrator account.

On-Chain Transparency

Voting-related state is stored on the blockchain, making contract activity auditable through blockchain transactions and state queries.

State Validation

Election operations should only be allowed during the appropriate stage of the election lifecycle.

Input Validation

Candidate IDs, voter addresses, and other contract inputs should be validated before modifying election state.

Limitations

This system should not be considered a production-ready electronic voting platform.

Important limitations include:

  • A blockchain wallet does not inherently prove the real-world identity of a voter.
  • Public blockchain transactions may expose voting-related information.
  • Wallet ownership can be lost or compromised.
  • Smart contract vulnerabilities could affect election integrity.
  • Gas fees and blockchain performance can limit scalability.
  • Voter privacy requires additional cryptographic and architectural mechanisms.
  • Real elections require legal, organizational, accessibility, identity, auditing, and security requirements beyond this prototype.

Educational Use Cases

This project can be used to demonstrate:

  • Solidity smart contract development
  • Ethereum-based application architecture
  • Blockchain state management
  • Access control
  • Smart contract testing
  • Decentralized application concepts
  • Transparent transaction processing
  • Basic e-voting system design

Future Improvements

Possible extensions include:

  • Web3 frontend using React
  • MetaMask wallet integration
  • Event-based election monitoring
  • Multiple election support
  • Improved role-based access control
  • Candidate metadata management
  • Automated deployment workflows
  • Additional security tests
  • Gas optimization
  • Privacy-preserving voting mechanisms
  • More comprehensive frontend result visualization

Example Development Workflow

npm install
npx hardhat compile
npx hardhat test
npx hardhat node
npx hardhat run scripts/deploy.js --network localhost

License

This project is provided for educational and academic purposes.

You may add an open-source license such as the MIT License if you intend to distribute or modify the project under those terms.

Author

Rohit Singh

GitHub: https://github.com/rohitsingh83

Disclaimer

This repository is an educational blockchain voting prototype. It should not be used to conduct real governmental, institutional, public, or legally binding elections without extensive additional security, privacy, identity, accessibility, compliance, and auditing measures. ChatGPT Image Aug 26, 2026, 01_44_33 PM

About

Educational blockchain voting prototype using Solidity smart contracts for voter registration, candidate management, one-vote-per-wallet enforcement, transparent counting, and auditable election state management

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages