Skip to content

Cecile-Hirschauer/VotingSystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

Voting Contract

Overview

This Solidity smart contract, Voting, is tailored for streamlined voting within a small organization. It allows pre-registered (whitelisted) voters to propose options and vote on them. The contract emphasizes transparency and simplicity, facilitating a clear and democratic voting process.

Compiler Version

Developed with Solidity version 0.8.23, it is advisable to utilize the most recent stable release of the Solidity compiler for deployment purposes.

Key Features

  • Whitelisted Voter Registration: Enables only authorized voters to participate.
  • Proposal Submission: Registered voters can submit proposals within a designated timeframe.
  • Transparent Voting Mechanism: Ensures that all votes are visible to registered participants, maintaining transparency.
  • Majority Wins: The proposal with the majority of votes is deemed the winner.
  • Structured Workflow: Manages different phases of voting, from voter registration to final vote tally.

Voting Process

  1. Voter Registration: Admin registers known voters via their Ethereum addresses.
  2. Proposal Registration Phase: Initiation of the proposal submission period by the admin.
  3. Proposal Submission: Voters submit their proposals.
  4. End of Proposal Registration: Admin concludes the proposal submission phase.
  5. Voting Commences: Registered voters start casting their votes.
  6. Voting Concludes: Admin closes the voting period.
  7. Tallying Votes: Admin calculates the votes to identify the winning proposal.
  8. Winner Announcement: Public access to the winning proposal’s details.

Contract Components

Data Structures

  • Voter: Keeps track of each voter's registration and voting status.
  • Proposal: Represents a proposal with its description and accumulated votes.
  • VoteRecord: Logs each vote cast, linking it to a voter and a proposal.

Enumerations

  • WorkflowStatus: Guides the contract through various stages of the voting procedure.

Principal Functions

  • registerVoter: Enlists a voter in the whitelist.
  • registerProposal: Allows voters to put forth proposals.
  • vote: Empowers whitelisted voters to cast their vote for their preferred proposals.
  • getWinner: Fetches the identifier of the proposal that received the most votes.

Deployment Instructions

For deployment, the contract should be executed by the administrator using the latest version of the Solidity compiler. The contract integrates OpenZeppelin's Ownable for efficient ownership management.

Security and Reliability

Designed with a focus on security and reliability, the contract incorporates distinct phases and constraints to prevent unauthorized or premature actions during various stages of the voting process. This ensures a fair and transparent electoral environment.


VotingPlus Contract

Overview

The VotingPlus smart contract, an evolution of the Voting contract, is designed to facilitate organized and democratic voting processes within a community or organization. It introduces additional features for a more nuanced voting experience, including the ability to cast blank votes.

Compiler Version

The contract is written in Solidity version 0.8.23 and should be compiled with the same or newer compiler version to ensure compatibility and security.

Key Features

  • Blank Vote Capability: Voters can cast a blank vote to indicate neutrality or abstention.
  • Proposal Description Constraints: Enforces minimum and maximum lengths for proposal descriptions.
  • Vote Recording Enhancements: Provides detailed tracking of each vote cast.
  • Refined Tally Mechanism: Improved vote tallying process with checks for ties and blank votes.
  • Workflow Optimization: Streamlined voting workflow with private utility functions for common tasks.

Voting Workflow

  1. Voter Registration: Only whitelisted voters can propose and vote.
  2. Proposal Submission: Voters can submit proposals with validated descriptions.
  3. Voting Phase: Voters cast their votes, with the option to submit a blank vote.
  4. Vote Tallying: The contract calculates votes, handles ties, and identifies if all votes are blank.
  5. Winner Declaration: The contract announces the proposal with the most votes.

Contract Structure

Data Structures

  • Voter: Tracks registration and voting status of each voter.
  • Proposal: Contains the proposal's description and vote count, with a flag for blank votes.
  • VoteRecord: Logs the association between voters and their chosen proposals.

Enums

  • WorkflowStatus: Defines the stages of the voting process.

Events

  • VoterRegistered: Triggered when a voter is registered.
  • WorkflowStatusChange: Emitted on transition between workflow stages.
  • ProposalRegistered: Announced when a new proposal is submitted.
  • Voted: Emitted when a vote is cast.
  • AllVotesAreBlank: Triggered if all votes in a session are blank.
  • TieDetected: Emitted when a tie occurs.
  • TieResolved: Announced when a tie is resolved.

Functions

  • registerVoter: Registers a new voter if they are not already on the whitelist.
  • registerProposal: Submits a new proposal with a validated description.
  • vote: Records a voter's choice for a given proposal.
  • getWinner: Retrieves the winning proposal after votes are tallied.

Deployment and Usage

To deploy VotingPlus, use the latest stable release of the Solidity compiler and follow standard smart contract deployment practices. The contract integrates OpenZeppelin's Ownable to manage ownership and access controls.

Security Measures

The contract enforces strict workflow stages to avoid unauthorized actions, utilizing modifiers to ensure actions are taken in the correct order and by authorized individuals.

Future Enhancements

  • Improved Randomness in Tie Resolution: Adopting more secure random number generation methods for tie-breaking.
  • Governance Token Integration: Allowing voting power to be proportional to token holdings.
  • Gas Optimization: Reducing transaction costs through efficient use of storage and execution paths.

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published