Voting System Operations
Cast Vote
Cast a vote on a poll. POST only.
Request: Refer to Create Transaction Request for common parameters.
requestType
iscastVote
poll
is the poll IDvote00
is an integer within the allowed range to vote for option (answer) 0 (optional ifminNumberOfOptions
met, default is\-128
)vote01
is an integer within the allowed range to vote for option (answer) 1 (optional ifminNumberOfOptions
met, default is\-128
)vote02
is an integer within the allowed range to vote for option (answer) 2 (optional ifminNumberOfOptions
met, default is\-128
)
Note: The allowed vote values are integers between minRangeValue
and maxRangeValue
, inclusive. This range, along with the minimum and maximum number of options that can and must be voted on are specified when the poll is created. Refer to Create Poll.
Response: Refer to Create Transaction Response.
Example: Refer to Cast Vote example.
Create Poll
Create a new poll. POST only.
Request: Refer to Create Transaction Request for common parameters.
requestType
iscreatePoll
name
is the name of the polldescription
is the description of the poll, or the question to be answeredfinishHeight
is the block height when the poll is completedvotingModel
is0
forOne Vote Per Account
,1
forVote By BLX Balance
,2
forVote By Asset Balance
and3
forVote By Currency Balance
minNumberOfOptions
is the minimum number of options (answers) that must be voted formaxNumberOfOptions
is the maximum number of options (answers) that can be voted forminRangeValue
is the minimum integer value for an option (answer) (>=0
)maxRangeValue
is the maximum integer value for an option (answer) (>=minRangeValue
)minBalance
is the minimum balance (in NQT or QNT) required for voting (optional, default 0)minBalanceModel
is (required ifminBalance
>0
, must matchvotingModel
whenvotingModel
>0
)1
for BLX balance2
for an asset balance3
for a currency balance
holding
is the asset or currency ID (required ifminBalanceModel
>1
)option00
is the name of option (answer) 0option01
is the name of option (answer) 1 (optional)option02
is the name of option (answer) 2 (optional)
Note: When a balance affects the poll result, the result depends only on the balance (including pending outgoing phased transfers) computed just prior to the finish height.
Response: Refer to Create Transaction Response. The transaction ID is also the poll ID.
Example: Refer to Create Poll example.
Get Poll
Get the details of a poll.
Request:
requestType
isgetPoll
poll
is the poll IDrequireBlock
is the block ID of a block that must be present in the blockchain during execution (optional)requireLastBlock
is the block ID of a block that must be last in the blockchain during execution (optional)
Response:
poll
(S) is the poll IDaccount
(S) is the account number of the poll creatoraccountRS
(S) is the Reed-Solomon address of the accountname
(S) is the name of the polldescription
(S) is the description of the poll, or the question to be answeredfinishHeight
(N) is the block height when the poll is completedfinished
(B) istrue
if the poll is completed,false
otherwisevotingModel
(N) is0
for -one Vote Per Account,
1for
Vote By BLX Balance,
2for
Vote By Asset Balanceand
3for
Vote By Currency Balance`minNumberOfOptions
(N) is the minimum number of options (answers) that must be voted formaxNumberOfOptions
(N) is the maximum number of options (answers) that can be voted forminBalance
(S) is the minimum balance (in NQT or QNT) required for votingminBalanceModel
(N) is1
for BLX balance,2
for an asset balance,3
for a currency balance whenminBalance
> 0holding
is the asset or currency ID when minBalanceModel > 1options
(A) is the array of options (answers)minRangeValue
(N) is the minimum integer value for an option (answer)maxRangeValue
(N) is the maximum integer value for an option (answer)lastBlock
(S) is the last block ID on the blockchain (applies ifrequireBlock
is provided but notrequireLastBlock
)requestProcessingTime
(N) is the API request processing time (in millisec)
Example: Refer to Get Poll example.
Get Poll Result
Get the result of a poll.
Request:
requestType
isgetPollResult
poll
is the poll IDvotingModel
(optional, default null)holding
(optional, default null)minBalance
(optional, default0
)minBalanceModel
(required ifminBalance
>0
, must matchvotingModel
whenvotingModel
>0
)requireBlock
is the block ID of a block that must be present in the blockchain during execution (optional)requireLastBlock
is the block ID of a block that must be last in the blockchain during execution (optional)
Note: The votingModel
, holding
, minBalance
and minBalanceModel
parameters are optional and default to the original values specified when the poll was created (refer to Create Poll). The original values can only be overridden while the votes are still stored in the database, until 1441 blocks after the poll is completed. If votingModel
is specified, holding
, minBalance
and minBalanceModel
or the defaults specified above apply, otherwise they are ignored.
Response:
poll
(S) is the poll IDvotingModel
(N) is the votingModel used to calculateresults
(refer to Note above)minBalanceModel
(N) is the minBalanceModel used to calculateresults
(refer to Note above)minBalance
(S) is the minBalance used to calculateresults
(refer to Note above)holding
(S) is the asset or currency ID if the voting model uses an asset or currency balance to determineweight
, if applicable (refer to Note above)decimals
(N) is the number decimal places used by the asset or currency, if applicablefinished
(B) istrue
if the poll is complete,false
otherwiseoptions
(A) is the array of options (answers) of the pollresults
(A) is an array of result objects with the following fields for each result:weight
(S) is the sum of theweight
of each account that voted for the corresponding option (answer); an account'sweight
is1
if the voting model is0
, otherwise it is the NQT, asset QNT or currency QNT balance of the account if the voting model is1
,2
or3
respectively; however, theweight
is0
ifminBalance
is not metresult
(S) is the sum over each account that voted for the corresponding option (answer) of: the product of the account'sweight
and therangeValue
selected when the vote was cast.
lastBlock
(S) is the last block ID on the blockchain (applies ifrequireBlock
is provided but notrequireLastBlock
)requestProcessingTime
(N) is the API request processing time (in millisec)
Example: Refer to Get Poll Result example.
Get Poll Vote
Get a poll vote given a poll ID and an account ID.
Request:
requestType
isgetPollVote
poll
is the poll IDaccount
is the account IDincludeWeights
istrue
to calculate and return the weight assigned to each vote (optional)requireBlock
is the block ID of a block that must be present in the blockchain during execution (optional)requireLastBlock
is the block ID of a block that must be last in the blockchain during execution (optional)
Response:
votes
(A) is an array of votes, the range values (S) corresponding to each option (answer) with empty strings for non-votesvoter
(S) is the account number of the votervoterRS
(S) is the Reed-Solomon address of the votertransaction
(S) is the transaction ID of the voteweight
(S) is the weight assigned to each vote (applies ifincludeWeights
istrue
)lastBlock
(S) is the last block ID on the blockchain (applies ifrequireBlock
is provided but notrequireLastBlock
)requestProcessingTime
(N) is the API request processing time (in millisec)
Note: Votes are deleted from the database 1441 blocks after the poll is finished. Only aggregate results are kept (refer to Get Poll Result).
Example: Refer to Get Poll Vote example.
Get Poll Votes
Get all votes on a poll in reverse chronological order.
Request:
requestType
isgetPollVotes
poll
is the poll IDincludeWeights
istrue
to calculate and return the weight assigned to each vote (optional)firstIndex
is a zero-based index to the first vote to retrieve (optional)lastIndex
is a zero-based index to the last vote to retrieve (optional)requireBlock
is the block ID of a block that must be present in the blockchain during execution (optional)requireLastBlock
is the block ID of a block that must be last in the blockchain during execution (optional)
Response:
votes
(A) is an array of vote objects (refer to Get Poll Vote for details)lastBlock
(S) is the last block ID on the blockchain (applies ifrequireBlock
is provided but notrequireLastBlock
)requestProcessingTime
(N) is the API request processing time (in millisec)
Note: Votes are deleted from the database 1441 blocks after the poll is finished. Only aggregate results are kept (refer to Get Poll Result).
Example: Refer to Get Poll Votes example.
Get Polls
Get poll details in reverse creation order.
Request:
requestType
isgetPolls
account
is a creation account ID filter (optional)timestamp
is the earliest poll (in seconds since the genesis block) to retrieve (optional)firstIndex
is a zero-based index to the first poll to retrieve (optional)lastIndex
is a zero-based index to the last poll to retrieve (optional)includeFinished
istrue
to include completed polls (optional)finishedOnly
istrue
to exclude not yet executed, phased transactions (optional)requireBlock
is the block ID of a block that must be present in the blockchain during execution (optional)requireLastBlock
is the block ID of a block that must be last in the blockchain during execution (optional)
Response:
polls
(A) is an array of polls (refer to Get Poll for details)lastBlock
(S) is the last block ID on the blockchain (applies ifrequireBlock
is provided but notrequireLastBlock
)requestProcessingTime
(N) is the API request processing time (in millisec)
Example: Refer to Get Polls example.
Search Polls
Search for poll details given a name/description query string.
Request:
requestType
issearchPolls
query
is a full text query on the poll fieldsname
(S) anddescription
(S) in the standard Lucene syntax (opens in a new tab) (optional)firstIndex
is a zero-based index to the first poll to retrieve (optional)lastIndex
is a zero-based index to the last poll to retrieve (optional)includeFinished
istrue
to include completed polls (optional)requireBlock
is the block ID of a block that must be present in the blockchain during execution (optional)requireLastBlock
is the block ID of a block that must be last in the blockchain during execution (optional)
Response:
polls
(A) is an array of polls (refer to Get Poll for details)lastBlock
(S) is the last block ID on the blockchain (applies ifrequireBlock
is provided but notrequireLastBlock
)requestProcessingTime
(N) is the API request processing time (in millisec)
Example: Refer to Search Polls example.