This repository contains an assignment for implementing an election smart contract using object-oriented programming principles in Solidity. The assignment is designed to help mentees understand and apply key concepts such as structs, modifiers, functions, events, and access control in Solidity.
Your goal is to create a robust and secure smart contract for conducting elections on the blockchain.
Define a struct to represent a candidate. Include fields such as candidate ID, name, vote count, etc.
Define a struct to represent a voter. Include fields such as voter ID, eligibility status, etc.
Implement modifiers to restrict access to certain functions, such as only allowing the contract owner to add candidates or voters.
Add functions to perform various actions like adding candidates, registering voters, casting votes, etc. Ensure that appropriate checks are implemented to maintain the integrity of the election process, such as preventing double voting.
Define events to emit important information, such as when a vote is cast or when a new candidate is added.
- Think about error handling and edge cases, such as what should happen if someone tries to vote multiple times or if an ineligible voter tries to cast a vote.
- Consider gas optimization techniques to ensure that the contract remains efficient and cost-effective to use.
To get started with this assignment, follow these steps:
- Clone this repository to your local machine.
- Implement the smart contract according to the specifications outlined in the README.
- Test your smart contract thoroughly to ensure it functions correctly and handles edge cases appropriately.
- Document your code thoroughly and provide explanations for your design decisions.
- Submit your completed assignment by pushing your changes to a new branch and creating a pull request.
- Solidity Documentation: https://docs.soliditylang.org/
- Ethereum Development with Solidity: https://ethereum.org/en/developers/docs/smart-contracts/solidity/