Open Action | Voting

Coming Soon - The voting open action lets you create polls on posts that use token voting. Release date TBA


This is a Lens Open Action for voting on a publication. A post creator can set up to 4 options for a vote and anyone can vote. Votes are placed by tokens and settled after the specified time period is up. At that point tokens are returned based on the parameters.

By default tokens are simply returned to sender after voting period is up and the results remain recorded in the contract. Optionally the post creator can opt to set the vote as forfeit on lose whereby all tokens that voted on losing options are forfeited and become claimable by the winners, proportional to how much they voted. The post creator also receives 10% of the losing tokens.

Post creators have the ability to set the number of options to vote on (up to 4) and they can set a max votes per user.


Encode module init data for a post

// module init data
    uint256 numberOfOptions, // total number of vote options - max 4
    bool losersForfeit, // whether or not losers forfeit their tokens
    uint256 voteDuration, // length of voting period - min 24 hours, max 30 days
    address token, // token to vote with
    uint256 maxVote // maximum vote size in tokens

Encode module act data. This is only used when voting. If you act on the post after the voting period is closed the act data is ignored and instead contract state is read to determine whether or not there are tokens to be returned to you.

// module act data
    uint256 option, // option to vote on
    uint256 amount // amount to vote with

Last updated