Skip to main content

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.

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.

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

near staking delegation <user-account.near> deposit-and-stake '100 NEAR' <my_validator> network-config mainnet sign-with-keychain
tip

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:

near staking delegation <user-account.near> view-balance <my_validator> network-config mainnet now
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

near view <my_validator> get_total_staked_balance '{}'

Owner of the staking pool

near view <my_validator> get_owner_id '{}'

Current reward fee

near view <my_validator> get_reward_fee_fraction '{}'

Owner's balance

near view <my_validator> get_account_total_balance '{"account_id": "owner"}'

Staking key

near view <my_validator> get_staking_key '{}'

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

near staking delegation <user-account.near> unstake '1 NEAR' <my_validator> network-config mainnet sign-with-keychain
info

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

Query Unstaked Balance

near staking delegation <user-account.near> view-balance <my_validator> network-config mainnet now

Withdraw Tokens

Once the unbonding period has passed, you can withdraw your unstaked tokens:

near staking delegation <user-account.near> withdraw '1 NEAR' <my_validator> network-config mainnet sign-with-keychain
info

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

Tools and Resources