Skip to main content

Validator

This guide details how to configure a synced full node to become an active validator, deploy a staking pool, and start securing the NEAR network.

Prerequisite: You must have a fully synced Mainnet node as described in the Full Node Setup Guide.


Your node needs to be associated with your validator's staking pool ID.

  1. Stop the node to make configuration changes:

    sudo systemctl stop neard
  2. Edit the config.json to include your validator's future account ID. Your validator ID will follow the format <pool_name>.pool.near. For example, my-node.pool.near.

    Open the config file:

    nano ~/.near/config.json

    Find the line "account_id": null, and change it to your validator's ID:

    "account_id": "<pool_name>.pool.near",
  3. The validator_key.json file in ~/.near/ contains the public key your node will use to sign blocks. You will need this key later.


Step 2: Create and Authorize a Wallet

You need a Mainnet NEAR wallet to own and manage your staking pool.

  1. Create a Wallet: Go to MyNearWallet (or another compatible wallet) and create a new account. This will be your owner_id.
  2. Fund Your Wallet: Send at least 31 NEAR to this new wallet address. This is required to pay for the staking pool contract's storage.
  3. Authorize the CLI: Connect your local machine to your wallet to sign transactions.
    near login
    This command opens a web browser. Follow the prompts to grant access to the NEAR CLI.

Step 3: Deploy Your Staking Pool

Deploy the smart contract that allows others to delegate their NEAR to your validator.

Replace the following placeholders in the command below:

  • <pool_name>: Your chosen pool name (e.g., my-node).
  • <owner_id>: Your main wallet address (e.g., mywallet.near).
  • <public_key>: The public key from your ~/.near/validator_key.json file.
near contract call-function as-transaction pool.near create_staking_pool json-args '{"staking_pool_id": "<pool_name>", "owner_id": "<owner_id>", "stake_public_key": "<public_key>", "reward_fee_fraction": {"numerator": 5, "denominator": 100}}' prepaid-gas '300.0 Tgas' attached-deposit '30 NEAR' sign-as <owner_id> network-config mainnet sign-with-keychain

A True result at the end indicates the deployment was successful. You can now restart your node:

sudo systemctl start neard

Step 4: Join the Validator Set

To become an active validator, you must have enough stake to meet the current seat price and submit a proposal.

  1. Check the Seat Price: Find the minimum stake required.
    near-validator validators network-config mainnet next
  2. Deposit Stake (Optional): If you are staking your own funds, deposit them into your pool.
    near contract call-function as-transaction <pool_name>.pool.near deposit_and_stake prepaid-gas '300.0 Tgas' attached-deposit '<amount_in_yocto_near>' sign-as <owner_id> network-config mainnet sign-with-keychain
  3. Send an Initial Proposal (Ping): A "ping" submits your proposal to the network. It also updates staking balances and rewards for your delegators.
    near contract call-function as-transaction <pool_name>.pool.near ping json-args '{}' prepaid-gas '300.0 Tgas' attached-deposit '0 NEAR' sign-as <owner_id> network-config mainnet sign-with-keychain

After your proposal is accepted and your total stake (your own + delegations) exceeds the seat price, you will enter the active validator set within a few epochs.


Step 5: Ongoing Maintenance

Automated Pinging

It's crucial to ping regularly to keep your proposal active. Set up a cron job to do this automatically. This example runs every 8 hours.

# Create a script file
mkdir -p ~/scripts && nano ~/scripts/ping.sh

# Add the following content, replacing placeholders
#!/bin/sh
export NEAR_ENV=mainnet
POOL_ID="<pool_name>.pool.near"
ACCOUNT_ID="<owner_id>"
near contract call-function as-transaction $POOL_ID ping json-args '{}' prepaid-gas '300.0 Tgas' attached-deposit '0 NEAR' sign-as $ACCOUNT_ID network-config mainnet sign-with-keychain

# Make it executable and add to crontab
chmod +x ~/scripts/ping.sh
(crontab -l 2>/dev/null; echo "0 */8 * * * /home/[USER]/scripts/ping.sh") | crontab -

Updating Your Node

When a new version of nearcore is announced, follow these steps to update:

cd ~/nearcore
git fetch
git checkout <new_version_tag>
make release
sudo systemctl restart neard