Intermediate
How to delegate and undelegate tokens and check delegations
This tutorial provides a guide to delegate and undelegate tokens to/from a validator in the Harmony network and to check the number of delegations to your validator. The commands provided can be used in either Mainnet or Testnet with the difference in the node URL. The tutorial explains the syntax of the delegate, undelegate, and check delegation commands, along with the different parameters used such as delegator-addr, validator-addr, and amount, and the expected output. The tokens will be released at the end of the epoch after undelegation, and the number of delegations to the validator can be viewed by using the blockchain delegation by-validator command.
Delegating To A Validator
How to delegate tokens to a validator
You can delegate tokens to a validator using the following command:
Mainnet
./hmy --node="https://api.s0.t.hmny.io" staking delegate \ --delegator-addr [ONE ADDRESS] --validator-addr [ONE ADDRESS] \ --amount [AMOUNT] --passphrase
Testnet
./hmy --node="https://api.s0.b.hmny.io" staking delegate \ --delegator-addr [ONE ADDRESS] --validator-addr [ONE ADDRESS] \ --amount [AMOUNT] --passphrase
Example:
./hmy --node="https://api.s0.t.hmny.io" staking delegate \ --delegator-addr one1km7xg8e3xjys7azp9f4xp8hkw79vm2h3f2lade --validator-addr one1km7xg8e3xjys7azp9f4xp8hkw79vm2h3f2lade \ --amount 10000 --passphrase
The CLI will ask for the passphrase for the delegator-addr
keystore file.
--delegator-addr
is the ONE address of the delegator (string)
--validator-addr
is the ONE address of the validator (string)
--amount
is the number of ONE tokens to delegate to the validator (float)
As a validator, if you want to increase your stake, you will have to delegate to yourself. For delegating to your own validator, delegator-addr
and validator-addr
will be the same.
Undelegating From A Validator
How to undelegate your tokens from a validator
You can un-delegate tokens from a validator using the following command:
Mainnet
./hmy --node="https://api.s0.t.hmny.io" staking undelegate \ --delegator-addr [ONE ADDRESS] --validator-addr [ONE ADDRESS] \ --amount [AMOUNT] --passphrase
Testnet
./hmy --node="https://api.s0.b.hmny.io" staking undelegate \ --delegator-addr [ONE ADDRESS] --validator-addr [ONE ADDRESS] \ --amount [AMOUNT] --passphrase
Example:
./hmy.sh -- node="https://api.s0.t.hmny.io" staking undelegate \ --delegator-addr one1km7xg8e3xjys7azp9f4xp8hkw79vm2h3f2lade --validator-addr one1km7xg8e3xjys7azp9f4xp8hkw79vm2h3f2lade \ --amount 10000 --passphrase
The CLI will ask for the passphrase for the delegator-addr
keystore file.
--delegator-addr
is the ONE address of the delegator (string)
--validator-addr
is the ONE address of the validator (string)
--amount
is the number of ONE tokens to un-delegate (float)
As a validator, for un-delegating from your own validator, delegator-addr
and validator-addr
will be the same.
When will I get my tokens back after un-delegating?
When you decide to un-delegate your tokens from a validator, your tokens will be released at the end of the epoch from when you un-delegate.
This means that you will NOT have access to these tokens and can NOT transfer them after choosing to un-delegate your tokens from a validator until the tokens are in your account.
If your validator didn’t get elected in the last epoch, you will get the token back at the end of current epoch.
Check Your Delegations
How to see your delegators
You can see the number of delegations to your validator with the following command:
Mainnet
./hmy blockchain delegation by-validator [VALIDATOR ADDRESS] --node="https://api.s0.t.hmny.io"
Testnet
./hmy blockchain delegation by-validator [VALIDATOR ADDRESS] --node="https://api.s0.b.hmny.io"
Example:
./hmy blockchain delegation by-validator one1km7xg8e3xjys7azp9f4xp8hkw79vm2h3f2lade --node="https://api.s0.t.hmny.io"
Output:
{ "id": "0", "jsonrpc": "2.0", "result": [ { "Undelegations": [], "amount": 93000000000000000000, "delegator_address": "one1ctr58xue32peagud620tmthc95w5ch94vfhfgp", "reward": 193348691324709180000, "validator_address": "one1ctr58xue32peagud620tmthc95w5ch94vfhfgp" }, { "Undelegations": [], "amount": 1.01e+22, "delegator_address": "one1cg5d67v28m3s0xuph46y8w842yu9dzd7094zr5", "reward": 646413329184000700000, "validator_address": "one1ctr58xue32peagud620tmthc95w5ch94vfhfgp" } ] }