Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

MasteringWeb3.0-Assignment-2

Election Smart Contract

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.

Objective

Your goal is to create a robust and secure smart contract for conducting elections on the blockchain.

Requirements

Candidate Struct:

Define a struct to represent a candidate. Include fields such as candidate ID, name, vote count, etc.

Voter Struct:

Define a struct to represent a voter. Include fields such as voter ID, eligibility status, etc.

Modifiers:

Implement modifiers to restrict access to certain functions, such as only allowing the contract owner to add candidates or voters.

Functions:

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.

Events:

Define events to emit important information, such as when a vote is cast or when a new candidate is added.

Additional Considerations:

  • 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.

Getting Started

To get started with this assignment, follow these steps:

  1. Clone this repository to your local machine.
  2. Implement the smart contract according to the specifications outlined in the README.
  3. Test your smart contract thoroughly to ensure it functions correctly and handles edge cases appropriately.
  4. Document your code thoroughly and provide explanations for your design decisions.
  5. Submit your completed assignment by pushing your changes to a new branch and creating a pull request.

Resources

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors