Skip to main content

Vote Contract

The Vote contract is an abstract layer for voting. Developers implement concrete voting activities by calling this contract. Implements aelf Standards ACS1.

Contract Methods

Method NameRequest TypeResponse TypeDescription
RegisterVote.VotingRegisterInput google.protobuf.Empty <#google.protobuf.Empty>Create a voting activity.
VoteVote.VoteInput google.protobuf.Empty <#google.protobuf.Empty>After successfully creating a voting activity, others are able to vote.
WithdrawVote.WithdrawInput google.protobuf.Empty <#google.protobuf.Empty>A voter can withdraw the token after the lock time.
TakeSnapshotVote.TakeSnapshotInput google.protobuf.Empty <#google.protobuf.Empty>Save the result of the specified number of votes and generates a new round of votes.
AddOptionVote.AddOptionInput google.protobuf.Empty <#google.protobuf.Empty>Add an option to a voting activity.
RemoveOptionVote.RemoveOptionInput google.protobuf.Empty <#google.protobuf.Empty>Remove an option from a voting activity.
AddOptionsVote.AddOptionsInput google.protobuf.Empty <#google.protobuf.Empty>Add multiple options to a voting activity.
RemoveOptionsVote.RemoveOptionsInput google.protobuf.Empty <#google.protobuf.Empty>Remove multiple options from a voting activity.
GetVotingItemVote.GetVotingItemInput Vote.VotingItem Get a voting activity information.
GetVotingResultVote.GetVotingResultInput Vote.VotingResult Get a voting result according to the provided voting activity id and snapshot number.
GetLatestVotingResultaelf.Hash Vote.VotingResult Gets the latest result according to the voting activity id.
GetVotingRecordaelf.Hash Vote.VotingRecord Get the voting record according to vote id.
GetVotingRecordsVote.GetVotingRecordsInput Vote.VotingRecords <#Vote.VotingRecords>Get the voting record according to vote ids.
GetVotedItemsaelf.Address Vote.VotedItems <#Vote.VotedItems>Get all voted information according to voter address.
GetVotingIdsVote.GetVotingIdsInput Vote.VotedIds Get the vote ids according to voting activity id.

AElf.Standards.ACS1

Method NameRequest TypeResponse TypeDescription
SetMethodFeeacs1.MethodFees google.protobuf.Empty Set the method fees for the specified method. Note that this will override all fees of the method.
ChangeMethodFeeControllerAuthorityInfogoogle.protobuf.Empty Change the method fee controller, the default is parliament and default organization.
GetMethodFeegoogle.protobuf.StringValue acs1.MethodFees Query method fee information by method name.
GetMethodFeeControllergoogle.protobuf.Empty AuthorityInfoQuery the method fee controller.

Contract Types

AElf.Contracts.Vote

Vote.AddOptionInput

FieldTypeDescriptionLabel
voting_item_idaelf.Hash The voting activity id.
optionstring The new option to add.

Vote.AddOptionsInput

FieldTypeDescriptionLabel
voting_item_idaelf.Hash The voting activity id.
optionsstring The new options to add.repeated

Vote.GetVotingIdsInput

FieldTypeDescriptionLabel
voteraelf.Address The address of voter.
voting_item_idaelf.Hash The voting activity id.

Vote.GetVotingItemInput

FieldTypeDescriptionLabel
voting_item_idaelf.Hash The voting activity id.

Vote.GetVotingRecordsInput

FieldTypeDescriptionLabel
idsaelf.Hash The vote ids.repeated

Vote.GetVotingResultInput

FieldTypeDescriptionLabel
voting_item_idaelf.Hash The voting activity id.
snapshot_numberint64 The snapshot number.

Vote.RemoveOptionInput

FieldTypeDescriptionLabel
voting_item_idaelf.Hash The voting activity id.
optionstring The option to remove.

Vote.RemoveOptionsInput

FieldTypeDescriptionLabel
voting_item_idaelf.Hash The voting activity id.
optionsstring The options to remove.repeated

Vote.TakeSnapshotInput

FieldTypeDescriptionLabel
voting_item_idaelf.Hash The voting activity id.
snapshot_numberint64 The snapshot number to take.

Vote.VoteInput

FieldTypeDescriptionLabel
voting_item_idaelf.Hash The voting activity id.
voteraelf.Address The address of voter.
amountint64 The amount of vote.
optionstring The option to vote.
vote_idaelf.Hash The vote id.
is_change_targetbool Whether vote others.

