Staking NEAR Tokens
Learn how to stake NEAR, delegate to validators, track rewards, and withdraw staked tokens safely.
You can delegate NEAR tokens to a validator to help secure the network and earn staking rewards.
This tutorial shows you how to stake tokens, check balances, unstake, and withdraw using the NEAR CLI.
[!NOTE]
Contract source code
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.
[accordion] List validators using CLI
If you prefer, you can get the list of current validators by using the
near-validatorCLI:near-validator validators network-config mainnet now
Stake Tokens
[tab] Staking CLI
near staking delegation <user-account.near> deposit-and-stake '100 NEAR' <my_validator> network-config mainnet sign-with-keychain
[tab] Function Call
near call <my_validator> deposit_and_stake --useAccount <user-account.near> --deposit 100
[tab] Lantstool
Try it out on Lantstool
[!TIP]
You will start earning staking rewards after the next epoch
Staked Balance
To check your staked balance on the <my_validator> pool for the <user-account.near> account, run the following command:
[tab] Staking CLI
near staking delegation <user-account.near> view-balance <my_validator> network-config mainnet now
[tab] Function Call
near view <my_validator> get_account_staked_balance '{"account_id": "<user-account.near>"}'
[tab] Lantstool
Try it out on Lantstool
[accordion] 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
[tab] 🖥️ CLI
near view <my_validator> get_total_staked_balance '{}'[tab] Lantstool
Try it out on Lantstool
Owner of the staking pool
[tab] 🖥️ CLI
near view <my_validator> get_owner_id '{}'[tab] Lantstool
Try it out on Lantstool
Current reward fee
[tab] 🖥️ CLI
near view <my_validator> get_reward_fee_fraction '{}'[tab] Lantstool
Try it out on Lantstool
Owner's balance
[tab] 🖥️ CLI
near view <my_validator> get_account_total_balance '{"account_id": "owner"}'[tab] Lantstool
Try it out on Lantstool
Staking key
[tab] 🖥️ CLI
near view <my_validator> get_staking_key '{}'[tab] Lantstool
Try it out on Lantstool
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 unbonding period before they can be withdrawn.
Unstake Tokens
[tab] Staking CLI
near staking delegation <user-account.near> unstake '1 NEAR' <my_validator> network-config mainnet sign-with-keychain[!NOTE]
Use the
unstake-allcommand to unstake all tokens at once:near staking delegation <user-account.near> unstake-all <my_validator> network-config mainnet sign-with-keychain
[tab] Function Call
near call <my_validator> unstake '{"amount": "100000000000000000000000000"}' --useAccount <user-account.near>[!NOTE]
Call the
unstake_allmethod to unstake all tokens at once
[tab] Lantstool
Try it out on Lantstool
Query Unstaked Balance
[tab] Staking CLI
near staking delegation <user-account.near> view-balance <my_validator> network-config mainnet now
[tab] Function Call
near view <my_validator> get_account_unstaked_balance '{"account_id": "<user-account.near>"}'
[tab] Lantstool
Try it out on Lantstool
Withdraw Tokens
Once the unbonding period has passed, you can withdraw your unstaked tokens:
[tab] Staking CLI
near staking delegation <user-account.near> withdraw '1 NEAR' <my_validator> network-config mainnet sign-with-keychain[!NOTE]
If you want to withdraw all available tokens, you can use the
withdraw-allcommand:near staking delegation <user-account.near> withdraw-all <my_validator> network-config mainnet sign-with-keychain
[tab] Function Call
near call <my_validator> withdraw '{"amount": "100000000000000000000000000"}' --useAccount <user-account.near>
[tab] Lantstool
Try it out on Lantstool
Tools and Resources
- Supported wallets for staking and managing your tokens:
- To explore validators and staking pools: