How to Stake your Tokens¶
Introduction¶
Collators (block producers) with the highest stake in the network join the active pool of collators, from which they are selected to offer a block to the Relay Chain.
Token holders can add to the collators' stake using their tokens, a process called nomination (also referred to as staking). When they do so, they are vouching for that specific collator, and their nomination is a signal of trust.
When a collator does not behave appropriately, its stake in the network is slashed, affecting the tokens nominated by users as well (feature currently not available in Moonbase Alpha). If collators act accordingly, they'll receive block rewards as part of the inflationary model. They can share these as staking rewards with their nominators.
With the release of Moonbase Alpha v6, users of the network can now stake their tokens to nominate collators. This guide outlines all the steps to do so.
General Definitions¶
Some important parameters to understand in relation to the staking system in Moonbeam include:
- Collators — block producers. They collect transactions from users and produce state transition proofs for the Relay Chain to validate. Have a stake in the network that get slashed if they misbehave
- Nominators — token holders who stake tokens, vouching for specific collators. Any user that holds a minimum amount of tokens as free balance can become a nominator
- Minimum nomination stake — minimum amount of total tokens staked a user must have to be in the set of nominators
- Minimum nomination — minimum amount of tokens to nominate other collators once a user is in the set of nominators
- Maximum nominators per collator — maximum number of nominators a collator can have
- Maximum collators per nominator — maximum number of collators a nominator can nominate
-
Round — number of blocks in a round. An important parameter for reward distribution
-
Bond duration — number of rounds that the staking rewards are delayed
Currently, for Moonbase Alpha:
Variable | Value | |
---|---|---|
Minimum nomination stake | 5 | |
Minimum nomination | 5 | |
Maximum collators per nominator | 25 | |
Round | 600 blocks (2 hours) | |
Bond duration | 2 rounds |
Extrinsics Definitions¶
There are many extrinsics related to the staking pallet, so all of them are not covered in this guide. However, this list defines all of the extrinsics associated with the nomination process:
Note
Extrinsics might change in the future as the staking pallet is updated.
- nominate — two inputs: address of collator to nominate and amount. Extrinsic to nominate a collator. The amount must be at least 5 tokens
- leaveNominators — no inputs. Extrinsic to leave the set of nominators. Consequently, all ongoing nominations will be revoked
- nominatorBondLess — two inputs: address of a nominated collator and amount. Extrinsic to reduce the amount of staked tokens for an already nominated collator. The amount must not decrease your overall total staked below 5 tokens
- nominatorBondMore — two inputs: address of a nominated collator and amount. Extrinsic to increase the amount of staked tokens for an already nominated collator
- revokeNomination — one input: address of a nominated collator. Extrinsic to remove an existing nomination
Retrieving the List of Collators¶
Before starting to stake tokens, it is important to retrieve the list of collators available in the network. To do so, navigate to "Chain state" under the "Developer" tab.
Here, provide the following information:
- Choose the pallet to interact with. In this case, it is the
parachainStaking
pallet - Choose the state to query. In this case, it is the
selectedCandidates
orcandidatePool
state - Send the state query by clicking on the "+" button
Each extrinsic provides a different response:
- selectedCandidates — returns the current active set of collators, that is, the top 8 collators by total tokens staked (including nominations)
- candidatePool — returns the current list of all the collators, including those that are not in the active set
How to Nominate a Collator¶
This section goes over the process of nominating collators. The tutorial will use the following collators as reference:
Variable | Address | |
---|---|---|
Collator 1 | 0x4c5A56ed5A4FF7B09aA86560AfD7d383F4831Cce | |
Collator 2 | 0x62d2e7324f9274fac3893a59aff8e944a323a495 |
To access staking features, you need to use the PolkadotJS Apps interface. To do so, you need to import/create an Ethereum-style account first (H160 address), which you can do by following this guide.
For this example, an account was imported and named with a super original name: Alice.
Currently, everything related to staking needs to be accessed via the "Extrinsics" menu, under the "Developer" tab:
To nominate a collator, provide the following information:
- Select the account from which you want to stake your tokens
- Choose the pallet you want to interact with. In this case, it is the
parachainStaking
pallet - Choose the extrinsic method to use for the transaction. This will determine the fields that need to fill in the following steps. In this case, it is the
nominate
extrinsic - Set the collator's address you want to nominate. In this case, it is set to
0x4c5A56ed5A4FF7B09aA86560AfD7d383F4831Cce
- Set the number of tokens you want to stake
- Click the "Submit Transaction" button and sign the transaction
Once the transaction is confirmed, you can head back to the "Accounts" tab to verify that you have a reserved balance (equal to the number of tokens staked).
To verify a nomination, you can navigate to "Chain state" under the "Developer" tab.
Here, provide the following information:
- Choose the pallet you want to interact with. In this case, it is the
parachainStaking
pallet - Choose the state to query. In this case, it is the
nominators
state - Make sure to disable the "include option" slider
- Send the state query by clicking on the "+" button
In the response, you should see your account (in this case, Alice's account) with a list of the nominations. Each nomination contains the target address of the collator and the amount.
You can follow the same steps as described to nominate other collators in the network. For example, Alice nominated 0x62d2e7324f9274fac3893a59aff8e944a323a495
as well.
How to Stop Nominations¶
If you are already a nominator, you have two options to stop your nominations: using the revokeNomination
extrinsic to unstake your tokens from a specific collator, or using the leaveNominators
extrinsic to revoke all ongoing nominations.
This example is a continuation of the previous section, and assumes that you have at least two active nominations.
You can remove your nomination from a specific collator by navigating to the "Extrinsics" menu under the "Developer" tab. Here, provide the following information:
- Select the account from which you want to remove your nomination
- Choose the pallet you want to interact with. In this case, it is the
parachainStaking
pallet - Choose the extrinsic method to use for the transaction. This will determine the fields that need to fill in the following steps. In this case, it is the
revokeNomination
extrinsic - Set the collator's address you want to remove your nomination from. In this case, it is set to
0x62d2e7324f9274fac3893a59aff8e944a323a495
- Click the "Submit Transaction" button and sign the transaction
Once the transaction is confirmed, you can verify that your nomination was removed in the "Chain state" option under the "Developer" tab.
Here, provide the following information:
- Choose the pallet you want to interact with. In this case, it is the
parachainStaking
pallet - Choose the state to query. In this case, it is the
nominatorState
state - Make sure to disable the "include options" slider
- Send the state query by clicking on the "+" button
In the response, you should see your account (in this case, Alice's account) with a list of the nominations. Each nomination contains the target address of the collator, and the amount.
As mentioned before, you can also remove all ongoing nominations with the leaveNominators
extrinsic (in step 3 of the "Extrinsics" instructions). This extrinsic requires no input:
Once the transaction is confirmed, your account should not be listed in the nominatorState
state when queried, and you should have no reserved balance (related to staking).
Staking Rewards¶
As collators receive rewards from block production, nominators get rewards as well. A brief overview on how the rewards are calculated can be found on this page.
In summary, nominators will earn rewards based on their stake of the total nominations for the collator being rewarded (including the collator's stake as well).
From the previous example, Alice was rewarded with 0.0044
tokens after two payout rounds:
We Want to Hear From You¶
If you have any feedback regarding how to stake your tokens on Moonbase Alpha or any other Moonbeam-related topic, feel free to reach out through our official development Discord channel.