Running a Validator
Staking on NEAR
Translations
Add your language too via Github pull request
READ THIS QUICKSTART GUIDE BEFORE YOU START
Wait until your node is fully synced before you send a staking transaction. An out of sync node cannot produce or validate blocks, so if you're chosen as a validator, you're at risk of being kicked out of the validator pool and losing your rewards if your node doesn't maintain the appropriate uptime (i.e. validate / produce the number of assigned blocks for that epoch).
You can test your validator infrastructure on NEAR TestNet. You can generate an account with a few tokens from the NEAR wallet, and use it to deploy your staking pool. Then, contact NEAR Core-dev on Discord to request sufficient stake to become a validator on TestNet.
For this current session: run the command
export NODE_ENV=testnet
Add this same line (
export NODE_ENV=testnet
) to the end of the file~/.bashrc
if you want to ensure this environment variable persists at machine restarts.
TestNet is running on separate URLs for the explorer, the wallet and the Json RPC:
Every new TestNet account receives automatically a few hundred tokens to deploy smart contracts and test your APIs.
You can use nearup to easily deploy your TestNet node on a VPS. If you plan to deploy on MainNet, you can't use nearup, and we suggest following the guidelines here. Join NEAR validator channels on Discord to receive technical support by NEAR team and the rest of the community.
NEAR Validators should:
Know how to compile, deploy and configure NEAR Validator nodes
Understand the difference between
account_key
,node_key
andvalidator_key
(see the keys on NEAR Platform doc)Understand how to deploy a NEAR contract, and the difference between
view
andcall
methods. Know how to leverage them vianear-cli
andnear RPC
Have a monitoring platform in place, to measure the generated and missed blocks, peers and connectivity, current node version, along with the typical CPU, memory, storage, and networking performance
Understand the state of a validator:
proposals
,next
andcurrent
Use the information above to control if the validator is falling outside of the active set, and what needs to be done to fix the issue
Know where to find information about upcoming nearcore releases and other tooling upgrades
Node hardware requirements
The minimum requirements to run a validator node on NEAR are:
More information is on the Hardware Requirements docs.
Setting up your environment
IMPORTANT: Make sure you have the latest version of NEAR CLI and Node Version 12.x
You can install and upgrade Near CLI by using npm:
Note: The default network for near-cli
is testnet
. If you would like to change this to mainnet
or betanet
, please see near-cli
network selection for instructions.
Once Near CLI is installed, go ahead and run your node.
Pro Tip
You don't have to run near-cli on your validator node: all staking commands are issued to the staking pool, which is a normal smart contract.
Run the Node
Please follow Nearup documentation to start your TestNet node. Remember that nearup
doesn't support MainNet, so you will have to build your startup scripts and follow the mainnet deployment guide.
At the first start, nearup
will ask for your validator account ID. Put a placeholder, like coming_soon
, to let the node sync with the network while you deploy the staking pool:
While the sync is in progress, you have to retrieve your validator key from ~/.near/testnet/validator_key.json
:
This key will be needed to do the pairing between your validator node and its staking pool.
Authorize near-cli
to your TestNet account
near-cli
to your TestNet accountConfigure
near-cli
to use TestNet, issuing the commandexport NODE_ENV=testnet
Authenticate
near-cli
with your NEAR Wallet account, by running the commandnear login
You will be asked to navigate to a URL to authenticate your staking account. You can expect a result similar to the one below:
Be careful to specify the same TestNet account ID in the browser and near-cli
:
Once you completed the login in the browser and put the account id in the input field above, you should expect a message like the one below:
Heads Up!
If you get an ERR_CONNECTION_REFUSED error, double-check that your browser is not trying to open the address http://127.0.0.1:5000. This is a wrong redirect of near-cli running on a remote instance, and can be ignored.
To test if your near-cli
is capable to control your testnet
account, issue the command: $ near send nearkat.testnet testnet 0.1
, where nearkat.testnet
is the sender, and testnet
the recipient of 0.1
NEAR tokens. You can expect a result similar to this one:
Deploy the staking pool
NEAR Protocol provides a staking pool smart contract from the initial contracts Github repository.
Deploy your staking pool by sending the call method below to the staking pool factory:
Where:
pool.f863973.m0
is the staking pool factory mentioned above<POOL_ID>
is the name of the staking pool contract. If you pass the parameterheyheyhey
the result will beheyheyhey.pool.f863973.m0
<OWNER_ID>
is the account authorized to send the owner methods to the pool, such as the validator key or the fees<VALIDATOR_KEY>
is the public key stored at~/.near/testnet/validator_key.json
on your validator node (see staking#run-the-node step above){"numerator": <X>, "denominator": <Y>}
set the validator fees. 10% of fees requiresx=10
andy=100
--amount 50
attaches 50 $NEAR to the transaction, as a reserve to pay the contract storage--gas 300000000000000
specifies the gas for the transaction (optional)
You can expect a result similar to this one:
The true
statement in the last line and the explorer link provide proof that the staking pool is deployed and ready to receive the stake
Configure your node's validator_key.json
and restart nearup
validator_key.json
and restart nearupOnce the staking pool is deployed, manually edit the file ~/.near/testnet/validator_key.json
on your validator node and replace coming_soon
with your staking pool account name:
Once done, you can stop and restart nearup
, with the command: nearup stop
followed by: nearup run testnet
Heads Up!
Be sure that your node downloaded entirely the genesis.json file before giving the stop command to nearup.
Becoming a Validator in the active set
Once the staking pool is deployed, you can stake tokens using any of the methods offered in the delegation docs. Make sure that you are using a tool that supports TestNet and not only MainNet.
NEAR TestNet and MainNet require at least 24 hours bonding period to accept your staking pool bid. You can verify if you are a validator when in the logs of the node you see "V/" - where V means this node is currently a validator:
The 0/0/40 shows the total validators: connected peers / up to date peers / my peers. This number may change over time.
To learn more about how validators are chosen, take a look at the Staking FAQ.
See the list of current and future validators
You can use near-cli
to review the validator set in the next three epochs:
Heads Up!
You have to wait at least 2 epochs (43,200 blocks each) before your
Note: The default network for near-cli
is testnet
. If you would like to change this to mainnet
or betanet
, please see near-cli
network selection for instructions.
Automatically re-staking
NEAR Protocol automatically re-stakes all inflationary rewards, unless you decide to manually unstake some of the funds.
Additional links
Got a question? Ask it on StackOverflow!
Last updated