Validator Staking
NEAR uses a Proof-of-Stake (PoS), meaning that users chose the active node validators by delegating their tokens to them.
In this article you'll find a detailed explanation of the staking process, including delegating, viewing balances, and withdrawing using the NEAR CLI.
You can review the Staking pool smart contract source code in this GitHub repository.
Delegate NEAR tokens
Before delegating, you need to choose a validator (a node that participates in staking).
Check NearBlocks, Pikespeak or Near Staking, and look for validators with a good track record, uptime, and reasonable commission rates.
List validators using CLI
If you prefer, you can get the list of current validators by using the near-validator CLI:
near-validator validators network-config mainnet now
Stake Tokens
- Staking CLI
- Function Call
- Lantstool
near staking delegation <user-account.near> deposit-and-stake '100 NEAR' <my_validator> network-config mainnet sign-with-keychain
near call <my_validator> deposit_and_stake --useAccount <user-account.near> --deposit 100
Try it out on Lantstool
Loading...
You will start earning staking rewards after the next epoch (approximately 12 hours)
Staked Balance
To check your staked balance on the <my_validator> pool for the <user-account.near> account, run the following command:
- Staking CLI
- Function Call
- Lantstool
near staking delegation <user-account.near> view-balance <my_validator> network-config mainnet now
near view <my_validator> get_account_staked_balance '{"account_id": "<user-account.near>"}'
Try it out on Lantstool
Loading...
Staking pool balances
You can view additional information and balances from the staking pool using the following CLI commands:
Total staked balance of the entire pool
- 🖥️ CLI
- Lantstool
near view <my_validator> get_total_staked_balance '{}'
Try it out on Lantstool
Loading...
Owner of the staking pool
- 🖥️ CLI
- Lantstool
near view <my_validator> get_owner_id '{}'
Try it out on Lantstool
Loading...
Current reward fee
- 🖥️ CLI
- Lantstool
near view <my_validator> get_reward_fee_fraction '{}'
Try it out on Lantstool
Loading...
Owner's balance
- 🖥️ CLI
- Lantstool
near view <my_validator> get_account_total_balance '{"account_id": "owner"}'
Try it out on Lantstool
Loading...
Staking key
- 🖥️ CLI
- Lantstool
near view <my_validator> get_staking_key '{}'
Try it out on Lantstool
Loading...
Withdrawing Staked Tokens
To withdraw your staked tokens, you will first need to "un-delegate" them from the validator.
Your tokens will enter a 4 epoch (~24 hours) unbonding period before they can be withdrawn.
Unstake Tokens
- Staking CLI
- Function Call
- Lantstool
near staking delegation <user-account.near> unstake '1 NEAR' <my_validator> network-config mainnet sign-with-keychain
Use the unstake-all command to to unstake all tokens at once:
near staking delegation <user-account.near> unstake-all <my_validator> network-config mainnet sign-with-keychain
near call <my_validator> unstake '{"amount": "100000000000000000000000000"}' --useAccount <user-account.near>
Call the unstake_all method to unstake all tokens at once
Try it out on Lantstool
Loading...
Query Unstaked Balance
- Staking CLI
- Function Call
- Lantstool
near staking delegation <user-account.near> view-balance <my_validator> network-config mainnet now
near view <my_validator> get_account_unstaked_balance '{"account_id": "<user-account.near>"}'
Try it out on Lantstool
Loading...
Withdraw Tokens
Once the unbonding period has passed, you can withdraw your unstaked tokens:
- Staking CLI
- Function Call
- Lantstool
near staking delegation <user-account.near> withdraw '1 NEAR' <my_validator> network-config mainnet sign-with-keychain
If you want to withdraw all available tokens, you can use the withdraw-all command:
near staking delegation <user-account.near> withdraw-all <my_validator> network-config mainnet sign-with-keychain
near call <my_validator> withdraw '{"amount": "100000000000000000000000000"}' --useAccount <user-account.near>
Try it out on Lantstool
Loading...
Tools and Resources
- Supported wallets for staking and managing your tokens:
- To explore validators and staking pools: