evm-tokenvote

Voting machine using ERC20 tokens as votes.
Info | Log | Files | Refs | README

voting.texi (2186B)


      1 @node voting
      2 @chapter Voting
      3 
      4 
      5 Votes are defined in magnitudes of ERC20 tokens.
      6 
      7 A vote will transfer ERC20 tokens to the custody of the smart contract for the duration of the voting.
      8 
      9 The smart contract uses the @code{transferFrom} method to transfer tokens. It is the caller's responsibility to make the necessary token allowance (using @code{approve}). Votes with insufficient allowance will fail.
     10 
     11 
     12 @section Proposal context
     13 
     14 Votes are always cast on the oldest proposal the has not been completed.
     15 
     16 
     17 @section Options
     18 
     19 If multiple options exist, the token holder may freely distribute votes between the options.
     20 
     21 
     22 @section Cancellation votes
     23 
     24 In both proposals with and without options, votes can be cast to cancel the proposal.
     25 
     26 For proposals with no or one option, the @emph{cancel} amounts to a vote against the proposal.
     27 
     28 For proposals with two or more options, the @emph{cancel} amounts to a vote against proposal and its all options.
     29 
     30 
     31 @section How to vote
     32 
     33 In each case, make sure the necessary @emph{allowance} has been successfully executed.
     34 
     35 For proposals without options, a simplified method can be called:
     36 
     37 @verbatim
     38 # solidity:
     39 function vote(uint256 _value) public returns (bool);
     40 
     41 
     42 # chainlib-python:
     43 def vote(self, contract_address, sender_address, value)
     44 
     45 
     46 # eth-encode CLI:
     47 $ eth-encode --mode tx --signature vote -e <voter_contract_address> -y <keyfile_json> u:<value>
     48 @end verbatim
     49 
     50 
     51 For proposal with options, the call is slightly more verbose:
     52 
     53 @verbatim
     54 # solidity:
     55 function voteOption(uint256 _optionIndex, uint256 _value) public returns (bool);
     56 
     57 
     58 # chainlib-python:
     59 def vote(self, contract_address, sender_address, option=<option_index>, value)
     60 
     61 
     62 # eth-encode CLI:
     63 $ eth-encode --mode tx --signature voteOption -e <voter_contract_address> -y <keyfile_json> u:<option_index> u:<value>
     64 @end verbatim
     65 
     66 
     67 To cast votes for cancellation, the call will be:
     68 
     69 
     70 @verbatim
     71 # solidity:
     72 function voteCancel(uint256 _value) public returns (bool);
     73 
     74 
     75 # chainlib-python:
     76 def vote_cancel(self, contract_address, sender_address, value)
     77 
     78 
     79 # eth-encode CLI:
     80 $ eth-encode --mode tx --signature voteCancel -e <voter_contract_address> -y <keyfile_json> u:<value>
     81 @end verbatim
     82