Klaytn Docs Archive
Getting StartedBuild a dAppNode OperationDeveloper Hub
  • Klaytn Docs
  • -
    • Klaytn Overview
      • Why Klaytn
      • Klaytn Design
        • Consensus Mechanism
        • Accounts
        • Transactions
          • Basic
          • Fee Delegation
          • Partial Fee Delegation
          • Ethereum
        • Computation
          • Klaytn Smart Contract
          • Execution Model
          • Computation Cost
            • Computation Cost (Previous docs)
          • Klaytn Virtual Machine
            • Klaytn Virtual Machine (Previous docs)
        • Storage
          • State Migration
          • StateDB Live Pruning
        • Transaction Fees
          • Transaction Fees (Previous docs)
        • Klaytn native coin - KLAY
        • Token Economy
        • Governance
        • Multi-Channel
        • KNI
      • Scaling Solutions
    • Getting Started
      • Deploying Smart Contract Using Foundry
      • Deploying Smart Contract Using Hardhat
      • Deploying Smart Contract Using Thirdweb
      • Deploying Smart Contract Using KEN
        • Launch an Endpoint Node
        • Top up your Account
        • Install Development Tools
        • Deploy a Smart Contract
        • Check the Deployment
        • Account Management
          • Creating Accounts
          • Managing Accounts
      • Development Environment
      • Getting KLAY
    • Smart Contract
      • Solidity - Smart Contract Language
      • Precompiled Contracts
        • Precompiled Contracts (Previous docs)
      • IDE and Tools
        • Truffle
      • Sample Contracts
        • KlaytnGreeter
        • ERC-20
          • 1. Writing ERC-20 Smart Contract
          • 2. Deploying Smart Contract
          • 3. Interacting with ERC-20 token from Klaytn Wallet
        • ERC-721
          • 1. Writing ERC-721 Smart Contract
          • 2. Deploying Smart Contract
      • Testing Guide
      • Deployment Guide
      • Klaytn Compatible Tokens
      • Porting Ethereum Contract
    • Run a Node
      • Deployment
        • Endpoint Node
          • System Requirements
          • Installation Guide
            • Download
            • Installation Guide
            • Configuration
            • Startup the EN
            • Testing the Installation
          • ken CLI commands
          • JSON-RPC APIs
        • Core Cell
          • System Requirements
          • Network Configuration
          • Installation Guide
            • Download
            • Before You Install
            • Consensus Node Setup
              • Installation Guide
              • Configuration
              • Startup the CN
            • Proxy Node Setup
              • Installation Guide
              • Configuration
              • Startup the PN
            • Testing the Core Cell
          • Monitoring Setup
          • H/A Setup
        • Service Chain
          • Getting Started
            • Setting up a 4-node Service Chain
            • Connecting to Baobab
            • Cross-Chain Value Transfer
            • HA(High Availability) for ServiceChain
            • Nested ServiceChain
            • Value Transfer between Sibling ServiceChains
          • Reference Manuals
            • System Requirements
            • Download
            • SCN User Guide
              • Installation
              • Configuration
              • Starting/Stopping SCN
              • Checking Node Status
              • kscn commands
              • homi commands
            • SPN/SEN User Guide
              • Installation
              • Configuration
              • Starting/Stopping Node
              • Checking Node Status
            • Bridge Configuration
            • Anchoring
            • KAS Anchoring
            • Value Transfer
            • Configuration Files
            • Log Files
            • Genesis JSON
            • Upgrade & Hard Fork
          • How-To Guides
        • Download Node Packages
          • v1.12.0
          • v1.11.1
          • v1.11.0
          • v1.10.2
          • v1.10.1
          • v1.10.0
          • v1.9.1
          • v1.9.0
          • v1.8.4
          • v1.8.3
          • v1.8.2
          • v1.8.1
          • v1.8.0
          • v1.7.3
          • v1.7.2
          • v1.7.1
          • v1.7.0
          • v1.6.4
          • v1.6.3
          • v1.6.2
          • v1.6.1
          • v1.6.0
          • v1.5.3
          • v1.5.2
          • v1.5.1
          • v1.5.0
          • v1.4.2
          • v1.4.1
          • v1.4.0
          • v1.3.0
          • v1.2.0
          • v1.1.1
          • v1.0.0
          • v0.9.6
          • v0.8.2
    • Operation Guide
      • Configuration
      • Node Log
      • Log operation
      • Errors & Troubleshooting
      • Klaytn Command
      • Chaindata Change
      • Chaindata Migration
    • dApp Developers
      • JSON-RPC APIs
        • API references
          • eth
            • Caution
            • Account
            • Block
            • Transaction
            • Config
            • Filter
            • Gas
            • Miscellaneous
          • klay
            • Account
            • Block
            • Transaction
              • Working with Klaytn Transaction Types
            • Configuration
            • Filter
            • Gas
            • Miscellaneous
          • net
          • debug
            • Logging
            • Profiling
            • Runtime Tracing
            • Runtime Debugging
            • VM Tracing
            • VM Standard Tracing
            • Blockchain Inspection
          • admin
          • personal
          • txpool
          • governance
        • Service Chain API references
          • mainbridge
          • subbridge
        • Transaction Error Codes
      • RPC Service Providers
        • Public Endpoints
      • SDK & Libraries for interacting with Klaytn Node
        • caver-js
          • Getting Started
          • Sending a sample transaction
          • API references
            • caver.account
            • caver.wallet
              • caver.wallet.keyring
            • caver.transaction
              • Basic
              • Fee Delegation
              • Partial Fee Delegation
            • caver.rpc
              • caver.rpc.klay
              • caver.rpc.net
              • caver.rpc.governance
            • caver.contract
            • caver.abi
            • caver.kct
              • caver.kct.kip7
              • caver.kct.kip17
              • caver.kct.kip37
            • caver.validator
            • caver.utils
            • caver.ipfs
          • caver-js ~v1.4.1
            • Getting Started (~v1.4.1)
            • API references
              • caver.klay
                • Account
                • Block
                • Transaction
                  • Legacy
                  • Value Transfer
                  • Value Transfer Memo
                  • Account Update
                  • Smart Contract Deploy
                  • Smart Contract Execution
                  • Cancel
                • Configuration
                • Filter
                • Miscellaneous
              • caver.klay.net
              • caver.klay.accounts
              • caver.klay.Contract
              • caver.klay.KIP7
              • caver.klay.KIP17
              • caver.klay.abi
              • caver.utils (~v1.4.1)
            • Porting from web3.js
        • caver-java
          • Getting Started
          • API references
          • caver-java ~v1.4.0
            • Getting Started (~v1.4.0)
            • Porting from web3j
        • ethers.js
        • web3.js
      • Tutorials
        • Klaytn Online Toolkit
        • Fee Delegation Example
        • Count DApp
          • 1. Environment Setup
          • 2. Clone Count DApp
          • 3. Directory Structure
          • 4. Write Smart Contract
          • 5. Frontend Code Overview
            • 5-1. Blocknumber Component
            • 5-2. Auth Component
            • 5-3. Count Component
          • 6. Deploy Contract
          • 7. Run App
        • Klaystagram
          • 1. Environment Setup
          • 2. Clone Klaystagram DApp
          • 3. Directory Structure
          • 4. Write Klaystagram Smart Contract
          • 5. Deploy Contract
          • 6. Frontend Code Overview
          • 7. FeedPage
            • 7-1. Connect Contract to Frontend
            • 7-2. UploadPhoto Component
            • 7-3. Feed Component
            • 7-4. TransferOwnership Component
          • 8. Run App
        • Building a Buy Me a Coffee dApp
          • 1. Project Setup
          • 2. Creating a BMC Smart Contract
          • 3. Testing the contract using scripts
          • 4. Deploying BMC Smart contract
          • 5. Building the BMC Frontend with React and Web3Onboard
          • 6. Deploying Frontend code on IPFS using Fleek
          • 7. Conclusion
        • Migrating Ethereum App to Klaytn
        • Connecting MetaMask
        • Connecting Remix
        • Verifying Smart Contracts Using Block Explorers
      • Developer Tools
        • Wallets
          • Kaikas
          • Klaytn Wallet
          • Klaytn Safe
            • Klaytn Safe Design
            • Create a Safe
            • Add assets
            • Send assets
            • Contract Interaction
            • Transaction Builder
            • Points to Note
            • Frequently Asked Questions
          • SafePal S1
          • Wallet Libraries
            • Web3Auth
            • Web3Modal
            • Web3-Onboard
            • Particle Network
        • Oracles
          • Orakl Network
          • Witnet
          • SupraOracles
        • Indexers
          • SubQuery
        • Cross-chain
          • LayerZero
        • Block Explorers
          • Klaytnscope
          • Klaytnfinder
        • Klaytn Contracts Wizard
    • Glossary
  • ---
    • Klaytn Hard Fork History
    • Klaytn 2.0
      • Metaverse Package
      • Finality and Improvements
      • Ethereum Compatibility
      • Decentralizing Governance
      • Massive Eco Fund
    • FAQ
    • Open Source
    • Terms of Use
    • Languages
  • ℹ️Latest Klaytn Docs
