Skip to content

A mechanism for creating questionnaires in blockchains and accepting votes.

License

Notifications You must be signed in to change notification settings

PLUSPLUS-JP/crypto-vote

Repository files navigation

Mechanism for creating questionnaires in blockchain and accepting votes

Read this in other languages: English , 日本語 .

Overview

Implement a questionnaire system using a smart contract.

Main point

  • The questionnaire consists of questions and options and sets the response period (start and end).
  • You can set the start and end date and time for voting. (1 minute minimum voting period)
  • Anyone can answer the questionnaire, and can answer only once for each EOA address.
  • The situation of the answer is always public.
  • Since the content of the questionnaire is hashed and managed, the exact same content can not be created

What can be achieved by this Dapps

Because information is recorded in the block chain, there is no concern such as falsification of the record

specification

Create a questionnaire

argument

  • The contents of the string _contents questionnaire (the format is described below)
  • uint _numberOfChoices Choices
  • uint _voteStartAt Start timestamp for accepting answers
  • uint _voteEndAt Time stamp for closing answer
{
    "question": "What is your favorite drink?",
    "options": ["tea", "coffee", "orange juice", "cola"]
}

Javascript example:

const data = {
    question: "What's your favorite drink?",
    options: ['tea', 'coffee', 'orange juice', 'cola'],
};

const _contents = JSON.stringify(data);

function

function create(string memory _contents, uint _numberOfChoices, uint _voteStartAt, uint _voteEndAt) public onlyOwner returns (bool) { ... }

キャンペーン作成

Voting

argument

  • bytes32 _id Questionnaire ID
  • uint _choice Number of choices to vote (number starts with zero)

function

function vote(bytes32 _id, uint _choice) public acceptingVoting(_id) returns (bool) { ... }

投票

Refer poll results

argument

  • bytes32 _id Questionnaire ID

function

function getResult(bytes32 _id) public view returns (uint[] memory) { ... }

投票結果参照

Implementation

The implementation will be published on GitHub.

https://github.com/PLUSPLUS-JP/crypto-vote

Releases

No releases published

Packages

No packages published