BVote is a decentralized voting application built on the Ethereum blockchain using Solidity smart contracts and the Hardhat development environment. This project allows users to register as voters, register political parties, and cast votes in a secure and transparent manner. The application leverages Web3.js for interaction with the Ethereum blockchain.
- Voter Registration: Voters can register with a unique ID and password.
- Party Registration: Admins can register political parties for elections.
- Voting: Registered voters can cast their votes for registered parties.
- Election Management: Admins can create and manage elections, including setting deadlines.
- Secure Authentication: Voter login is secured using hashed passwords.
Before you begin, ensure you have the following installed:
- Node.js (v12 or later)
- npm (Node Package Manager)
- Hardhat
- MetaMask or another Ethereum wallet
git clone https://github.com/yourusername/VotingApp.git
cd VotingAppNavigate to the project directory and install the required dependencies:
npm installCompile the smart contracts using Hardhat:
npx hardhat compileYou can deploy the smart contracts to a local Hardhat network or a test network. To deploy to a local network, run:
npx hardhat nodeIn another terminal, deploy the contracts:
npx hardhat run scripts/deploy.js --network localhostTo ensure everything is working correctly, run the tests provided in the project:
npx hardhat testNavigate to the frontend directory and install the frontend dependencies:
cd frontend
npm installStart the frontend application:
npm startThis will launch the application in your default web browser.
- Register Party: Admins can register new political parties using the admin interface.
- Create Election: Admins can create elections with specified start and end times.
- Register Candidates: Admins can register candidates for specific elections.
- Register Voter: Voters can register using their unique ID and password.
- Login: Voters can log in to the application using their credentials.
- Vote: After logging in, voters can select a party and cast their vote.
Here are some example commands for interacting with the smart contract:
- Register a Party:
await contract.methods.registerParty(partyNumber, partyName).send({ from: adminAddress });- Register a Voter:
await contract.methods.registerVoter(voterIdHash, passwordHash, constituency).send({ from: relayerAddress });- Vote:
await contract.methods.vote(partyNumber, voterIdHash).send({ from: relayerAddress });-
contracts/: Contains the Solidity smart contracts.
BVote.sol: The main smart contract for the voting application.
-
frontend/: Contains the frontend application built with HTML, CSS, and JavaScript.
src/: Contains the source code for the frontend.src/admin.js: Handles admin functionalities.src/client.js: Handles voter functionalities.
-
scripts/: Contains deployment scripts for the smart contracts.
Contributions are welcome! If you have suggestions for improvements or new features, please fork the repository and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
This README provides a comprehensive overview of the VotingApp project, including setup instructions, usage, and code structure. If you have any questions or need further assistance, feel free to reach out!