Powered by GitBook
On this page
  • caver.rpc.governance.vote
  • caver.rpc.governance.showTally
  • caver.rpc.governance.getTotalVotingPower
  • caver.rpc.governance.getMyVotingPower
  • caver.rpc.governance.getMyVotes
  • caver.rpc.governance.getChainConfig
  • caver.rpc.governance.getNodeAddress
  • caver.rpc.governance.getItemsAt
  • caver.rpc.governance.getPendingChanges
  • caver.rpc.governance.getIdxCache
  • caver.rpc.governance.getIdxCacheFromDb
  • caver.rpc.governance.getItemCacheFromDb
  • caver.rpc.governance.getVotes
  • caver.rpc.governance.getStakingInfo
  1. -
  2. dApp Developers
  3. SDK & Libraries for interacting with Klaytn Node
  4. caver-js
  5. API references
  6. caver.rpc

caver.rpc.governance

Previouscaver.rpc.netNextcaver.contract

Last updated 2 years ago

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 | boolean

Various types of value for each key.

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 .

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

caver.rpc.governance.getItemsAt

caver.rpc.governance.getItemsAt([blockNumberOrTag] [, callback])

Returns governance items at a specific block. It is the result of previous voting of the block and used as configuration for chain at the given block number.

Parameters

Name
Type
Description

