DPoS API
Console API and JSON-RPC API related to DxChain3.0 system contract
JSON-RPC
For example:
curl -H 'content-type:application/json' -d '{"jsonrpc":"2.0","method":"dpos_getBaseInfos","params":[],"id":1}' RPC_URLWhen querying the specified block height, please make sure that the
RPC-URLarchive mode is enabled.
dpos_getBaseInfos
dpos.base() in console.
Get all the basic parameters related to the system contract.
Parameter
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
params: [
null |'latest' | 'earliest' | 'pending' | 'hex number'
]Return
All basic parameters related to the system contract.
Example
curl -H 'content-type:application/json' -d '{"jsonrpc":"2.0","method":"dpos_getBaseInfos","params":["latest"],"id":1}' RPC_URL
// dpos.base("latest")
// result
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"BLACK_HOLE_ADDRESS": "0x0000000000000000000000000000000000000000",
"BLOCK_SECONDS": 3,
"EPOCH_BLOCKS": 28800,
"MAX_LEVEL_VALIDATOR_COUNT": 120,
"MAX_PUNISH_COUNT": 278,
"MAX_RATE": 100,
"MAX_VALIDATORS_COUNT": 210,
"MAX_VALIDATOR_COUNT_LV1": 21,
"MAX_VALIDATOR_COUNT_LV2": 33,
"MAX_VALIDATOR_COUNT_LV3": 66,
"MAX_VALIDATOR_COUNT_LV4": 99,
"MAX_VALIDATOR_DETAIL_LENGTH": 1000,
"MEDIUM_LEVEL_VALIDATOR_COUNT": 90,
"MIN_DEPOSIT": 40000000000000000000000000,
"MIN_LEVEL_VALIDATOR_COUNT": 60,
"MIN_RATE": 70,
"PROPOSAL_DURATION_EPOCHS": 7,
"RATE_SET_LOCK_EPOCHS": 1,
"REWARD_DEPOSIT_FROM_LV1_TO_LV2": 128250000000000000000,
"REWARD_DEPOSIT_FROM_LV2_TO_LV3": 157125000000000000000,
"REWARD_DEPOSIT_FROM_LV3_TO_LV4": 180750000000000000000,
"REWARD_DEPOSIT_FROM_LV4_TO_LV5": 199875000000000000000,
"REWARD_DEPOSIT_OVER_LV5": 214125000000000000000,
"REWARD_DEPOSIT_UNDER_LV1": 95250000000000000000,
"SAFE_MULTIPLIER": 1000000000000000000,
"TOTAL_DEPOSIT_LV1": 15000000000000000000000000000,
"TOTAL_DEPOSIT_LV2": 20000000000000000000000000000,
"TOTAL_DEPOSIT_LV3": 25000000000000000000000000000,
"TOTAL_DEPOSIT_LV4": 30000000000000000000000000000,
"TOTAL_DEPOSIT_LV5": 35000000000000000000000000000,
"VALIDATOR_REWARD_LOCK_EPOCHS": 7,
"VALIDATOR_UNSTAKE_LOCK_EPOCHS": 1,
"VOTE_CANCEL_EPOCHS": 1
}
}dpos_getAllProposalSets
dpos.allProposalIds()in console.
Get the (bytes4) id of all node application records.
Parameter
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
A list of (bytes4) ids containing all node request records.
Example
dpos_getAddressProposalSets
dpos.addressProposalIds(address)in console.
Get the (bytes4) id of the node application record of an address.
Parameter
address: Search the address
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
A list of (bytes4) ids containing the node request record for an address.
Example
dpos_getProposal
dpos.proposal(id)in console.
Get the detailed information of a node's application record.
Parameter
id: Node application record id
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
id: Node application id
Proposer: The address of applicant
Deposit: Amount of staking
Rate: Allocation ratio
Details: Details of node
Name: Node name
InitBlock: Block height of application
Guarantee: The address of approver
UpdateBlock: Record the update block
PType: Application type
0 means application
Status:
0: pending
1: success
2: cancel
Example
dpos_getAllProposals
dpos.allProposals()in console.
Get a detailed list of application records for all nodes.
Parameter
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
Contains a detailed list of application records for all nodes.
Example
dpos_getAddressProposals
dpos.addressProposals(address)in console.
Get a list of all application record details for this address.
Parameter
address: Look up the address
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
Contains a list of all application record details for this address.
Example
dpos_getValidator
dpos.validator(validator)in console.
Get details for this node.
Parameter
validator: Look up the address
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
Deposit
Details
Name
Rate
RateSettLockingEndBlock: The block height for next edit
UnstakeLockingEndBlock: The block height of unlock staking
Votes
Status:
0: Defalt Status: Cancelled or not a node
1: Cancellation is under processing, staking has not been redeemed
2: Queueing
3: Node is kicked
4: Node is valid
Example
dpos_getCurrentEpochValidators
dpos.currentEpochValidators()in console.
Get the validators' address list of the latest epoch.
Parameter
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
List of validators' addresses for the latest epoch.
Example
dpos_isEffictiveValidator
dpos.isEffictiveValidator(address)in console.
Check if the node of this address is a validator or not.
Parameter
address
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
If the node of this address is a validator or not.
Example
dpos_effictiveValsLength
dpos.effictiveValsLength()in console.
Get the current number of validators.
Parameter
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
The number of validators.
Example
dpos_getEffictiveValidators
dpos.effictiveValidators()in console.
Get the current list of valid node addresses.
Parameter
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
List of valid node addresses.
Example
dpos_cancelQueueValidatorsLength
dpos.cancelQueueValsLength()in console.
Get the length of the canceled node queue in this epoch.
Parameter
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
Length
Example
dpos_getCancelQueueValidators
dpos.cancelQueueValidators()in console.
Get the list of the canceled node queue in this period.
Parameter
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
List
Example
dpos_validatorVotersLength
dpos.validatorVotersLength(validator)in console.
Get the number of voters of the validating node.
Parameter
validator
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
Number
Example
dpos_getValidatorVoters
dpos.validatorVoters(validator)in console.
Get the list of voter addresses of validators.
Parameter
validator
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
Address list
Example
dpos_pendingValidatorReward
dpos.pendingValidatorReward(validator)in console.
Reward info of nodes
Parameter
validator
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
avaliable: available reward
frozen: frozen reward
Example
dpos_validatorRewardsInfo
dpos.validatorRewardsInfo(validator)in console.
Get the information of reward, redemption ,and lock epoch.
Parameter
validator
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
Epochs: Lock time for the reward
DelegatorsRewards: The corresponding reward allocated to voter in the epoch.
Rates: The corresponding reward allocation.
ValidatorRewards: The corresponding block reward.
FrozenReward: Total reward freezed.
PendingReward: Available Reward
RewardPerVote: The block reward per vote.
Example
dpos_validatorRewardInfoByEpoch
dpos.validatorRewardInfoByEpoch(validator, epoch)in console.
Get the reward distribution information of the node in this epoch: block reward, reward allocated to voters and allocation ratio.
Parameter
validator
epoch
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
DelegatorsReward
Rate
ValidatorReward
Example
dpos_pendingVoteReward
dpos.pendingVoteReward(validator, voter)in console.
Get the reward info of a validator.
Parameter
validator: Address of validator
voter: Address of voter
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
Reward info
Example
dpos_votesRewardRedeemInfo
dpos.votesRewardRedeemInfo(validator, voter)in console.
Get the votes, rewards, and redemption information.
Parameter
validator
voter
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
Amount: Amount of votes
LockRedeemEpochs: The epoch to redeem votes
LockRedeemVotes: Redeemable amount
PendingRedeem: Available amount to redeem
PendingReward: Available assets to collect
ValidatorTotalVotes: Total vote of the validator
Validator: The address of validator
ValidatorName
ValidatorRate
Example
dpos_votesRewardRedeemInfos
dpos.votesRewardRedeemInfos(voter)in console.
Get vote, reward, and redemption information of all voted nodes.
Parameter
voter
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
Vote, reward, and redemption information of all voted nodes.
Example
dpos_getTotalDeposit
dpos.totalDeposit()in console.
Total staking of all valid nodes.
Parameter
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
Total staking amount.
Example
dpos_getTotalVotes
dpos.totalVotes()in console.
The total amount of votings.
Parameter
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
Total votings.
Example
dpos_epochInfo
dpos.epochInfo(epoch)in console.
Get the block rewards, number of validators, total locked values, and number of nodes when the current epoch starts.
Parameter
epoch
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
BlockReward
ValidatorCount
effictiveValCount
TVL: Node staking plus users' votes
Example
dpos_kickoutInfo
dpos.kickoutInfo(epoch)in console.
The address list of kicked nodes in this epoch.
Parameter
epoch
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
The address list
Example
dpos_punishInfo
dpos.punishInfo(validator,epoch)in console.
The details of punished nodes (if any).
Parameter
validator
epoch
blockNum:
null |'latest' | 'earliest' | 'pending' | 'hex number'
Return
Count
PunishBlocks
BurnRewards: The burnt block reward of each kick out
KickoutBlocks
Example
Last updated
Was this helpful?