Stake with OKC CLI (Command-Line Interface)

OKT Chain
OKT Chain
Published in
8 min readOct 18, 2022

With the OKC mainnet upgrade (v1.6.3) on 17th October 2022, we have added OKC staking feature. This guide contains all the necessary information for validators and delegators to stake with the OKC through the Command-Line Interface (CLI).

What is staking?

Staking is the unique consensus mechanism of PoS(proof-of-stake). In PoS consensus, nodes are responsible for wrapping trade information, maintaining network operations, and participating in community governance. Nodes can receive an issued token as a reward for staking.

OKC uses Tendermint’s (BFT-DPoS) consensus algorithm, anyone that pledges 10,000 OKT can operate a full node to become a registered validator. After every epoch cycle (252 blocks), OKC will calculate the weight of every validator, and the Top 21 weighted nodes will become the next epoch cycle’s block producers that participate in consensus, while the others become alternative nodes. Under Tendermint’s consensus algorithm, these 21 nodes will vote to produce the new block.

OKT is OKC’s only native equity token; Staking on OKC essentially means locking OKT to help maintain OKC’s network. Participation in Staking does not necessarily require OKT to be transferred to the validator node account, but requires only that one’s voting rights are delegated to the validator node (delegation), thus obtaining OKT rewards through staking and voting. Similar to most other public blockchain networks, the reward includes a block producer’s reward and transaction fees. In short, users can stake OKT and vote for a validator, and after the validator receives their rewards, the rest is distributed to the users based first on a default ratio and then on the weight of votes.

OKC staking rules

1. Staking rewards generation

As previously mentioned, OKC’s staking rewards are based on block rewards and transaction fees. OKT’s issuing mechanism is similar to that of BTC, which takes a fixed total amount and periodically reduces tokens. OKT has a total of 41,690,000 OKT in circulation, including 10,000,000 OKT allocated by Genesis Mining; each new block corresponds to a 0.5 OKT reward, and the reward is halved every 3 years.

Below is a specific explanation of the distribution rules for block rewarding:

  • X% represents the community distribution rate (currently at 0%). Y% represents the commission rate of every validator node (defaulted at 100%). After the update goes live, validators can adjust this according to their own needs.
  • Block rewards = block producers reward + the total amount of all block’s transaction fees
  • In one epoch cycle:

(1-x%) of block reward * 25% averaged and distributed to 21 producer nodes (validators)

(1-x%) of block reward * 75% of vote shares distributed to 21 producer nodes (validators) and candidate nodes (candidate validators)

X% of block reward + surplus of distributed balance (mentioned above), then all poured into the community fund pool

  • As a reward to users, the validator node will distribute (1-y%) of their earnings to users according to the proportions of users’ votes.

2. Exchange and multiple voting

After staking OKT (minimum of 0.0001 OKT per stake), users can opt to exchange their voting rights for the validator node. It’s worth mentioning that OKC uses a multi-voting system, where users can vote for up to 30 validator nodes after completing their stakes (each node can only be voted for once). Furthermore, when users want to stake OKT again, they will not need to go through the voting process again, but will vote for their previous validator node by default.

3. Staking rewards calculator

Since the voting shares of the validator on the chain will not experience constant fluctuation, hence the period concept was put in place to calculate dividends.

  • The validator node’s voting shares will not change during a period.
  • Only when the user’s actions change the share of voting nodes of the validator, the current period ends, and a new period begins.
  • With the period concept, calculating the user’s earnings only requires determining the sum of earnings the user accumulated during the user’s start and end period.

The rationale for calculating user earnings is to track a single share over consecutive periods, in other words, the Cumulative Reward Ratio.

According to users, if their shares don’t change within these periods, they can calculate their earnings: user earnings = Cumulative Reward Ratio * Shares

Below is delegator A’s process of staking, voting, revoking stake and explanation of dividend rewards.

  • Delegator A votes at the end of m-4 period, resulting in the start of m-3 period.
  • Delegator B votes at the end of m-3 period, resulting in the start of m-2 period.
  • Delegator A votes at the end of m-2 period, resulting in the start of m-1 period.
  • Delegator A revokes vote, activates dividends, total dividend is the sum of earnings accumulated between m-4 and m-2

(0.12OKT — 0 OKT) * 50 shares = 6 OKT

  • Simple interest is calculated individually for every period

4. Withdrawing rewards

Users who have accumulated a certain amount of earnings can claim their earnings into their wallets in two ways: active withdrawal and passive withdrawal.

  • Active withdrawal: the user initiates an on-chain claim transaction, receiving rewards from a single validator node.
  • Passive withdrawal: after the user has voted and attempts to stake or vote again, a change in number of votes triggers withdrawal of rewards (only the user’s own actions can trigger this).

However, due to a truncation precision issue with claiming rewards-if the reward amount contains decimals-the user will receive the amount up to the tenth decimal place (0.1), while everything from the hundredths place (0.01..) and on will be distributed to the community pool. For example, if the user has 1.55 OKT from V_1 node, 0.39 OKT from V_2 node and 24.305 OKT from V_3 node, the amount claimed and distributed to the community pool would look like this:

  • Amount claimed by user:1.5 + 0.3 + 24.3 = 26.1 OKT
  • Amount distributed to pool:0.05 + 0.09 + 0.005 = 0.145 OKT

