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.
- 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.
- Solidity
^0.8.34 - Remix IDE
- Ethereum Virtual Machine (EVM)
Adds a new candidate to the election.
Access: Owner only.
Allows a user to vote for a candidate using the candidate ID.
Each wallet address can vote only once.
Returns:
- Winner's name
- Total votes received
Returns:
- Candidate name
- Candidate vote count
Returns the total number of candidates registered.
Screen.Recording.2026-07-29.111134.mp4
Deploy the smart contract using Remix IDE.
Only the contract owner can add candidates.
addSomeCandidates("Party A");
addSomeCandidates("Party B");
addSomeCandidates("Party C");Cast a vote using the candidate ID.
letsgoForVotes(0); // Party A
letsgoForVotes(1); // Party B
letsgoForVotes(2); // Party CSwitch accounts in Remix to simulate different voters.
Get the winner:
winner();View candidate details:
candidateDetails(0);View the total number of candidates:
totalCandidates();Decentralized-voting-system/
│
├── MyVotingSystem.sol
├── README.md
└── LICENSE
- Owner-only candidate registration.
- One vote per Ethereum address.
- Input validation using Solidity
require()statements. - Prevents voting for invalid candidate IDs.