Vote.Voted

FieldTypeDescriptionLabel
voting_item_idaelf.Hash The voting activity id.
voteraelf.Address The address of voter.
snapshot_numberint64 The snapshot number.
amountint64 The amount of vote.
vote_timestampgoogle.protobuf.Timestamp <#google.protobuf.Timestamp>The time of vote.
optionstring The option voted.
vote_idaelf.Hash The vote id.

Vote.VotedIds

FieldTypeDescriptionLabel
active_votesaelf.Hash The active vote ids.repeated
withdrawn_votesaelf.Hash The withdrawn vote ids.repeated

Vote.VotedItems

FieldTypeDescriptionLabel
voted_item_vote_idsVotedItems.VotedItemVoteIdsEntry The voted ids.repeated

Vote.VotedItems.VotedItemVoteIdsEntry

FieldTypeDescriptionLabel
keystring
valueVotedIds

Vote.VotingItem

FieldTypeDescriptionLabel
voting_item_idaelf.Hash The voting activity id.
accepted_currencystring The token symbol which will be accepted.
is_lock_tokenbool Whether the vote will lock token.
current_snapshot_numberint64 The current snapshot number.
total_snapshot_numberint64 The total snapshot number.
optionsstring The list of options.repeated
register_timestampgoogle.protobuf.Timestamp <#google.protobuf.Timestamp>The register time of the voting activity.
start_timestampgoogle.protobuf.Timestamp <#google.protobuf.Timestamp>The start time of the voting.
end_timestampgoogle.protobuf.Timestamp <#google.protobuf.Timestamp>The end time of the voting.
current_snapshot_start_timestampgoogle.protobuf.Timestamp <#google.protobuf.Timestamp>The start time of current round of the voting.
sponsoraelf.Address The sponsor address of the voting activity.

Vote.VotingItemRegistered

FieldTypeDescriptionLabel
voting_item_idaelf.Hash The voting activity id.
accepted_currencystring The token symbol which will be accepted.
is_lock_tokenbool Whether the vote will lock token.
current_snapshot_numberint64 The current snapshot number.
total_snapshot_numberint64 The total number of snapshots of the vote.
register_timestampgoogle.protobuf.Timestamp <#google.protobuf.Timestamp>The register time of the voting activity.
start_timestampgoogle.protobuf.Timestamp <#google.protobuf.Timestamp>The start time of the voting.
end_timestampgoogle.protobuf.Timestamp <#google.protobuf.Timestamp>The end time of the voting.
current_snapshot_start_timestampgoogle.protobuf.Timestamp <#google.protobuf.Timestamp>The start time of current round of the voting.
sponsoraelf.Address The sponsor address of the voting activity.

Vote.VotingRecord

FieldTypeDescriptionLabel
voting_item_idaelf.Hash The voting activity id.
voteraelf.Address The address of voter.
snapshot_numberint64 The snapshot number.
amountint64 The amount of vote.
withdraw_timestampgoogle.protobuf.Timestamp <#google.protobuf.Timestamp>The time of withdraw.
vote_timestampgoogle.protobuf.Timestamp <#google.protobuf.Timestamp>The time of vote.
is_withdrawnbool Whether the vote had been withdrawn.
optionstring The option voted.
is_change_targetbool Whether vote others.

Vote.VotingRecords

FieldTypeDescriptionLabel
recordsVotingRecord The voting records.repeated

Vote.VotingRegisterInput

FieldTypeDescriptionLabel
start_timestampgoogle.protobuf.Timestamp <#google.protobuf.Timestamp>The start time of the voting.
end_timestampgoogle.protobuf.Timestamp <#google.protobuf.Timestamp>The end time of the voting.
accepted_currencystring The token symbol which will be accepted.
is_lock_tokenbool Whether the vote will lock token.
total_snapshot_numberint64 The total number of snapshots of the vote.
optionsstring The list of options.repeated

Vote.VotingResult

FieldTypeDescriptionLabel
voting_item_idaelf.Hash The voting activity id.
resultsVotingResult.ResultsEntry The voting result, option -> amount of votes,repeated
snapshot_numberint64 The snapshot number.
voters_countint64 The total number of voters.
snapshot_start_timestampgoogle.protobuf.Timestamp <#google.protobuf.Timestamp>The start time of this snapshot.
snapshot_end_timestampgoogle.protobuf.Timestamp <#google.protobuf.Timestamp>The end time of this snapshot.
votes_amountint64 Total votes received during the process of this snapshot.

