Blockchain based voting contract design

Second part of Blockchain Voting System project docs

Averrous Saloom
2 min readAug 31, 2023

previous | home

Problem Statement

A decentralized blockchain based voting system for a simple organization.

Issues

  • Repeated votes from the same ID
  • Syncronizing data between multiple place of elections
  • The election commision can withheld the result and make modificatioins

Proposed solution

  • Deploy a contract for voting that stored tbe
  • There is still a commision that ensuring

Benefits

Transparent system while still keeping anonymous credentials for every voter.

General Program Flow

  1. The election commision created addresses for every eligible voter
    Flaw: Because no one can know who has a specific address, the election commision can create unauthorized address.
  2. The election commision upload allowed address to a data asset in the contract
  3. The election commision upload the candidates.
  4. The voter send a procedure to the contract with parameter of candidates
  5. After an amount of time, public can access the election result

Usecase Diagram

Usecase diagram created by me in Excalidraw

— edited at 2 September ‘23

after trying to implement it in solidity. I find that the operations is not close enough to the real use case in the real election. An election need to have a start and a finish. The vote count can only be seen only after the election is finished. The electors also need to be stopped from adding up vote after the election is done. The commision alse need to be stopped to register another candidate in the middle of an election. Hence:

I need to add the startElection and stopElection method for the election commision.

Contract Design

Data Assets:

  • commision address
  • eligible voter list
  • candidate votes map

Rule and roles:

  • onlyCommision : only user with address commision can do an operation
  • onlyEligibleVoter : only user who is eligible can do the operation

Transactions:

  • registerVoter (address voter) onlyCommision
  • registerCandidate (string candidate) onlyCommision
  • getEligibleVotersCount () view public returns (uint)
  • checkVoteResult () view public returns (map)
  • vote (string candidate) onlyEligibleVoter

— edited at 2 September ‘23

As per the change in the usecase above, the data assets need to change too.

Data Assets addition:

  • isStarted
  • isElectionFinished

Rules and roles addition:

  • onlyAfterStarted: only allow to run procedure when the election has started
  • onlyAfterFinished: only allow to run procedure when the election has finished

Transactions addition:

  • startElection
  • stopElection

— edited at 2 September ‘23

Design limitations

There are some limitation with this design:

  • There can be only one election run for a blockchain

--

--

Averrous Saloom
Averrous Saloom

No responses yet