For the governance of the network, Klaytn provides the following APIs under governance
namespace.
In Klaytn, there are three different governance modes.
none
: All nodes participating in the network have the right to change the configuration.
single
: Only one designated node has the right to change the configuration.
ballot
: All nodes which have voting power can vote for a change. When more than half of total voting power gathered, the vote passes.
The vote
method submits a new vote. If the node has the right to vote based on governance mode, the vote can be placed. If not, an error message will be returned and the vote will be ignored.
Parameters
Key
: Name of the configuration setting to be changed. Key has the form of domain.field
Value
: Various types of value for each key.
Key | Description |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Return Value
Type | Description |
String | Result of vote submission |
Example
> governance.vote ("governance.governancemode", "ballot")"Your vote was successfully placed."​> governance.vote ("governance.governingnode", "0x12345678990123456789901234567899012345678990")"Your vote was successfully placed."​> governance.vote("istanbul.epoch", 604800)"Your vote was successfully placed."​> governance.vote("governance.unitprice", 25000000000)"Your vote was successfully placed."​> governance.vote("istanbul.committeesize", 7)"Your vote was successfully placed."​> governance.vote("reward.mintingamount", "9600000000000000000")"Your vote was successfully placed."​> governance.vote("reward.ratio", "40/30/30")"Your vote was successfully placed."​> governance.vote("reward.useginicoeff", false)"Your vote was successfully placed."​// If wrong data are given> governance.vote("reward.ratio", 100)"Your vote couldn't be placed. Please check your vote's key and value"​> governance.vote("governance.governingnode", 1234)"Your vote couldn't be placed. Please check your vote's key and value"​// when `governancemode` is "single" and the node is not `governingnode`> governance.vote("governance.governancemode", "ballot")"You don't have the right to vote"
The showTally
property provides the current tally of governance votes. It shows the aggregated approval rate in percentage. When it goes over 50%, the vote passes.
Parameters
None
Return Value
Type | Description |
Tally | Each vote's value and approval rate in percentage |
Example
> governance.showTally[{ApprovalPercentage: 36.2,Key: "unitprice",Value: 25000000000}, {ApprovalPercentage: 72.5,Key: "mintingamount",Value: "9600000000000000000"}]
The totalVotingPower
property provides the sum of all voting power that CNs have. Each CN has 1.0 ~ 2.0 voting power. In "none"
, "single"
governance mode, totalVotingPower
don't provide any information.
Parameters
None
Return Value
Type | Description |
Float | Total Voting Power or error message |
Example
// In "ballot" governance mode> governance.totalVotingPower32.452​// In "none", "single" governance mode> governance.totalVotingPower"In current governance mode, voting power is not available"
The myVotingPower
property provides the voting power of the node. The voting power can be 1.0 ~ 2.0. In "none"
, "single"
governance mode, totalVotingPower
don't provide any information.
Parameters
None
Return Value
Type | Description |
Float | Node's Voting Power or error message |
Example
// In "ballot" governance mode> governance.myVotingPower1.323​// In "none", "single" governance mode> governance.myVotingPower"In current governance mode, voting power is not available"
The myVotes
property 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
None
Return Value
Type | Description |
Vote List | Node's Voting status in the epoch
- |
Example
> governance.vote("governance.governancemode", "ballot")"Your vote was successfully placed."​> governance.myVotes[{BlockNum: 403,Casted: true,Key: "governance.governancemode",Value: "ballot"}]
The chainConfig
property 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
None
Return Value
Type | Description |
JSON | Current chain configuration |
Example
> governance.chainConfig{chainId: 1001,deriveShaImpl: 2,governance: {governanceMode: "ballot",governingNode: "0xe733cb4d279da696f30d470f8c04decb54fcb0d2",reward: {deferredTxFee: true,minimumStake: 5000000,mintingAmount: 9600000000000000000,proposerUpdateInterval: 3600,ratio: "34/54/12",stakingUpdateInterval: 20,useGiniCoeff: false}},istanbul: {epoch: 20,policy: 2,sub: 1},unitPrice: 25000000000}
The nodeAddress
property 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
None
Return Value
Type | Description |
ADDRESS | 20 BYTE address of a node |
Example
> governance.nodeAddress"0xe733cb4d279da696f30d470f8c04decb54fcb0d2"
The itemsAt
returns governance items at specific block. It is the result of previous voting of the block and used as configuration for chain at the given block number.
Parameters
Type | Description |
QUANTITY | TAG | Integer block number, or the string |
Return Value
Type | Description |
JSON | governance items |
Example
> governance.itemsAt(89){governance.governancemode: "single",governance.governingnode: "0x7bf29f69b3a120dae17bca6cf344cf23f2daf208",governance.unitprice: 25000000000,istanbul.committeesize: 13,istanbul.epoch: 30,istanbul.policy: 2,reward.deferredtxfee: true,reward.minimumstake: "5000000",reward.mintingamount: "9600000000000000000",reward.proposerupdateinterval: 30,reward.ratio: "34/54/12",reward.stakingupdateinterval: 60,reward.useginicoeff: true}
The pendingChanges
returns the list of items that have received enough number of votes but not yet finalized. At the end of the current epoch, these changes will be finalized and the result will be in effect from the epoch after next epoch.
Parameters
None
Return Value
Type | Description |
Vote List | Currently pending changes composed of keys and values |
Example
> governance.pendingChanges{reward.minimumstake: "5000000",reward.useginicoeff: false}
The votes
returns the votes from all nodes in the epoch. These votes are gathered from the header of each block.
Parameters
None
Return Value
Type | Description |
Vote List | Current votes composed of keys, values and node addresses |
Example
> governance.votes[{key: "reward.minimumstake",validator: "0xe733cb4d279da696f30d470f8c04decb54fcb0d2",value: "5000000"}, {key: "reward.useginicoeff",validator: "0xa5bccb4d279419abe2d470f8c04dec0789ac2d54",value: false}]
The idxCache
property returns an array of current idxCache in the memory cache. idxCache contains the block numbers where governance change happened. The cache can have up to 1000 block numbers in memory by default.
Parameters
None
Return Value
Type | Description |
uint64 array | Block numbers where governance change happened |
Example
> governance.idxCache[0, 30]
The idxCacheFromDb
returns an array that contains all block numbers on which a governance change ever happened. The result of idxCacheFromDb
is the same or longer than that of idxCache
Parameters
None
Return Value
Type | Description |
uint64 array | Every block numbers where governance change happened |
Example
> governance.idxCacheFromDb[0, 30]
The itemCacheFromDb
returns the governance information stored in the given block. If no changes were stored in the given block, the function returns null
.
Parameters
Type | Description |
uint64 | A block number to query the governance change made in the block. |
Return Value
Type | Description |
JSON | Stored governance information at a given block |
Example
> governance.itemCacheFromDb(0){governance.governancemode: "single",governance.governingnode: "0xe733cb4d279da696f30d470f8c04decb54fcb0d2",governance.unitprice: 25000000000,istanbul.committeesize: 1,istanbul.epoch: 30,istanbul.policy: 2,reward.deferredtxfee: true,reward.minimumstake: "5000000",reward.mintingamount: "9600000000000000000",reward.proposerupdateinterval: 3600,reward.ratio: "34/54/12",reward.stakingupdateinterval: 20,reward.useginicoeff: false}