部分锁定提交显示使用ERC20令牌的投票系统
Mainnet factory: 0xdf9c10e2e9bb8968b908261d38860b1a038cc2ef
Rinkeby factory: 0x5edd7268c6a0d2f171789d8385e95cdbb16ab735
EPM: plcr-revival
PLCR voting is an efficient system for token-weighted voting on the Ethereum blockchain
PLCR voting enables a user to participate in multiple polls simultaneously with their tokens while preventing double-voting of tokens within polls
PLCR voting allows users to withdraw (at any time) the maximum number of tokens which are not actively used in voting
PLCR voting (in it’s current implementation) does not stake tokens — voting in the losing party of a poll does not result in a loss of one’s tokens
voting rights: tokens controlled by the voting contract; either active or available to be used in PLCR voting
commit-reveal: voting takes place in 2 separate chronologic time periods. this prevents the voting process itself from influencing vote results
locked tokens: during a poll’s commit stage, committed tokens are “locked” (not-withdrawable) until the user either (1) reveals their vote or (2) rescues their tokens (more on this later)
partial-lock: although committed tokens are locked, you are able to and are highly encouraged to use those same “locked” tokens to commit votes in multiple polls at the same time
majority bloc: the group of voters who voted with a greater aggregate number of tokens
minority bloc: the group of voters who voted with a lesser aggregate number of tokens
voteTokenBalance
: mapping of user addresses: voting rights
voteOption
: voter’s choice for (binary) dispute resolution. in token-curated registries, references the candidate (applicant)
votesFor
: represents tokens voted in support for the candidatevotesAgainst
: represents tokens voted in opposition to the candidateacquire voting contract’s intrinsic token
plcr.startPoll(details)
: create a new poll and emit details about the poll to the network
startPoll
is a message sent via tcr.challenge(listing)
token.approve(voting)
: approve the voting contract, setting an allowance and enabling ERC20 transactions with the voting contract
plcr.requestVotingRights(tokens)
: transfer tokens from the user to the voting contract, increasing the user’s voteTokenBalance
(voting rights). in order to be able to lock and unlock tokens during periods, the voting contract must have control over voting tokens
requestVotingRights(tokens - votingRights)
the commitVote
functionplcr.commitVote(poll, secret, tokens)
: submit a secret token-weighted vote to a poll. the vote choice is hidden and submitted as a secret
plcr.revealVote(poll, keys)
: reveal the hidden contents of a committed vote. this confirms the secret commit’s validity and increases the number of total votes toward the user’s vote option
tcr.updateStatus(poll)
: ping the contract that initiated the poll. tally the votesFor
and votesAgainst
, resolve the challenge, and transfer tokens accordingly
tcr.withdraw()
tcr.claimReward(poll, key)
: claim reward tokens for voting with the winning side (the majority bloc of voters for that poll’s ruling). increasing the user’s voteTokenBalance
(voting rights)
plcr.withdrawVotingRights(tokens)
: transfer tokens from the voting contract to the user, decreasing the user’s voteTokenBalance
(voting rights)
plcr.rescueTokens()
. those tokens will not count toward the poll’s outcome, as the reveal stage must have ended by this point to proceed. they are unlocked and made available to be withdrawn if/when you desire to do soPLCRVoting v1.1 supports multi-commit and multi-reveal. if you have more than 1 poll you wish to commit/reveal for, you can collect the values of the multiple votes and send the consolidated data in a single transaction
since v1.1 requests voting rights within the commitVote
function, you can save an additional tx by NOT calling requestVotingRights
, and solely invoking commitVote
with the maximum number of tokens you are willing to actively use (i.e. lock) for voting. TLDR: don’t bother with requestVotingRights
, just call commitVote
during the commit stage: although users’ vote options are hidden (using a random salt), the number of tokens with which the user voted in the poll is emitted with the transaction and available to other users
a user can only have 1 valid commit per poll. a re-committed vote will effectively delete the former commit
voting in polls does not risk losing voting rights. if you vote in the minority bloc of a poll, you do not lose any tokens. yes, PLCR voting (in it’s current implementation) does not stake tokens!
Tactical goal: increase the number of tokens one owns
Strategic goal: increase the value of those tokens one owns