1.0.1 • Published 3 months ago

@intercoin/voting v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 months ago

#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:

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

nametypedescription
voteTitlestringVote title
blockNumberStartuint256vote will start from blockNumberStart
blockNumberEnduint256vote will end at blockNumberEnd
voteWindowBlocksuint256period in blocks then we check eligible

CommunitySettings

nametypedescription
communityRolestringcommunity role of participants which allowance to vote
communityFractionuint256fraction (percents mul by 1e6). setup if minimum/memberCount too low
communityMinimumuint256community minimum

voterData

nametypedescription
namestringstring
valueuint256uint256

voter

nametypedescription
contractAddressaddresscontract address
contractMethodNamestringcontract method name
voterDatatuplesee voterData
alreadyVotedbooltrue if voter is already voted

Lifecycle of Vote