@intercoin/voting

1.0.1 • Public • Published

#f03c15 README.MD is out of date.

VotingContract

Smart contract for facilitating voting and polling

Installation

Node

npm install @openzeppelin/contracts-ethereum-package

Deploy

when deploy it is need to pass parameters in to init method Params:

name type description
InitSettings tuple see InitSettings
contractAddress address contract's address which will call after user vote. contract nede to implement method with params: ((string,uint256)[],uint256). (tuples of tag:value, user weight)
communityAddress address address of community contract
communitySettings tuple[] see CommunitySettings

Overview

once installed will be use methods:

method name called by description
init anyone need to initialize after contract deploy
setWeight owner [TBD] ability to owner setup weight for role community
vote only which roles specified at Community Contract vote method
wasEligible anyone is block eligible for sender or not
getVoterInfo anyone return voter info
getVoters anyone return voter's addresses

Methods

wasEligible

Checking if the user was eligible in blockNumber block

Params:

name type description
addr address user's address
blockNumber uint256 Block number

vote

user can vote if he hasn't vote before and he has was eligible in blockNumber block

Params:

name type description
blockNumber uint256 Block number
voterData array of tuples see voterData

getVoterInfo

Return voter info. tuple of voter Params:

name type description
addr address user's address

setWeight

[TBD] setup weight for community role Params:

name type description
role string role name
weight uint256 weight value

getVoters

return all addresses which already voted

Tuples

InitSettings

name type description
voteTitle string Vote title
blockNumberStart uint256 vote will start from blockNumberStart
blockNumberEnd uint256 vote will end at blockNumberEnd
voteWindowBlocks uint256 period in blocks then we check eligible

CommunitySettings

name type description
communityRole string community role of participants which allowance to vote
communityFraction uint256 fraction (percents mul by 1e6). setup if minimum/memberCount too low
communityMinimum uint256 community minimum

voterData

name type description
name string string
value uint256 uint256

voter

name type description
contractAddress address contract address
contractMethodName string contract method name
voterData tuple see voterData
alreadyVoted bool true if voter is already voted

Lifecycle of Vote

  • deploy( or got) contract which method vote we will be call from voting contract. for example <address contract1>

  • got contract of Community and roles name. for example <address community> and role "members"

  • creation VotingContract and call init method with params

    • initSettings = ["My First Vote",11105165,11155165,100] ([<voteTitle>, <blockNumberStart>, <blockNumberEnd>, <voteWindowBlocks>])
    • contractAddress = <address contract1>
    • communityAddress = <address community>
    • communitySettings = [['members',150000,20]] ([<communityRole>, <communityFraction>, <communityMinimum>])
  • now any user which contain in contract community with role 'members' can vote in period from blockNumberStart to blockNumberEnd if was eligible in blockNumber block calling vote with Params

    • blockNumber = 11105222
    • methodName = 'vote'
    • voterData = [["orange",12],["blackberry",34],["lemon",56]]
  • each successful vote will call method vote(tuple(name,value)[], weight) of <address contract1>. [TBD] weight = 1 unless owner will set new value for role calling setWeight

Readme

Keywords

none

Package Sidebar

Install

npm i @intercoin/voting

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

111 kB

Total Files

21

Last publish

Collaborators

  • artman325
  • gregmozart