Check out Lisk SDK examples and official lisk.io documentation for setup instructions.
Below is the short description of states and transactions.
Each poll is set to created when created. Closed poll cannot be re-opened. Polls and their results cannot be deleted.
1.Created state
- everyone can view the poll
- noone can vote
- the owner can open the poll
2.Opened state
- everyone can view the poll
- everyone can vote and change their vote
- noone can see the results
- the owner can close the poll
3.Closed state
- everyone can view the poll
- everyone can display results
- noone can change the vote
In order to achieve all mentioned states, three transactions were created.
- create poll
- update poll
- vote
Polls and votes are stored on the senders account in following form.
// PollState = [ "created", "opened", "closed" ]
{
...
"address": string,
"balance": BigNum,
"asset": {
"polls" [
{
"id": uuid, // pollId
"title": string,
"options": [
{
"text": string,
"id": int // optionId
}
],
"state": PollState
}
],
"votes": {
[pollId]: [optionId]
}
},
...
}