Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.near.org/llms.txt

Use this file to discover all available pages before exploring further.

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 codeYou 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.
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
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
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
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
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

Sunsetting a Stake Pool

If you are a stake pool owner and want to wind down your validator service, follow these steps to ensure delegators can safely recover their funds.

Step 1: Notify Delegators

Before making any changes, inform your delegators that the pool is shutting down. Give them enough time to unstake and withdraw their tokens. They need to:
  1. Call unstake_all on the pool.
  2. Wait for the 4-epoch unbonding period (~48 hours).
  3. Call withdraw_all to retrieve their tokens.
You can share the commands from the Withdrawing Staked Tokens section above with them.

Step 2: Pause Staking

Call pause_staking from the pool owner account. This causes the contract to unstake everything (stake 0) and stop restaking, without affecting share balances or reward calculations.
near call <my_validator> pause_staking '{}' --useAccount <owner-account.near> --depositYocto 1 --networkId mainnet
The contract will unstake all tokens at the next epoch boundary. Delegators will still see their shares and can unstake and withdraw normally.

Step 3: Withdraw Owner Balance

Once your own staked tokens are unstaked and the unbonding period has passed, withdraw them:
near staking delegation <owner-account.near> withdraw-all <my_validator> network-config mainnet sign-with-keychain

Step 4: Resume (Optional)

If you decide to keep the pool running again, you can re-enable staking at any time:
near call <my_validator> resume_staking '{}' --useAccount <owner-account.near> --depositYocto 1 --networkId mainnet

Tools and Resources