Vote.VotingResult.ResultsEntry

FieldTypeDescriptionLabel
keystring
valueint64

Vote.WithdrawInput

FieldTypeDescriptionLabel
vote_idaelf.Hash The vote id.

Vote.Withdrawn

FieldTypeDescriptionLabel
vote_idaelf.Hash The vote id.

AElf.Standards.ACS1

acs1.MethodFee

FieldTypeDescriptionLabel
symbolstring The token symbol of the method fee.
basic_feeint64 The amount of fees to be charged.

acs1.MethodFees

FieldTypeDescriptionLabel
method_namestring The name of the method to be charged.
feesMethodFee List of fees to be charged.repeated
is_size_fee_freebool Optional based on the implementation of SetMethodFee method.

AElf.Types

aelf.Address

FieldTypeDescriptionLabel
valuebytes

aelf.BinaryMerkleTree

FieldTypeDescriptionLabel
nodesHash The leaf nodes.repeated
rootHash The root node hash.
leaf_countint32 The count of leaf node.

aelf.Hash

FieldTypeDescriptionLabel
valuebytes

aelf.LogEvent

FieldTypeDescriptionLabel
addressAddress The contract address.
namestring The name of the log event.
indexedbytes The indexed data.repeated
non_indexedbytes The non indexed data.

aelf.MerklePath

FieldTypeDescriptionLabel
merkle_path_nodesMerklePathNode The merkle path nodes.repeated

aelf.MerklePathNode

FieldTypeDescriptionLabel
hashHash The node hash.
is_left_child_nodebool Whether it is a left child node.

aelf.SInt32Value

FieldTypeDescriptionLabel
valuesint32

aelf.SInt64Value

FieldTypeDescriptionLabel
valuesint64

aelf.ScopedStatePath

FieldTypeDescriptionLabel
addressAddress The scope address, which will be the contract address.
pathStatePath <#aelf.StatePath>The path of contract state.

aelf.SmartContractRegistration

FieldTypeDescriptionLabel
categorysint32 The category of contract code(0: C#).
codebytes The byte array of the contract code.
code_hashHash The hash of the contract code.
is_system_contractbool Whether it is a system contract.
versionint32 The version of the current contract.

aelf.StatePath

FieldTypeDescriptionLabel
partsstring The partial path of the state path.repeated

aelf.Transaction

FieldTypeDescriptionLabel
fromAddress The address of the sender of the transaction.
toAddress The address of the contract when calling a contract.
ref_block_numberint64 The height of the referenced block hash.
ref_block_prefixbytes The first four bytes of the referenced block hash.
method_namestring The name of a method in the smart contract at the To address.
paramsbytes The parameters to pass to the smart contract method.
signaturebytes When signing a transaction it’s actually a subset of the fields: from/to and the target method as well as the parameter that were given.

aelf.TransactionExecutingStateSet.DeletesEntry

FieldTypeDescriptionLabel
keystring
valuebool

aelf.TransactionExecutingStateSet.ReadsEntry

FieldTypeDescriptionLabel
keystring
valuebool

aelf.TransactionExecutingStateSet.WritesEntry

FieldTypeDescriptionLabel
keystring
valuebytes

aelf.TransactionResult

FieldTypeDescriptionLabel
transaction_idHash The transaction id.
statusTransactionResultStatus The transaction result status.
logsLogEvent The log events.repeated
bloombytes Bloom filter for transaction logs.
return_valuebytes The return value of the transaction execution.
block_numberint64 **The height of the block that packages the transaction.
block_hashHash **The hash of the block that packages the transaction.
errorstring Failed execution error message.

aelf.TransactionResultStatus

NameNumberDescription
NOT_EXISTED0The execution result of the transaction does not exist.
PENDING1The transaction is in the transaction pool waiting to be packaged.
FAILED2Transaction execution failed.
MINED3The transaction was successfully executed and successfully packaged into a block.
CONFLICT4When executed in parallel, there are conflicts with other transactions.
PENDING_VALIDATION5The transaction is waiting for validation.
NODE_VALIDATION_FAILED6Transaction validation failed.

AuthorityInfo

FieldTypeDescriptionLabel
contract_addressaelf.Address The contract address of the controller.
owner_addressaelf.Address The address of the owner of the contract.