AElf.Contracts.Election
Election contract.
Used for voting for Block Producers.
Implement AElf Standards ACS1.
Contract Methods
Method Name |
Request Type |
Response Type |
Description |
---|---|---|---|
InitialElectionContract |
Initialize the election contract. |
||
RegisterElectionVotingEvent |
Register a new voting item through vote contract. |
||
TakeSnapshot |
Take snapshot according to term number, and distribute profits. |
||
AnnounceElection |
To be a block producer, a user should first register to be a candidate and lock some token as a deposit. If the data center is not full, the user will be added in automatically and get one weight for sharing bonus in the future. |
||
QuitElection |
A candidate is able to quit the election provided he is not currently elected. If you quit successfully, the candidate will get his locked tokens back and will not receive anymore bonus. |
||
Vote |
Used for voting for a candidate to be elected. The tokens you vote with will be locked until the end time. According to the number of token you voted and its lock time, you can get corresponding weight for sharing the bonus in the future. And return the vote id. |
||
ChangeVotingOption |
Before the end time, you are able to change your vote target to other candidates. |
||
Withdraw |
After the lock time, your locked tokens will be unlocked and you can withdraw them according to the vote id. |
||
UpdateCandidateInformation |
Update candidate information by consensus contract. |
||
UpdateMultipleCandidateInformation |
Batch update candidate information by consensus contract. |
||
UpdateMinersCount |
Update the count of miner by consensus contract. |
||
SetProfitsReceiver |
Set collect profits receiver address.. |
||
SetTreasurySchemeIds |
Set the treasury profit ids. |
||
SetVoteWeightInterest |
Set the weight of vote interest. |
||
SetVoteWeightProportion |
Set the weight of lock time and votes in the calculation of voting weight. |
||
ChangeVoteWeightInterestController |
Change the controller for the weight of vote interest. |
||
ReplaceCandidatePubkey |
Candidate admin can replace candidate pubkey with a new pubkey. |
||
SetCandidateAdmin |
Set admin address of candidate (mostly supply) |
||
GetCandidates |
Get all candidates’ public keys. |
||
GetVotedCandidates |
Get all candidates whose number of votes is greater than 0. |
||
GetCandidateInformation |
Get a candidate’s information. |
||
GetVictories |
Get the victories of the latest term. |
||
GetTermSnapshot |
Get the snapshot of term according to term number. |
||
GetMinersCount |
Get the count of miner. |
||
GetElectionResult |
Get the election result according to term id. |
||
GetElectorVote |
Get the voter information according to voter public key. |
||
GetElectorVoteWithRecords |
Gets the voter information including the active voting records (excluding withdrawn voting records.). |
||
GetElectorVoteWithAllRecords |
Gets the voter information including the active and withdrawn voting records. |
||
GetCandidateVote |
Get voting information for candidate according to the public key of the candidate. |
||
GetCandidateVoteWithRecords |
Get voting information for candidate according to the public key of the candidate. |
||
GetCandidateVoteWithAllRecords |
Get voting information for candidate according to the public key of the candidate (including the active and withdrawn voting records). |
||
GetVotersCount |
Get the total number of voters. |
||
GetVotesAmount |
Get the total number of vote token. |
||
GetPageableCandidateInformation |
Get candidate information according to the index and length. |
||
GetMinerElectionVotingItemId |
Get the voting item id of miner election. |
||
GetDataCenterRankingList |
Get the data center ranking list. |
||
GetVoteWeightSetting |
Get the weight of vote interest. |
||
GetVoteWeightProportion |
Get the weight of lock time and votes in the calculation of voting weight. |
||
GetCalculateVoteWeight |
Used to calculate the bonus weights that users can get by voting. |
||
GetVoteWeightInterestController |
Query the controller for the weight of vote interest. |
||
GetMinerReplacementInformation |
Inspect the evil nodes included in the specified miners and return to the replacement node. |
||
GetCandidateAdmin |
Query candidate admin. |
||
GetNewestPubkey |
Query the newest pubkey of an old pubkey. |
||
GetReplacedPubkey |
Query the old pubkey. |
AElf.Standards.ACS1
Method Name |
Request Type |
Response Type |
Description |
---|---|---|---|
SetMethodFee |
Set the method fees for the specified method. Note that this will override all fees of the method. |
||
ChangeMethodFeeController |
Change the method fee controller, the default is parliament and default organization. |
||
GetMethodFee |
Query method fee information by method name. |
||
GetMethodFeeController |
Query the method fee controller. |
Contract Types
AElf.Contracts.Election
Election.CandidateDetail
Field |
Type |
Description |
Label |
---|---|---|---|
candidate_information |
The candidate information. |
||
obtained_votes_amount |
The number of votes a candidate has obtained. |
Election.CandidateInformation
Field |
Type |
Description |
Label |
---|---|---|---|
pubkey |
Candidate’s public key. |
||
terms |
The number of terms that the candidate is elected. |
repeated |
|
produced_blocks |
The number of blocks the candidate has produced. |
||
missed_time_slots |
The time slot for which the candidate failed to produce blocks. |
||
continual_appointment_count |
The count of continual appointment. |
||
announcement_transaction_id |
The transaction id when the candidate announced. |
||
is_current_candidate |
Indicate whether the candidate can be elected in the current term. |
Election.CandidatePubkeyReplaced
Field |
Type |
Description |
Label |
---|---|---|---|
old_pubkey |
|||
new_pubkey |
Election.CandidateVote
Field |
Type |
Description |
Label |
---|---|---|---|
obtained_active_voting_record_ids |
The active voting record ids obtained. |
repeated |
|
obtained_withdrawn_voting_record_ids |
The active voting record ids that were withdrawn. |
repeated |
|
obtained_active_voted_votes_amount |
The total number of active votes obtained. |
||
all_obtained_voted_votes_amount |
The total number of votes obtained. |
||
obtained_active_voting_records |
The active voting records. |
repeated |
|
obtained_withdrawn_votes_records |
The voting records that were withdrawn. |
repeated |
|
pubkey |
Public key for candidate. |
Election.ChangeVotingOptionInput
Field |
Type |
Description |
Label |
---|---|---|---|
vote_id |
The vote id to change. |
||
candidate_pubkey |
The new candidate public key. |
Election.DataCenterRankingList
Field |
Type |
Description |
Label |
---|---|---|---|
data_centers |
The top n * 5 candidates with vote amount, candidate public key -> vote amount. |
repeated |
Election.DataCenterRankingList.DataCentersEntry
Field |
Type |
Description |
Label |
---|---|---|---|
key |
|||
value |
Election.ElectionResult
Field |
Type |
Description |
Label |
---|---|---|---|
term_number |
The term number |
||
results |
The election result, candidates’ public key -> number of votes. |
repeated |
|
is_active |
Whether an election is currently being held. |
Election.ElectionResult.ResultsEntry
Field |
Type |
Description |
Label |
---|---|---|---|
key |
|||
value |
Election.ElectionVotingRecord
Field |
Type |
Description |
Label |
---|---|---|---|
voter |
The address of voter. |
||
candidate |
The public key of candidate. |
||
amount |
Amount of voting. |
||
term_number |
The term number of voting. |
||
vote_id |
The vote id. |
||
lock_time |
Vote lock time. |
||
unlock_timestamp |
The unlock timestamp. |
||
withdraw_timestamp |
The withdraw timestamp. |
||
vote_timestamp |
The vote timestamp. |
||
is_withdrawn |
Indicates if the vote has been withdrawn. |
||
weight |
Vote weight for sharing bonus. |
||
is_change_target |
Whether vote others. |
Election.ElectorVote
Field |
Type |
Description |
Label |
---|---|---|---|
active_voting_record_ids |
The active voting record ids. |
repeated |
|
withdrawn_voting_record_ids |
The voting record ids that were withdrawn. |
repeated |
|
active_voted_votes_amount |
The total number of active votes. |
||
all_voted_votes_amount |
The total number of votes (including the number of votes withdrawn). |
||
active_voting_records |
The active voting records. |
repeated |
|
withdrawn_votes_records |
The voting records that were withdrawn. |
repeated |
|
pubkey |
Public key for voter. |
||
address |
Address for voter. |
Election.EvilMinerDetected
Field |
Type |
Description |
Label |
---|---|---|---|
pubkey |
The public key of evil miner. |
Election.GetElectionResultInput
Field |
Type |
Description |
Label |
---|---|---|---|
term_number |
The term number. |
Election.GetMinerReplacementInformationInput
Field |
Type |
Description |
Label |
---|---|---|---|
current_miner_list |
The current miner list to inspect. |
repeated |
Election.GetPageableCandidateInformationOutput
Field |
Type |
Description |
Label |
---|---|---|---|
value |
The details of the candidates. |
repeated |
Election.GetTermSnapshotInput
Field |
Type |
Description |
Label |
---|---|---|---|
term_number |
The term number. |
Election.InitialElectionContractInput
Field |
Type |
Description |
Label |
---|---|---|---|
minimum_lock_time |
Minimum number of seconds for locking. |
||
maximum_lock_time |
Maximum number of seconds for locking. |
||
miner_list |
The current miner list. |
repeated |
|
time_each_term |
The number of seconds per term. |
||
miner_increase_interval |
The interval second that increases the number of miners. |
Election.MinerReplacementInformation
Field |
Type |
Description |
Label |
---|---|---|---|
alternative_candidate_pubkeys |
The alternative candidate public keys. |
repeated |
|
evil_miner_pubkeys |
The evil miner public keys. |
repeated |
Election.PageInformation
Field |
Type |
Description |
Label |
---|---|---|---|
start |
The start index. |
||
length |
The number of records. |
Election.PubkeyList
Field |
Type |
Description |
Label |
---|---|---|---|
value |
Candidates’ public keys |
repeated |
Election.ReplaceCandidatePubkeyInput
Field |
Type |
Description |
Label |
---|---|---|---|
old_pubkey |
|||
new_pubkey |
Election.SetCandidateAdminInput
Field |
Type |
Description |
Label |
---|---|---|---|
pubkey |
|||
admin |
Election.SetProfitsReceiverInput
Field |
Type |
Description |
Label |
---|---|---|---|
candidate_pubkey |
The candidate’s public key. |
||
profits_receiver_address |
The address of profits receiver. |
||
previous_receiver_address |
The previous address of profits receiver. |
Election.SetTreasurySchemeIdsInput
Field |
Type |
Description |
Label |
---|---|---|---|
treasury_hash |
The scheme id of treasury reward. |
||
welfare_hash |
The scheme id of welfare reward. |
||
subsidy_hash |
The scheme id of subsidy reward. |
||
votes_reward_hash |
The scheme id of votes reward. |
||
re_election_reward_hash |
The scheme id of re-election reward. |
Election.TakeElectionSnapshotInput
Field |
Type |
Description |
Label |
---|---|---|---|
term_number |
The term number to take snapshot. |
||
mined_blocks |
The number of mined blocks of this term. |
||
round_number |
The end round number of this term. |
Election.TermSnapshot
Field |
Type |
Description |
Label |
---|---|---|---|
end_round_number |
The end round number of this term. |
||
mined_blocks |
The number of blocks mined in this term. |
||
election_result |
The election result, candidates’ public key -> number of votes. |
repeated |
Election.TermSnapshot.ElectionResultEntry
Field |
Type |
Description |
Label |
---|---|---|---|
key |
|||
value |
Election.UpdateCandidateInformationInput
Field |
Type |
Description |
Label |
---|---|---|---|
pubkey |
The candidate public key. |
||
recently_produced_blocks |
The number of blocks recently produced. |
||
recently_missed_time_slots |
The number of time slots recently missed. |
||
is_evil_node |
Is it a evil node. If true will remove the candidate. |
Election.UpdateMinersCountInput
Field |
Type |
Description |
Label |
---|---|---|---|
miners_count |
The count of miner. |
Election.UpdateMultipleCandidateInformationInput
Field |
Type |
Description |
Label |
---|---|---|---|
value |
The candidate information to update. |
repeated |
Election.UpdateTermNumberInput
Field |
Type |
Description |
Label |
---|---|---|---|
term_number |
The term number. |
Election.VoteInformation
Field |
Type |
Description |
Label |
---|---|---|---|
amount |
Amount of voting. |
||
lock_time |
Vote lock time. |
Election.VoteMinerInput
Field |
Type |
Description |
Label |
---|---|---|---|
candidate_pubkey |
The candidate public key. |
||
amount |
The amount token to vote. |
||
end_timestamp |
The end timestamp of this vote. |
||
token |
Used to generate vote id. |
Election.VoteWeightInterest
Field |
Type |
Description |
Label |
---|---|---|---|
day |
Number of days locked. |
||
interest |
Locked interest. |
||
capital |
Election.VoteWeightInterestList
Field |
Type |
Description |
Label |
---|---|---|---|
vote_weight_interest_infos |
The weight of vote interest. |
repeated |
Election.VoteWeightProportion
Field |
Type |
Description |
Label |
---|---|---|---|
time_proportion |
The weight of lock time. |
||
amount_proportion |
The weight of the votes cast. |
AElf.Standards.ACS1
acs1.MethodFee
Field |
Type |
Description |
Label |
---|---|---|---|
symbol |
The token symbol of the method fee. |
||
basic_fee |
The amount of fees to be charged. |
acs1.MethodFees
Field |
Type |
Description |
Label |
---|---|---|---|
method_name |
The name of the method to be charged. |
||
fees |
List of fees to be charged. |
repeated |
|
is_size_fee_free |
Optional based on the implementation of SetMethodFee method. |
AElf.Types
aelf.Address
Field |
Type |
Description |
Label |
---|---|---|---|
value |
aelf.BinaryMerkleTree
Field |
Type |
Description |
Label |
---|---|---|---|
nodes |
The leaf nodes. |
repeated |
|
root |
The root node hash. |
||
leaf_count |
The count of leaf node. |
aelf.Hash
Field |
Type |
Description |
Label |
---|---|---|---|
value |
aelf.LogEvent
Field |
Type |
Description |
Label |
---|---|---|---|
address |
The contract address. |
||
name |
The name of the log event. |
||
indexed |
The indexed data, used to calculate bloom. |
repeated |
|
non_indexed |
The non indexed data. |
aelf.MerklePath
Field |
Type |
Description |
Label |
---|---|---|---|
merkle_path_nodes |
The merkle path nodes. |
repeated |
aelf.MerklePathNode
Field |
Type |
Description |
Label |
---|---|---|---|
hash |
The node hash. |
||
is_left_child_node |
Whether it is a left child node. |
aelf.SInt32Value
Field |
Type |
Description |
Label |
---|---|---|---|
value |
aelf.SInt64Value
Field |
Type |
Description |
Label |
---|---|---|---|
value |
aelf.ScopedStatePath
Field |
Type |
Description |
Label |
---|---|---|---|
address |
The scope address, which will be the contract address. |
||
path |
The path of contract state. |
aelf.SmartContractRegistration
Field |
Type |
Description |
Label |
---|---|---|---|
category |
The category of contract code(0: C#). |
||
code |
The byte array of the contract code. |
||
code_hash |
The hash of the contract code. |
||
is_system_contract |
Whether it is a system contract. |
||
version |
The version of the current contract. |
aelf.StatePath
Field |
Type |
Description |
Label |
---|---|---|---|
parts |
The partial path of the state path. |
repeated |
aelf.Transaction
Field |
Type |
Description |
Label |
---|---|---|---|
from |
The address of the sender of the transaction. |
||
to |
The address of the contract when calling a contract. |
||
ref_block_number |
The height of the referenced block hash. |
||
ref_block_prefix |
The first four bytes of the referenced block hash. |
||
method_name |
The name of a method in the smart contract at the To address. |
||
params |
The parameters to pass to the smart contract method. |
||
signature |
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. It also contains the reference block number and prefix. |
aelf.TransactionExecutingStateSet
Field |
Type |
Description |
Label |
---|---|---|---|
writes |
The changed states. |
repeated |
|
reads |
The read states. |
repeated |
|
deletes |
The deleted states. |
repeated |
aelf.TransactionExecutingStateSet.DeletesEntry
Field |
Type |
Description |
Label |
---|---|---|---|
key |
|||
value |
aelf.TransactionExecutingStateSet.ReadsEntry
Field |
Type |
Description |
Label |
---|---|---|---|
key |
|||
value |
aelf.TransactionExecutingStateSet.WritesEntry
Field |
Type |
Description |
Label |
---|---|---|---|
key |
|||
value |
aelf.TransactionResult
Field |
Type |
Description |
Label |
---|---|---|---|
transaction_id |
The transaction id. |
||
status |
The transaction result status. |
||
logs |
The log events. |
repeated |
|
bloom |
Bloom filter for transaction logs. A transaction log event can be defined in the contract and stored in the bloom filter after the transaction is executed. Through this filter, we can quickly search for and determine whether a log exists in the transaction result. |
||
return_value |
The return value of the transaction execution. |
||
block_number |
The height of the block hat packages the transaction. |
||
block_hash |
The hash of the block hat packages the transaction. |
||
error |
Failed execution error message. |
aelf.TransactionResultStatus
Name |
Number |
Description |
---|---|---|
NOT_EXISTED |
0 |
The execution result of the transaction does not exist. |
PENDING |
1 |
The transaction is in the transaction pool waiting to be packaged. |
FAILED |
2 |
Transaction execution failed. |
MINED |
3 |
The transaction was successfully executed and successfully packaged into a block. |
CONFLICT |
4 |
When executed in parallel, there are conflicts with other transactions. |
PENDING_VALIDATION |
5 |
The transaction is waiting for validation. |
NODE_VALIDATION_FAILED |
6 |
Transaction validation failed. |