本文主要介绍如何使用命令行(CLI)完成 OKC 的质押挖矿。
什么是质押挖矿
OKC 采用 Tendermint (BFT-DPoS) 共识算法。用户可借助 CLI 工具质押 OKT 获得投票权,并能投票给愿意分成的验证者(Validator)节点,获取链上分红收益,以此实现 OKT 质押挖矿。
普通用户如何进行挖矿
- 质押 OKT,获得投票权
- 选择验证者进行投票,若此验证者设置了分成比例,即可获得链上分红收益
注:如果用户一周内没有参与投票,那么他们的投票权重就会开始衰减,每52周(1年)投票权重衰减一倍。重新投票(或质押、赎回质押、提取分红)后,会刷新选票权重。参考投票权重衰减机制
质押
// Deposit an amount of OKT to the delegator account.
// Deposited OKT in the delegator account is a prerequisite for adding shares. If add-shares is set before, this deposit will reuse the existing add-shares settings with the validators, respectively, and trigger a passive reward, which will automatically distribute the rewards to its own account (or reward withdraw account).
// e.g., <amountToDeposit>=1024okt, <gasPrice>=0.00000001 okt
exchaincli tx staking deposit <amountToDeposit> --from <delegatorKeyName> --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice>
// Query all information on delegations and all shares recently added by a delegator.
// e.g., <delegatorAddress>=ex1c8w3jcfagaw8s2je3kk2dqftmyypzv3mrv4tcd
exchaincli query staking delegator <delegatorAddress>
投票
// Add shares to one or more validators with all deposited OKT.
// Note: If shares are added multiple times, only the last setting will be used. If add-shares is set before, this operation will trigger a passive reward, which will automatically distribute the rewards to its own account (or reward withdraw account).
exchaincli tx staking add-shares <validator-addr1, validator-addr2, validator-addr3, ... validator-addrN> --from <delegatorKeyName> --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice>
// Query all information on delegations and all shares recently added by a delegator.
// e.g., <delegatorAddress>=ex1c8w3jcfagaw8s2je3kk2dqftmyypzv3mrv4tcd
exchaincli query staking delegator <delegatorAddress>
普通用户常用命令操作
普通用户可通过下述命令进行质押和投票,并获得质押挖矿分红奖励。
注:每种命令都可以使用-h or --help 获取更多帮助信息。
质押 OKT
// Deposit an amount of OKT to the delegator account.
// Deposited OKT in the delegator account is a prerequisite for adding shares. If add-shares is set before, this deposit will reuse the existing add-shares settings with the validators, respectively, and trigger a passive reward, which will automatically distribute the rewards to its own account (or reward withdraw account).
// e.g., <amountToDeposit>=1024okt, <gasPrice>=0.00000001 okt
exchaincli tx staking deposit <amountToDeposit> --from <delegatorKeyName> --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice>
// Query all information on delegations and all shares recently added by a delegator.
// e.g., <delegatorAddress>=ex1c8w3jcfagaw8s2je3kk2dqftmyypzv3mrv4tcd
exchaincli query staking delegator <delegatorAddress>
投票
// Add shares to one or more validators with all deposited OKT.
// Note: If shares are added multiple times, only the last setting will be used. If add-shares is set before, this operation will trigger a passive reward, which will automatically distribute the rewards to its own account (or reward withdraw account).
exchaincli tx staking add-shares <validator-addr1, validator-addr2, validator-addr3, ... validator-addrN> --from <delegatorKeyName> --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice>
// Query all information on delegations and all shares recently added by a delegator.
// e.g., <delegatorAddress>=ex1c8w3jcfagaw8s2je3kk2dqftmyypzv3mrv4tcd
exchaincli query staking delegator <delegatorAddress>
赎回 OKT
// Withdraw an amount of OKT and the corresponding shares from all validators.
// You will have to wait 14 days before your OKTs are fully unlocked and transferrable. This will also trigger a passive reward, which will automatically distribute the rewards to its own account (or reward withdraw account)
// e.g., <amountToWithdraw>=1024okt, <gasPrice>=0.00000001 okt
exchaincli tx staking withdraw <amountToWithdraw> --from <delegatorKeyName> --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice>
查询质押信息
// Query all information of delegations and all shares recently added by a delegator.
// e.g., <delegatorAddress>=ex1c8w3jcfagaw8s2je3kk2dqftmyypzv3mrv4tcd
exchaincli query staking delegator <delegatorAddress>
查询质押分红奖励
// Query all rewards earned by a delegator, optionally restrict to rewards from a single validator.
// e.g., <delegatorAddr>=ex1ja9xngm4zh0t442mse73ll30p7dczd49xqdhwu, [validatorAddr]=exvaloper1xkl5agjzqnjnptyat2dng2asmx8g5kllg7xamv
exchaincli query distr rewards <delegatorAddr> [validatorAddr]
取出单个验证者质押分红
// Withdraw rewards from a given validator address.
// e.g., <validatorAddr>=exvaloper1xkl5agjzqnjnptyat2dng2asmx8g5kllg7xamv
exchaincli tx distr withdraw-rewards <validatorAddr> --from <delegatorKeyName> --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice>
取出所有验证者质押分红
// Withdraw all delegations rewards for a delegator.
exchaincli tx distr withdraw-all-rewards --from <delegatorKeyName> --gas auto --gas-adjustment 1.5 --gas-prices <gasPrice>
验证者常用命令操作
验证者可通过下述命令进行设置抽成比例、取出抽成奖励等操作。
注:每种命令都可以使用-h or --help
获取更多帮助信息。
设置验证者抽成比例
// Update an existing validator commission rate, ranging [0,1]. It can only be edited by the validator once every 24 hours.
//Default value is 1 (100%), i.e., no distribution rewards to users. If the value is set at 0.2 (20%), 80% will be allocated to users according to the voting ratio.
// e.g., <commission-rate>=0.2
exchaincli tx staking edit-validator-commission-rate <commission-rate> [flags]
查询验证者抽成比例
// Query the information of a validator with the given address.
// e.g., <validatorAddr>=exvaloper1xkl5agjzqnjnptyat2dng2asmx8g5kllg7xamv
exchaincli query staking validator <validatorAddress>
查询验证者的抽成奖励
// Query available rewards of a validator address.
// e.g., <validatorAddress>=exvaloper1xkl5agjzqnjnptyat2dng2asmx8g5kllg7xamv
exchaincli query distr commission <validatorAddress>
取出验证者抽成奖励
// Withdraw validator's commission reward with --commission parameter. This will automatically distribute to its own account (or reward withdraw account).
// e.g., <validatorAddr>=exvaloper1xkl5agjzqnjnptyat2dng2asmx8g5kllg7xamv
exchaincli tx distr withdraw-rewards <validatorAddr> --commission [flags]
通用操作命令
exchaincli
命令行工具可以从区块链中查询所有相关信息,例如账户余额、绑定代币数量(质押并投票给一个或多个验证者的 OKT)、未取出的抽成、分红奖励等。
注:每种命令都可以使用-h or --help
获取更多帮助信息。
查询账户信息
// Your balance will change after staking OKTs or withdrawing rewards.
exchaincli query account <yourAddress>
查询交易执行结果
// This returns the execution result of a Tx
exchaincli query tx <txHash>
查询所有验证者列表
// Query the list of all validators.
exchaincli query staking validators
查询验证者详细信息
// Query the details of a validator with a given address.
// e.g., <validatorAddress>=exvaloper1xkl5agjzqnjnptyat2dng2asmx8g5kllg7xamv
exchaincli query staking validator <validatorAddress>
查询验证者详细投票信息
// Query the information of all shares recently added to a validator.
// e.g. <validatorAddress> exvaloper1xkl5agjzqnjnptyat2dng2asmx8g5kllg7xamv
exchaincli query staking shares-added-to <validatorAddress>
查询质押模块参数
// Query the parameters of the staking module.
exchaincli query staking params
查询分红模块参数
// Query the parameters of the distrbution module.
exchaincli query distr params
查询社区池余额
// Query the balance of the community pool.
exchaincli query distr community-pool
设置分红取款地址
// Change the default withdraw address.
// e.g., <withdraw-addr>=ex153z8qwxkqa5p2samfn8z50kr9pt8j6afs0am6e
exchaincli tx distr set-withdraw-addr <withdraw-addr>
查询分红取款地址
// Query the reward withdraw address of a delegator.
exchaincli query distr withdraw-addr <delegator>