Truncation precision can be adjusted through community proposal governance. The current truncation precision setting can be viewed on the command line.

exchaincli query distr params

5. Unstaking cycle

The unstaking commands displayed below show users how to apply for staked OKT retrieval. Unstaking requires a 14 day token locking period. During this time, locked OKT will not receive staking rewards, and users cannot conduct any other actions. If users apply for OKT retrieval multiple times during the 14 day lock period, all applications will be converged into one, and the lockdown period countdown will reset starting from the most recent application.

The minimum amount of OKT required for every unstake: 0.0001 OKT.

Staking commands

1. Deposit

Description:

The user deposits OKT to the delegator account, which is the first step to increasing shares.

If the user has voted before, the vote will default to vote for the previous validator node the user voted for and trigger a passive claim.

Command:

exchaincli tx staking deposit [amount] [flags]

Parameters:

Example:

exchaincli tx staking deposit 100okt --from ex1j5mr2jhr9pf20e7yhln5zkcsgqtdt7cydr8x3y --gas auto --gas-prices 0.0000000001okt --gas-adjustment 1.3 -y --node https://exchaintmrpc.okex.org

2. Delegator staking info

Description:
View delegator’s info, e.g., number of votes, validator nodes, unstake.

Command:

exchaincli query staking delegator [address] [flags]

Parameters:

Example:

exchaincli query staking delegator ex1j5mr2jhr9pf20e7yhln5zkcsgqtdt7cydr8x3y --node https://exchaintmrpc.okex.org

3. Voting (add-shares)

Description:
Users obtain shares with their deposits and vote for one or more validator nodes. If users have voted before, this action will trigger a passive claim.

Command:

exchaincli tx staking add-shares [validator-addr1, validator-addr2, validator-addr3, ... validator-addrN] [flags]

Parameters:

Example:

exchaincli tx staking add-shares exvaloper1pt7xrmxul7sx54ml44lvv403r06clrdkehd8z7 --from ex1j5mr2jhr9pf20e7yhln5zkcsgqtdt7cydr8x3y --gas auto --gas-prices 0.0000000001okt --gas-adjustment 1.3 -y --node https://exchaintmrpc.okex.org

4. Validator node list

Description:
View all validator nodes info.

Command:

exchaincli query staking validators [flags]

Example:

exchaincli query staking validators --node https://exchaintmrpc.okex.org

5. Rewards

Description:
View the corresponding dividends of a designated validator or any validator that voted.

Command:

exchaincli query distr rewards [delegator-addr] [<validator-addr>] [flags]

Parameters:

Example:

# View designated validators reward
exchaincli query distr rewards ex1j5mr2jhr9pf20e7yhln5zkcsgqtdt7cydr8x3y exvaloper1pt7xrmxul7sx54ml44lvv403r06clrdkehd8z7 --node https://exchaintmrpc.okex.org
# View all validators rewards
exchaincli query distr rewards ex1j5mr2jhr9pf20e7yhln5zkcsgqtdt7cydr8x3y --node https://exchaintmrpc.okex.org

6. Withdraw (claim) all rewards

Description:
Claim dividends from all validator nodes that voted.

Command:

exchaincli tx distr withdraw-all-rewards [flags]

Example:

exchaincli tx distr withdraw-all-rewards --from ex17kn7d20d85yymu45h79dqs5pxq9m3nyx2mdmcs --gas auto --gas-prices 0.0000000001okt --gas-adjustment 1.3 -y  --node https://exchaintmrpc.okex.org --node https://exchaintmrpc.okex.org

7. Withdraw OKT

Description:
Withdraw deposited OKT assets and revoke vote for validator node. This transaction will trigger dividend withdrawal (active claim).

Command:

exchaincli tx staking withdraw [amount] [flags]

Example:

exchaincli tx staking withdraw 300000okt --from ex153z8qwxkqa5p2samfn8z50kr9pt8j6afs0am6e --gas auto --gas-prices 0.0000000001okt --gas-adjustment 1.3 -y --node https://exchaintmrpc.okex.org

8. Dividend module parameters

Description:
View dividend module parameters.

Command:

exchaincli query distr params [flags]

Example:

exchaincli query distr params --node https://exchaintmrpc.okex.org

About OKC

OKC (OKX Chain) is an EVM-compatible L1 built on Cosmos with a focus on true interoperability (IBC) and maximized performance. At high scalability, developers can build and scale with low gas fees. The OKC ecosystem and infrastructure, including the all-in-one multi-chain Web3 interface, enables a seamless experience for both developers and users.

How to find us?

Website | Twitter |LinkedIn| Discord| Telegram |DevCommunity |Submit Your Project

--

--

OKT Chain
OKT Chain

OKT Chain is an EVM and Wasm compatible L1 built on Cosmos with a focus on true interoperability and maximized performance.