Voting System Operations
Cast Vote
Cast a vote on a poll. POST only.
Request: Refer to Create Transaction Request for common parameters.
requestTypeiscastVotepollis the poll IDvote00is an integer within the allowed range to vote for option (answer) 0 (optional ifminNumberOfOptionsmet, default is\-128)vote01is an integer within the allowed range to vote for option (answer) 1 (optional ifminNumberOfOptionsmet, default is\-128)vote02is an integer within the allowed range to vote for option (answer) 2 (optional ifminNumberOfOptionsmet, 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.
requestTypeiscreatePollnameis the name of the polldescriptionis the description of the poll, or the question to be answeredfinishHeightis the block height when the poll is completedvotingModelis0forOne Vote Per Account,1forVote By BLX Balance,2forVote By Asset Balanceand3forVote By Currency BalanceminNumberOfOptionsis the minimum number of options (answers) that must be voted formaxNumberOfOptionsis the maximum number of options (answers) that can be voted forminRangeValueis the minimum integer value for an option (answer) (>=0)maxRangeValueis the maximum integer value for an option (answer) (>=minRangeValue)minBalanceis the minimum balance (in NQT or QNT) required for voting (optional, default 0)minBalanceModelis (required ifminBalance>0, must matchvotingModelwhenvotingModel>0)1for BLX balance2for an asset balance3for a currency balance
holdingis the asset or currency ID (required ifminBalanceModel>1)option00is the name of option (answer) 0option01is the name of option (answer) 1 (optional)option02is 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:
requestTypeisgetPollpollis the poll IDrequireBlockis the block ID of a block that must be present in the blockchain during execution (optional)requireLastBlockis 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) istrueif the poll is completed,falseotherwisevotingModel(N) is0for -one Vote Per Account,1forVote By BLX Balance,2forVote By Asset Balanceand3forVote 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) is1for BLX balance,2for an asset balance,3for a currency balance whenminBalance> 0holdingis 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 ifrequireBlockis 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:
requestTypeisgetPollResultpollis the poll IDvotingModel(optional, default null)holding(optional, default null)minBalance(optional, default0)minBalanceModel(required ifminBalance>0, must matchvotingModelwhenvotingModel>0)requireBlockis the block ID of a block that must be present in the blockchain during execution (optional)requireLastBlockis 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) istrueif the poll is complete,falseotherwiseoptions(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 theweightof each account that voted for the corresponding option (answer); an account'sweightis1if the voting model is0, otherwise it is the NQT, asset QNT or currency QNT balance of the account if the voting model is1,2or3respectively; however, theweightis0ifminBalanceis not metresult(S) is the sum over each account that voted for the corresponding option (answer) of: the product of the account'sweightand therangeValueselected when the vote was cast.
lastBlock(S) is the last block ID on the blockchain (applies ifrequireBlockis 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:
requestTypeisgetPollVotepollis the poll IDaccountis the account IDincludeWeightsistrueto calculate and return the weight assigned to each vote (optional)requireBlockis the block ID of a block that must be present in the blockchain during execution (optional)requireLastBlockis 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 ifincludeWeightsistrue)lastBlock(S) is the last block ID on the blockchain (applies ifrequireBlockis 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:
requestTypeisgetPollVotespollis the poll IDincludeWeightsistrueto calculate and return the weight assigned to each vote (optional)firstIndexis a zero-based index to the first vote to retrieve (optional)lastIndexis a zero-based index to the last vote to retrieve (optional)requireBlockis the block ID of a block that must be present in the blockchain during execution (optional)requireLastBlockis 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 ifrequireBlockis 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:
requestTypeisgetPollsaccountis a creation account ID filter (optional)timestampis the earliest poll (in seconds since the genesis block) to retrieve (optional)firstIndexis a zero-based index to the first poll to retrieve (optional)lastIndexis a zero-based index to the last poll to retrieve (optional)includeFinishedistrueto include completed polls (optional)finishedOnlyistrueto exclude not yet executed, phased transactions (optional)requireBlockis the block ID of a block that must be present in the blockchain during execution (optional)requireLastBlockis 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 ifrequireBlockis 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:
requestTypeissearchPollsqueryis a full text query on the poll fieldsname(S) anddescription(S) in the standard Lucene syntax (opens in a new tab) (optional)firstIndexis a zero-based index to the first poll to retrieve (optional)lastIndexis a zero-based index to the last poll to retrieve (optional)includeFinishedistrueto include completed polls (optional)requireBlockis the block ID of a block that must be present in the blockchain during execution (optional)requireLastBlockis 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 ifrequireBlockis provided but notrequireLastBlock)requestProcessingTime(N) is the API request processing time (in millisec)
Example: Refer to Search Polls example.