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.
- 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
- Smart Contracts: Solidity ^0.8.19
- Blockchain Framework: Hardhat
- Web3 Library: ethers.js v6
- Security: OpenZeppelin Contracts
- Backend: Node.js + Express.js
-
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env
Edit
.envwith your configuration -
Compile smart contracts
npx hardhat compile
-
Start local blockchain
npx hardhat node
-
Deploy smart contract
npx hardhat ignition deploy ignition/modules/VotingContract.js --network localhost
-
Start the server
npm start
-
Access application Open http://localhost:3000 in your browser
- 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
GET /api/candidates- Get all candidatesPOST /api/vote- Cast a voteGET /api/results- Get voting results
POST /api/admin/add-candidate- Add candidatePOST /api/admin/register-voter- Register voterPOST /api/admin/start-voting- Start voting
- 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
npx hardhat test
npx hardhat coverageBuilt with ❤️ using Solidity and Web3 technology