blockNumberOrTag

number | string

(optional) A block number, or the string latest or earliest. If omitted, latest will be used.

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 governance items.

Example

> caver.rpc.governance.getItemsAt().then(console.log)
{
  'governance.governancemode': 'ballot',
  'governance.governingnode': '0xbeafcca672100a88a953fcf5e882cb763f9e3de9',
  'governance.unitprice': 25000000000,
  'istanbul.committeesize': 22,
  'istanbul.epoch': 30,
  'istanbul.policy': 2,
  'kip71.basefeedenominator': 20,
  'kip71.gastarget': 30000000,
  'kip71.lowerboundbasefee': 25000000000,
  'kip71.maxblockgasusedforbasefee': 60000000,
  'kip71.upperboundbasefee': 750000000000,
  'reward.deferredtxfee': true,
  'reward.minimumstake': '5000000',
  'reward.mintingamount': '6400000000000000000',
  'reward.proposerupdateinterval': 30,
  'reward.ratio': '50/40/10',
  'reward.stakingupdateinterval': 60,
  'reward.useginicoeff': true
}

> caver.rpc.governance.getItemsAt('latest').then(console.log)

caver.rpc.governance.getPendingChanges

caver.rpc.governance.getPendingChanges([callback])

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

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

Currently pending changes composed of keys and values.

