Staking on miners and sharders

0Chain miner smart contract allows staking on the miner and sharder nodes to validate transactions and earn rewards. To start staking on miner and sharder nodes, miner and sharder ID's are required which can be fetched using below commands.

Listing all miners

./zwallet ls-miners list the miners retrieved using the Miner smart contract. Parameters can be viewed using ./zwallet ls-miners --help flag.

Get list of all active miners from Miner SC

Usage:
  zwallet ls-miners [flags]

Flags:
  -h, --help   help for ls-miners
      --json   as JSON

--jsonflag can be passed to retrieve miners as JSON data.

Command:

./zwallet ls-miners

Sample Output:

- ID:         cdb9b5a29cb5f48b350481694c4645c2db24500e3af210e22e2d10477a68bad2
- Host:       one.devnet-0chain.net
- Port:       31203
- ID:         3d9a10dac6fb3903d4a5283a42ae07b29d8e5d228afcce9bfc14e3e9dbc82748
- Host:       one.devnet-0chain.net
- Port:       31201
- ID:         aaa721d5fbf4ca83e20c8c40874ebcb144b86f57173633ff1702968677c2fa98
- Host:       one.devnet-0chain.net
- Port:       31202

Listing all sharders

./zwallet ls-sharders list the sharders retrieved using the Miner smart contract. Parameters can be viewed using ./zwallet ls-sharders --help flag.

--all flag can be passed to retrieve all the available sharders where as --jsonflag will retrieve sharders as JSON data.

Command:

Sample output:

Get the staking configuration

To find out the number of delegates and the minimum and maximum tokens that can be staked, query the config using ./zwallet mn-config command.

./zwallet mn-config command displays the configuration and current requirements for staking.

Command:

Response:

According to the response the max delegates allowed are 200, where as the minimum and maximum number of tokens that can be staked are 0 and 100.

Get the miner or sharder info for staking

./zwallet mn-info command can be used to get staking info for a particular sharder or miner.

Parameters for mn-info command can be viewed using ./zwallet mn-info --help

Here,--id flag requires a particular miner and sharder ID which can be fetched using the ls-minersor ls-sharders command. For demonstration we are using a particular miner id fetched using ls-miners command.

Command:

Response:

Locking a stake on a node

Staking tokens on a miner or sharder nodes helps earning additional tokens over time. Tokens locked for staking can be unlocked anytime but you have to wait for the next view change cycle.

Note: If a node becomes offline, all stake pools are automatically unlocked and tokens are returned to wallets.

Stalking tokens can be locked using the ./zwallet mn-lock command. Parameters for locking the tokens can be viewed using the ./zwallet mn-lock --help.

Here, miner /sharder id with the required number of tokens to be locked are required.

Command for locking 0.2 tokens:

Response:

Note: If the locking of stakes is failing, verify the following.

  1. Wallet has enough tokens

  2. Node ID is valid

  3. Node has available delegates

Getting the stake pools of a wallet

A stake pool allows multiple stakeholders (miners/sharders) to contribute to a blockchain in a manner that it increase their chances of earning staking rewards. Every stakeholder stakes tokens through its wallet in the stake pool.

To get the stake pool information of a particular wallet,./zwallet mn-user-info command can be used. Parameters for the ./zwallet mn-user-infocan be viewed using the --help tag.

Here, Client ID for a particular user is required which can be fetched from the wallet located in the .zcn directory. As mentioned above --client_id flag is optional and if you do not specify a particular wallet client_id. It will find the stake pool related to wallet config in default wallet.json file.

Command:

Response:

On a successful response, you will see the staked miner/sharder nodes and the amount of tokens locked with that particular wallet. The response output can also be formatted in JSON data using the --json flag.

Getting the stake pool info

./zwallet mn-pool-info command can be used to get stake pool info for a particular miner/sharder. Parameters can be viewed using the ./zwallet mn-pool-info --help

--id flag requires miner/sharder ID which can be fetched using ls-miners or ls-sharders command,pool_id is generated when you lock stake tokens for a miner/sharder node, you can copy the pool_id from the response text or can view it using mn-user-info command.

Command:

Formatted Response:

Unlocking a stake on node

Staking tokens can be unlocked using the ./zwallet mn-unlock command. Parameters for locking the tokens can be viewed using the ./zwallet mn-unlock --help

Here, miner /sharder id with the pool ID to unlock the stake are required. Miner/sharder id can be fetched using ls-miners or ls-sharders command whereaspool_id is generated when you lock stake tokens for a miner/sharder node ,you can view it using mn-user-info command.

Command for unlocking would be:

Output:

Note: Tokens are released on the next view change cycle or at the next reward round.

Updating staking config of a node

./zwallet mn-update-settings command is used to update the staking config of a node. Parameters for the command can be viewed using --help flag.

Miner/Sharder ID of the node is a required flag and can be fetched using ls-minersor ls-sharders command. Variables that can be updated are max stake, min stake and number of delegate pools.

Before updating the configuration lets get the default staking configuration for miner/sharder node using :

Response:

In the above configuration min stake, max stake, number of delegate pools are 0,1000000000000 and 10 respectively. Lets update the miner/sharder node for 25 delegate pools, min and max stake for 1000,100000 using mn-update-settings.

Note: Staking config can only be updated by the node's delegate wallet.

Last updated