caver.rpc.governance
caver.rpc.governance
provides JSON-RPC call with the governance
name space.
caver.rpc.governance.vote
caver.rpc.governance.vote(key, value [, callback])
Submits a new vote. If the node has the right to vote based on the governance mode, the vote can be submitted. If not, an error will occur and the vote will be ignored.
Parameters
Name | Type | Description |
---|---|---|
key | string | Name of the configuration setting to be changed. Key has the form "domain.field". |
value | string \ | number \ |
callback | function | (optional) Optional callback, which returns an error object as the first parameter and the result as the second. |
For more details about the key
and value
for caver.rpc.governance.vote
, please refer to governance_vote.
Return Value
Promise
returns string
Type | Description |
---|---|
string | Result of vote submission. |
Example
> caver.rpc.governance.vote('governance.governancemode', 'ballot').then(console.log)Your vote was successfully placed.
caver.rpc.governance.showTally
caver.rpc.governance.showTally([callback])
Provides the current tally of governance votes. It shows the aggregate approval rate in percentage. The suggested change shall pass when the rate is over 50%.
Parameters
Name | Type | Description |
---|---|---|
callback | function | (optional) Optional callback, which returns an error object as the first parameter and the result as the second. |
Return Value
Promise
returns Array
Type | Description |
---|---|
Array | An array containing the vote's value and the approval rate in percentage. |
Example
> caver.rpc.governance.showTally().then(console.log)[ { Key: 'governance.unitprice', Value: 25000000000, ApprovalPercentage: 33.33333333333333 }]
caver.rpc.governance.getTotalVotingPower
caver.rpc.governance.getTotalVotingPower([callback])
Provides the sum of all voting power that CNs have. Each CN has 1.0 ~ 2.0 voting power. In the "none" and "single" governance modes, totalVotingPower doesn't provide any information.
Parameters
Name | Type | Description |
---|---|---|
callback | function | (optional) Optional callback, which returns an error object as the first parameter and the result as the second. |
Return Value
Promise
returns number
Type | Description |
---|---|
number | Total Voting Power. |
Example
> caver.rpc.governance.getTotalVotingPower().then(console.log)3
caver.rpc.governance.getMyVotingPower
caver.rpc.governance.getMyVotingPower([callback])
Provides the voting power of the node. The voting power can be anywhere between 1.0 ~ 2.0. In the "none" and "single" governance modes, totalVotingPower doesn't provide any information.
Parameters
Name | Type | Description |
---|---|---|
callback | function | (optional) Optional callback, which returns an error object as the first parameter and the result as the second. |
Return Value
Promise
returns number
Type | Description |
---|---|
number | Node's Voting Power. |
Example
> caver.rpc.governance.getMyVotingPower().then(console.log)1
caver.rpc.governance.getMyVotes
caver.rpc.governance.getMyVotes([callback])
Provides my vote information in the epoch. Each vote is stored in a block when the user's node generates a new block. After current epoch ends, this information is cleared.
Parameters
Name | Type | Description |
---|---|---|
callback | function | (optional) Optional callback, which returns an error object as the first parameter and the result as the second. |
Return Value
Promise
returns Array
Type | Description |
---|---|
Array | Node's Voting status in the epoch. |
Example
> caver.rpc.governance.getMyVotes().then(console.log)[ { Key: 'governance.unitprice', Value: 25000000000, Casted: true, BlockNum: 76899 }]
caver.rpc.governance.getChainConfig
caver.rpc.governance.getChainConfig([callback])
Provides the initial chain configuration. Because it just stores the initial configuration, if there were changes in the governance made by voting, the result of chainConfig will differ from the current states. To see the current information, please use itemsAt.
Parameters
Name | Type | Description |
---|---|---|
callback | function | (optional) Optional callback, which returns an error object as the first parameter and the result as the second. |
Return Value
Promise
returns object
Type | Description |
---|---|
object | The initial chain configuration |
Example
> caver.rpc.governance.getChainConfig().then(console.log){ chainId: 10000, istanbul: { epoch: 30, policy: 2, sub: 22 }, unitPrice: 25000000000, deriveShaImpl: 2, governance: { governingNode: '0xbeafcca672100a88a953fcf5e882cb763f9e3de9', governanceMode: 'single', reward: { mintingAmount: 6400000000000000000, ratio: '50/40/10', useGiniCoeff: true, deferredTxFee: true, stakingUpdateInterval: 60, proposerUpdateInterval: 30, minimumStake: 5000000 }, kip71: { lowerboundbasefee: 25000000000, upperboundbasefee: 750000000000, gastarget: 30000000, maxblockgasusedforbasefee: 60000000, basefeedenominator: 20 } }}
caver.rpc.governance.getNodeAddress
caver.rpc.governance.getNodeAddress([callback])
Provides the address of the node that a user is using. It is derived from the nodekey and used to sign consensus messages. And the value of "governingnode" has to be one of validator's node address.
Parameters
Name | Type | Description |
---|---|---|
callback | function | (optional) Optional callback, which returns an error object as the first parameter and the result as the second. |
Return Value
Promise
returns string
Type | Description |
---|---|
string | The address of a node. |
Example
> caver.rpc.governance.getNodeAddress().then(console.log)0xbeafcca672100a88a953fcf5e882cb763f9e3de9