Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

🗳️ Decentralized Voting System using Solidity

A decentralized voting smart contract built using Solidity on the Ethereum Virtual Machine (EVM). This project demonstrates the core concepts of blockchain-based voting, including owner-controlled candidate registration, one-wallet-one-vote enforcement, vote counting, and winner determination.

🚀 Features

  • Owner can add candidates.
  • One wallet can vote only once.
  • Prevents voting for invalid candidate IDs.
  • Calculates and returns the winning candidate.
  • View candidate details and total number of candidates.

🛠️ Technologies Used

  • Solidity ^0.8.34
  • Remix IDE
  • Ethereum Virtual Machine (EVM)

📋 Smart Contract Functions

addSomeCandidates(string nameoftheparty)

Adds a new candidate to the election.

Access: Owner only.


letsgoForVotes(uint id)

Allows a user to vote for a candidate using the candidate ID.

Each wallet address can vote only once.


winner()

Returns:

  • Winner's name
  • Total votes received

candidateDetails(uint id)

Returns:

  • Candidate name
  • Candidate vote count

totalCandidates()

Returns the total number of candidates registered.


🎥 Demo

Screen.Recording.2026-07-29.111134.mp4

📖 How to Use

1. Deploy the Contract

Deploy the smart contract using Remix IDE.

2. Add Candidates

Only the contract owner can add candidates.

addSomeCandidates("Party A");
addSomeCandidates("Party B");
addSomeCandidates("Party C");

3. Vote

Cast a vote using the candidate ID.

letsgoForVotes(0); // Party A
letsgoForVotes(1); // Party B
letsgoForVotes(2); // Party C

Switch accounts in Remix to simulate different voters.

4. View Results

Get the winner:

winner();

View candidate details:

candidateDetails(0);

View the total number of candidates:

totalCandidates();

📂 Project Structure

Decentralized-voting-system/
│
├── MyVotingSystem.sol
├── README.md
└── LICENSE

🔒 Security Features

  • Owner-only candidate registration.
  • One vote per Ethereum address.
  • Input validation using Solidity require() statements.
  • Prevents voting for invalid candidate IDs.

About

A decentralized voting system in Solidity

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages