# ConsensusGroup

# Contract Specification

Built-in consensus group contract. Contract address is vite_0000000000000000000000000000000000000004d28108e76b

ABI:

Copy [ // Register block producer {"type":"function","name":"Register", "inputs":[{"name":"gid","type":"gid"},{"name":"name","type":"string"},{"name":"nodeAddr","type":"address"}]}, // Update registration {"type":"function","name":"UpdateRegistration", "inputs":[{"name":"gid","type":"gid"},{"Name":"name","type":"string"},{"name":"nodeAddr","type":"address"}]}, // Cancel registration {"type":"function","name":"CancelRegister","inputs":[{"name":"gid","type":"gid"}, {"name":"name","type":"string"}]}, // Retrieve mining rewards {"type":"function","name":"Reward","inputs":[{"name":"gid","type":"gid"},{"name":"name","type":"string"},{"name":"beneficialAddr","type":"address"}]}, // Vote for block producer {"type":"function","name":"Vote", "inputs":[{"name":"gid","type":"gid"},{"name":"nodeName","type":"string"}]}, // Cancel voting {"type":"function","name":"CancelVote","inputs":[{"name":"gid","type":"gid"}]} ]

# register_getRegisterData

Generate request data for registering a new supernode in the specified consensus group. Equivalent to Register method in ABI.

  • Parameters:

    • Gid: Consensus group ID
    • string: Supernode name
    • Address: Block producing address
  • Returns:

    • []byte Data
  • Example:

# register_getCancelRegisterData

Generate request data for cancelling existing supernode registration in the specified consensus group. Equivalent to CancelRegister method in ABI.

  • Parameters:

    • Gid: Consensus group ID
    • string: Supernode name
  • Returns:

    • []byte Data
  • Example:

# register_getRewardData

Generate request data for retrieving supernode rewards if applied. Rewards in 90 days(or all accumulated un-retrieved rewards if less than 90 days) since last retrieval can be retrieved per request. Cannot retrieve rewards generated in recent 30 minutes. Equivalent to Reward method in ABI.

  • Parameters:

    • Gid: Consensus group ID
    • string: Supernode name
    • Address: The address to receive rewards
  • Returns:

    • []byte Data
  • Example:

# register_getUpdateRegistrationData

Generate request data for changing block producer in existing registration. Equivalent to UpdateRegistration method in ABI.

  • Parameters:

    • Gid: Consensus group ID, must be the same value as registered and cannot be changed
    • string: Supernode name, must be the same value as registered and cannot be changed
    • Address: New block producing address
  • Returns:

    • []byte Data
  • Example:

# register_getRegistrationList

Return a list of supernodes registered in the specified consensus group by account, ordered by expiration height

  • Parameters:

    • Gid: Consensus group ID
    • Address: Staking address
  • Returns:

Array<RegistartionInfo>

  1. name: string Supernode name
  2. nodeAddr: Address Block producing address
  3. pledgeAddr: Address Staking address
  4. pledgeAmount: big.Int Staking amount
  5. withdrawHeight: uint64 Staking expiration height
  6. withdrawTime: uint64 Estimated staking expiration time
  7. cancelHeight: uint64 Staking cancellation time. If the value > 0, meaning already cancelled.
  • Example:

# register_getAvailableReward

Return un-retrieved rewards in the specified consensus group by supernode name

  • Parameters:

    • Gid: Consensus group ID
    • string: Supernode name
  • Returns:

RewardInfo

  1. totalReward: string Accumulated un-retrieved rewards
  2. blockReward: Address Accumulated un-retrieved block creation rewards
  3. voteReward: Address Accumulated un-retrieved candidate additional rewards(voting rewards)
  4. drained: bool Return true only if the supernode has been canceled and all un-retrieved reward is zero
  • Example:

# register_getRewardByDay

Return daily rewards for all supernodes in the specified consensus group by timestamp

  • Parameters:

    • Gid: Consensus group ID
    • timestamp: Unix timestamp
  • Returns:

map<string>RewardInfo

  1. totalReward: string Total rewards in the day
  2. blockReward: Address Block creation rewards in the day
  3. voteReward: Address Candidate additional rewards(voting rewards) in the day
  4. expectedBlockNum: uint64 Target block producing number in the day. If zero block is produced by all supernodes in a round, the target block producing number in this round won't be counted in that of the day
  5. blockNum: uint64 Real block producing number in the day
  • Example:

# register_getRewardByIndex

Return daily rewards for all supernodes in the specified consensus group by cycle

  • Parameters:

    • Gid: Consensus group ID
    • uint64: Index of cycle in 24h starting at 0 from 12:00:00 UTC+8 05/21/2019
  • Returns:

Object

  1. rewardMap:map<string>RewardInfo Detailed reward information
  2. startTime:int64 Start time
  3. endTime:int64 End time
  • Example:

# register_getCandidateList

Return a list of SBP candidates in snapshot consensus group

  • Parameters:

  • Returns:

Array&lt;CandidateInfo&gt;

  1. name: string SBP name
  2. nodeAddr: Address Block producing address
  3. voteNum: string Number of votes
  • Example:

# vote_getVoteData

Generate request data for voting for the named supernode in the specified consensus group. Equivalent to Vote method in ABI.

  • Parameters:

    • Gid: Consensus group ID
    • string: Supernode name
  • Returns:

    • []byte Data
  • Example:

# vote_getCancelVoteData

Generate request data for cancelling voting in the specified consensus group. Equivalent to CancelVote method in ABI.

  • Parameters:

    • Gid: Consensus group ID
  • Returns:

    • []byte Data
  • Example:

# vote_getVoteInfo

Return the voting information in the specified consensus group by account

  • Parameters:

    • Gid: Consensus group ID
    • Address: Account address
  • Returns:

Object

  1. nodeName: string Supernode name
  2. nodeStatus: uint8 Supernode registration status. 1->valid. 2->invalid
  3. balance: big.Int Account balance
  • Example:

# vote_getVoteDetails

Return daily SBP voting information

  • Parameters:

    • Index: Index of days. 0 stands for the first launching day
  • Returns:

Array&lt;VoteDetails&gt;

  1. Name: string SBP name
  2. Balance: big.Int Total number of votes
  3. Addr: map Map of "voting address: voting amount"
  • Example: