diff --git a/docs/1.concepts/basics/staking.md b/docs/1.concepts/basics/staking.md index 8626ec4162..f0fa03ea0a 100644 --- a/docs/1.concepts/basics/staking.md +++ b/docs/1.concepts/basics/staking.md @@ -53,6 +53,13 @@ Before delegating, you need to choose a validator (a node that participates in s Once you select a validator and the stake transaction is confirmed, your tokens are delegated to the staking pool. You will start earning staking rewards after the next epoch (approximately 12 hours). +:::info Delegation without a staking pool + +For validators, there's also an option to stake NEAR tokens without deploying a staking pool smart contract. +Check [this section](../../4.tools/cli.md#staking) to learn how to stake using the [`near-validator`](../../4.tools/cli.md#validator-extension) CLI. + +::: + ### Selecting a Staking Pool Use [NearBlocks](https://nearblocks.io/node-explorer), [Pikespeak](https://pikespeak.ai/validators/overview) or [Near Staking](https://near-staking.com/) to find a validator and their staking pool. @@ -66,28 +73,74 @@ Look for validators with a good track record, uptime, and reasonable commission ::: +If you prefer, you can get the list of current validators by using the [`near-validator`](../../4.tools/cli.md#validator-extension) CLI: + +```sh +near-validator validators network-config mainnet now +``` + ### Staking using CLI Once you have chosen a validator you want to delegate your tokens to, follow these steps to stake them using the NEAR CLI: 1. Connect your wallet to the CLI and ensure you have NEAR tokens to delegate. + + + +```sh +near account import-account using-web-wallet network-config mainnet +``` + + + + ```sh near login ``` + + + + 2. Deposit tokens to the `` staking pool: + + + ```sh -near call deposit '{}' --accountId --amount 100 +near contract call-function as-transaction deposit json-args {} prepaid-gas '30.0 Tgas' attached-deposit '100 NEAR' sign-as network-config testnet sign-with-keychain send ``` + + + +```sh +near call deposit '{}' --accountId --deposit 100 +``` + + + + 3. Stake the deposited tokens by calling the `stake` method: + + + +```sh +near staking delegation stake '100 NEAR' network-config mainnet sign-with-keychain +``` + + + + ```sh near call stake '{"amount": "100000000000000000000000000"}' --accountId ``` + + + :::tip Interactive CLI If you want to manage your staking actions with an interactive CLI, use this command and follow the prompts on your screen: @@ -102,10 +155,23 @@ near staking delegation Once the transaction is confirmed, your tokens are delegated to the staking pool. + + + +```sh +near staking delegation view-balance network-config mainnet now +``` + + + + ```sh near view get_account_staked_balance '{"account_id": ""}' ``` + + + :::info Using a wallet to check your staked tokens You can see your staked balance, rewards earned, and the validator you delegated to using a web3 wallet. For example, you can try `https://app.mynearwallet.com/profile/`. @@ -121,18 +187,44 @@ The rewards are typically distributed periodically, and you will be able to see To check your total balance on the `` pool: + + + +```sh +near staking delegation view-balance network-config mainnet now +``` + + + + ```sh near view get_account_total_balance '{"account_id": ""}' ``` + + + #### User staked balance To check your staked balance on the `` pool: + + + +```sh +near staking delegation view-balance network-config mainnet now +``` + + + + ```sh near view get_account_staked_balance '{"account_id": ""}' ``` + + +
Staking pool balances @@ -181,30 +273,82 @@ To un-delegate the tokens: 1. First execute the `unstake` method on the `` contract: + + + +```sh +near staking delegation unstake '1 NEAR' network-config mainnet sign-with-keychain +``` + + + + ```sh near call unstake '{"amount": "100000000000000000000000000"}' --accountId ``` + + + 2. Check the unstaked balance for your `` account: + + + +```sh +near staking delegation view-balance network-config mainnet now +``` + + + + ```sh near view get_account_unstaked_balance '{"account_id": ""}' ``` + + + 3. After 4 epochs, check if you can withdraw: + + + +```sh +near contract call-function as-read-only is_account_unstaked_balance_available json-args '{"account_id": ""}' network-config mainnet now +``` + + + + ```sh near view is_account_unstaked_balance_available '{"account_id": ""}' ``` + + + If the Validator's response is `true`, then your tokens are ready for the last step. 4. Finally, withdraw the unstaked tokens: + + + +```sh +near staking delegation withdraw '1 NEAR' network-config mainnet sign-with-keychain +``` + + + + ```sh near call withdraw '{"amount": "100000000000000000000000000"}' --accountId ``` + + + --- ## Tools and Resources diff --git a/docs/4.tools/cli.md b/docs/4.tools/cli.md index 075bc67731..da0191cacf 100644 --- a/docs/4.tools/cli.md +++ b/docs/4.tools/cli.md @@ -45,6 +45,37 @@ The NEAR [Command Line Interface](https://github.com/near/near-cli-rs) (CLI) is +### Validator Extension + +If you want to interact with [NEAR Validators](https://pages.near.org/papers/economics-in-sharded-blockchain/#validators) from command line, you can also install the optional [NEAR Validator CLI Extension](https://github.com/near-cli-rs/near-validator-cli-rs): + + + + + ```bash + npm install -g near-validator + ``` + + + + ```bash + $ cargo install near-validator + ``` + + + + ```bash + curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near-cli-rs/near-validator-cli-rs/releases/latest/download/near-validator-installer.sh | sh + ``` + + + + ```bash + irm https://github.com/near-cli-rs/near-validator-cli-rs/releases/latest/download/near-validator-installer.ps1 | iex + ``` + + + --- ## Configuration file @@ -540,4 +571,106 @@ This will allow you to change or modify the network connections for your CLI. :::important We provide examples only of the most used commands. If you want to explore all options provided by `near-cli` use [the interactive mode](#interactive-mode). -::: \ No newline at end of file +::: + +--- + +## Validators + +:::tip +To use these commands, you **must** install the CLI [validator extension](#validator-extension). +::: + +You can use the following commands to interact with the blockchain and view validator stats. There are three reports used to monitor validator status: + +- [Proposals](#proposals) +- [Current validators](#current-validators) +- [Next validators](#next-validators) + +### Proposals + +A proposal by a validator indicates they would like to enter the validator set, in order for a proposal to be accepted it must meet the minimum seat price. + + + + +```sh +near-validator proposals network-config mainnet +``` + + + + +### Current Validators + +This shows a list of active validators in the current epoch, the number of blocks produced, number of blocks expected, and online rate. Used to monitor if a validator is having issues. + + + + +```sh +near-validator validators network-config mainnet now +``` + + + + +### Next Validators + +This shows validators whose proposal was accepted one epoch ago, and that will enter the validator set in the next epoch. + + + + +```sh +near-validator validators network-config mainnet next +``` + + + + +### Staking + +For validators, there's also an option to stake NEAR tokens without deploying a staking pool smart contract. + +#### View validator stake + +To view the validator's stake on the last block, you need to enter in the terminal command line: + + + + +```sh +near-validator staking view-stake examples.testnet network-config testnet now +``` + + + + +#### Stake directly without a staking pool + +To stake the amount you must enter in the terminal command line: + + + + +```sh +near-validator staking stake-proposal examples.testnet ed25519:AiEo5xepXjY7ChihZJ6AsfoDAaUowhPgvQp997qnFuRP '1500 NEAR' network-config testnet sign-with-keychain send +``` + + + + +#### Unstake directly without a staking pool + +To unstake you must enter in the terminal command line: + + + + +```sh +near-validator staking unstake-proposal examples.testnet ed25519:AiEo5xepXjY7ChihZJ6AsfoDAaUowhPgvQp997qnFuRP network-config testnet sign-with-keychain send +``` + + +