This project is a blockchain-based e-voting system where all voting rules are enforced on-chain using a Solidity smart contract. There is no centralized backend controlling votes or results. The frontend only acts as an interface to the blockchain.
The system runs on a local Ethereum network (Hardhat) for development and demonstration purposes.
- Hardhat – Local Ethereum blockchain, smart contract compilation and deployment
- Solidity – Smart contract that enforces voting rules
- MetaMask – Wallet and identity provider for users
- React + Ethers.js – Web interface for voting and viewing results
- Node.js – Runtime environment for tooling and frontend
- Candidate initialization at deployment
- On-chain voter registration
- One vote per wallet address
- Immutable vote storage
- Publicly readable vote counts
- Start the Hardhat local blockchain
- Deploy the voting smart contract
- Register eligible voter addresses (admin-only)
- User connects MetaMask wallet
- User casts vote (on-chain transaction)
- Smart contract validates and records the vote
- Results are read directly from the blockchain
| Component | Purpose |
|---|---|
| Hardhat | Local Ethereum network & deployment |
| Solidity | Smart contract logic |
| MetaMask | Wallet & transaction signing |
| React | Frontend UI |
| Ethers.js | Blockchain interaction |
| Node.js | Runtime environment |
- No centralized backend
- No database for votes
- Blockchain-enforced security
- Transparent and verifiable results
- Wallet-based identity
- The Hardhat local blockchain is ephemeral
- Restarting the node resets contracts and balances
- Contract must be redeployed after each restart
- Voter addresses must be registered on-chain
- MetaMask Nonce Mismatch: If you get transaction errors after restarting Hardhat, reset your MetaMask account via Settings -> Advanced -> Clear activity tab data.
This project serves as a secure academic prototype demonstrating how blockchain technology can be used to enforce election integrity in a decentralized manner.
- Code Quality: Verify styling guidelines and test scripts compilation before pushing commits to master.
- Contract Compilation: Compile changes using
npx hardhat compileinside root project folder. - Contract Updates: If you modify
Voting.sol, ensure that you compile and redeploy using Hardhat, and copy the new ABI artifact tofrontend/src/Voting.json. - Themeing: Add new styling declarations using standard CSS custom properties in
frontend/src/index.css. - MetaMask Configuration: When connecting to the local Hardhat node, add a custom RPC network with RPC URL
http://127.0.0.1:8545and Chain ID31337.
MIT