So I saw this example on solidity documentation site, I understand how code is working but my issue is that I am unable to understand the problem statement.

    The idea is to create one contract per ballot, providing a short 
     name for each option. Then the creator of the contract who serves 
     as chairperson will give the right to vote to each address 

      The persons behind the addresses can then choose to either vote 
      themselves or to delegate their vote to a person they trust.

Can anyone explain what was the exact problem of voting app.(meaning of delegation, chairperson or in general what we are trying to achieve here). code can be found on the following link. https://github.com/anaamnizami/solidity/blob/master/votingapp.sol

1 Answer 1


My understand: this is a smart contract that can be used to hold a public vote on the blockchain.

The person who deploys the smart contract is known as the "chairperson." They get to do two special things:

  1. At the time of deployment, they create a number of "proposals" (the options that people are voting on).
  2. After deployment, they can invite someone to vote. (This is giveRightToVote(address) in the code.)

People who have been given the right to vote (the chairperson plus anyone they added) are allowed to do one of the following two things:

  1. Vote for exactly one of the proposals.
  2. "Delegate" their vote to someone else. If I delegate my vote to you, it means you control my vote. (If you weren't already voting, then you essentially take my place. If you were already voting, then your vote counts as one extra vote now, which simulates me voting for the same proposal you vote for.)

The advantage of doing this sort of thing on the blockchain is that everyone can be sure that no tampering occurred. All data on the blockchain is public, so anyone can see who was invited to vote and what proposal each person voted for.

You could even imagine another contract using the results of such a vote (after a specified time period). E.g., we could be voting on what charity should receive our contribution, and the result of the vote could be binding in that it actually allocates the funds.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.