This project is a decentralized voting application built with ReactJS and Solidity. It uses smart contracts to ensure that only users with governance tokens can participate in the voting process.
Thw Solidity contract is for a voting system where voters can register, candidates can register, and voters can cast their votes for the registered candidates. The contract includes the following functionalities:
- Candidate registration: Candidates can register with their personal details, and the contract checks if the candidate has already registered. The contract also checks if the number of candidates registered is less than the maximum limit of 3.
- Voter registration: Voters can register with their personal details, and the contract checks if the voter has already registered. The contract also checks if the voter's age is at least 18.
- Voter and candidate verification: The contract includes functions to verify if a voter or candidate has already registered.
- Voter list and candidate list: The contract includes functions to retrieve the list of registered voters and candidates.
- Voting: Voters can cast their votes for the registered candidates. The contract checks if the voter has already voted, if the voter has enough tokens to vote, if the voting period has started, if the number of candidates registered is 3, if the candidate ID is valid, and if the voter is a registered voter.
- Voting time: The contract includes a function for the election commissioner to set the start and end times for the voting period.
- Voting status: The contract includes a function to check the current status of the voting period.
- Result: The contract includes a function for the election commissioner to announce the election result. The contract checks if at least one candidate has registered before announcing the result.
- Emergency: The contract includes a function for the election commissioner to stop the voting process in case of an emergency.
The contract uses OpenZeppelin's SafeERC20 library to safely interact with the ERC20 token contract. The contract also includes several events to log important actions, such as candidate registration, voter registration, vote casting, voting period set, voting status updated, and election result announced.
- Secure Voting: Utilizes smart contracts to ensure tamper-proof voting results and token-based voting access.
- Token-based Voting: Requires users to hold governance tokens to participate in voting.
- Intuitive User Interface: Provides a user-friendly interface for registering, voting, and viewing results.
-
Clone the Repository:
git clone https://github.com/SanskarDhyani98/Voting.git cd Voting/client
-
Install Dependencies:
npm install
-
Start the Development Server:
npm run dev
This will start a development server and open the application in your browser.
-
Register as a Voter:
- Visit the registration page and provide your details.
- Acquire governance tokens.
-
Vote:
- Login to your account and navigate to the voting page.
- Cast your votes.
-
View Results:
- Once voting is complete, view the results on the results page.
- Frontend: ReactJS is used for building the user interface.
- Backend: Solidity smart contracts handle voting logic and token management.
- Blockchain: The application interacts with a blockchain network, such as Ethereum.
Contributions are welcome! If you'd like to contribute, please submit a pull request.
This project is licensed under the MIT License.
This project was inspired by the growing interest in decentralized voting and the potential of blockchain technology.
If you have any questions or feedback, please feel free to contact Sanskar Dhyani at sanskardhyani98@gmail.com.