Example

> caver.rpc.governance.getPendingChanges().then(console.log)
{ 'governance.governancemode': 'single' }

caver.rpc.governance.getIdxCache

caver.rpc.governance.getIdxCache([callback])

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

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

Array

Block numbers where governance change happened.

Example

> caver.rpc.governance.getIdxCache().then(console.log)
[ 0, 60, 321180 ]

caver.rpc.governance.getIdxCacheFromDb

caver.rpc.governance.getIdxCacheFromDb([callback])

Returns an array that contains all block numbers at which any governance changes ever took place. The result of idxCacheFromDb is the same or longer than that of idxCache.

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

Array

Block numbers where governance change happened.

Example

> caver.rpc.governance.getIdxCacheFromDb().then(console.log)
[ 0, 60, 321180 ]

caver.rpc.governance.getItemCacheFromDb

caver.rpc.governance.getItemCacheFromDb([callback])

Returns the governance information stored on the given block. If no changes are stored on the given block, the function returns null.

Parameters

Name
Type
Description

callback

function

(optional) Optional callback, which returns an error object as the first parameter and the result as the second.

Parameters

Name
Type
Description

blockNumber

number | string

A block number, or the hex number string to query the governance change made on the block.

Return Value

Promise returns object

Type
Description

object

Stored governance information at a given block.

Example

> caver.rpc.governance.getItemCacheFromDb(540).then(console.log)
{
  'governance.governancemode': 'single',
  'governance.governingnode': '0xbeafcca672100a88a953fcf5e882cb763f9e3de9',
  'governance.unitprice': 25000000000,
  'istanbul.committeesize': 22,
  'istanbul.epoch': 30,
  'istanbul.policy': 2,
  'kip71.basefeedenominator': 30,
  'kip71.gastarget': 30000000,
  'kip71.lowerboundbasefee': 25000000000,
  'kip71.maxblockgasusedforbasefee': 60000000,
  'kip71.upperboundbasefee': 750000000000,
  'reward.deferredtxfee': true,
  'reward.minimumstake': '5000000',
  'reward.mintingamount': '6400000000000000000',
  'reward.proposerupdateinterval': 30,
  'reward.ratio': '50/40/10',
  'reward.stakingupdateinterval': 60,
  'reward.useginicoeff': true
}

> caver.rpc.governance.getItemCacheFromDb(1).then(console.log)
null

caver.rpc.governance.getVotes

caver.rpc.governance.getVotes([callback])

Returns the votes from all nodes in the epoch. These votes are gathered from the header of each block.

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

Array

Current votes composed of keys, values and node addresses.

Example

> caver.rpc.governance.getVotes().then(console.log)
[{
    key: 'reward.minimumstake',
    validator: '0xe733cb4d279da696f30d470f8c04decb54fcb0d2',
    value: '5000000'
}, {
    key: 'reward.useginicoeff',
    validator: '0xa5bccb4d279419abe2d470f8c04dec0789ac2d54',
    value: false
}]

caver.rpc.governance.getStakingInfo

caver.rpc.governance.getStakingInfo([blockNumberOrTag] [, callback])

Returns the staking information at a specific block.

Parameters

Name
Type
Description

blockNumberOrTag

number | string

(optional) A block number, or the string latest or earliest. If omitted, latest will be used.

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

Example

> caver.rpc.governance.getStakingInfo().then(console.log)
{
  BlockNum: 321600,
  CouncilNodeAddrs: [],
  CouncilStakingAddrs: [],
  CouncilRewardAddrs: [],
  KIRAddr: '0x0000000000000000000000000000000000000000',
  PoCAddr: '0x0000000000000000000000000000000000000000',
  UseGini: false,
  Gini: -1,
  CouncilStakingAmounts: []
}

Staking information. Refer to for a description of the return result.

governance_vote
governance_getStakingInfo