Create keys and staking pool on mainnet

There are 3 types of key pairs we manage

  • Account key:
    • You need this to manage the staking pool - creating the staking pool, and pinging a proposal every epoch (to renew proposals and update staking balance).
    • On NEAR, accounts are human-readable, so you can claim your account ID e.g. bitwise.near
    • There are two flavors of signer keys currently available, FullAccess keys and FunctionCall keys. The first has unrestricted control to "act on behalf of an account" (as used by NEAR CLI and NEAR Wallet). The second is limited to contract storage and compute. We’re going to create a FullAccess key via near login in this guide.
    • This wallet should be funded with a small balance to cover the costs of sending pings each epoch.
  • Validator key: Used to sign and validate blocks and chunks.
  • Node key: Used internally by a node to sign low-level communications with other nodes in the network like sending block headers or making other verifiable requests.

You can generate all of these keys independently from the node.

Create an account key with near login

Install CLI

npm install -g near-cli

Use mainnet

export NEAR_ENV=mainnet
near login

This command opens a web browser where you can authorize and copy a key to your local machine.

  • Copy the link into your browser
  • Grant access to NEAR CLI
  • You'll see a "127.0.0.1 refused to connect" page—this is expected
  • Return to your console and enter your wallet/account ID (e.g., bitwise.near)

Confirm that’s it in

ls -la .near-credentials/mainnet/

File content looks something like:

{
  "account_id": "bitwise.near",
  "public_key": "ed25519:***",
  "private_key": "ed25519:***"
}

Encrypt the content and store it under the inventory's host files directory under account_key.json - this is needed for the following Ansible task:

- name: "copy account_key.json to credentials directory"
  ansible.builtin.copy:
    src: "{{ inventory_dir }}/host_files/all/account_key.json"
    dest: "{{ neard_credentials_dir }}/{{ neard_account_id }}.json"
    owner: "{{ neard_user }}"
    mode: 0750
  notify:
    - restart neard

Create validator and node keys

near generate-key validator_key

This will saves the key to ~/.near-credentials/mainnet/validator_key.json.

This requires two important changes:

  • Change account_id to your desired pool name. Make sure to follow this format {pool_id}.{staking_pool_factory}. For example, if bitwise is the pool_id then the account_id is bitwise.pool.near because pool.near is the pool factory.
  • Change private_key to secret_key
{
  "account_id": "bitwise.pool.near",
  "public_key": "ed25519:***",
  "secret_key": "ed25519:****"
}

Encrypt the content and store it under the inventory's host files directory under validator_key.json

Generate a node key following the same process. You can set any account_id because, unlike the validator key, it isn't used for external purposes. Then encrypt and store it under the inventory's host files directory under node_key.json

Deploy staking pool contract

near call pool.near create_staking_pool '{"staking_pool_id": "<poolId>", "owner_id": "<accountId>", "stake_public_key": "<public key>", "reward_fee_fraction": {"numerator": 5, "denominator": 100}}' --accountId="<accountId>" --amount=4 --gas=300000000000000
  • pool_id: The staking pool name. The factory automatically adds its name to this parameter, creating {pool_id}.{staking_pool_factory}. For example, if you use bitwise, it becomes bitwise.pool.near on mainnet
    • VERY IMPORTANT: Make sure the final name matches the account_id in your validator_key.json file above
  • owner_id: The account ID you created in the previous step
  • stake_public_key: The public key from your validator_key.json file
  • reward_fee_fraction.numerator: The fee percentage your pool will charge (e.g., 5 over 100 means 5% fees)
  • amount=4: You must have at least 4 NEAR available, as this is the minimum required for storage in the new pool contract

Everything should now be set up. Here are some helpful references:

  • https://near-nodes.io/validator/compile-and-run-a-node#11-deploy-a-staking-pool
  • https://near-nodes.io/validator/staking-pool-migration

Submit a proposal (optional)

In order to obtain a validator seat, you must submit a proposal by sending a ping. A ping creates a new proposal and updates the staking balances for your delegators. You should issue a ping each epoch to keep reported rewards current.

This step is optional for two reasons: 1) you don't have enough stake yet when starting out, and 2) this process is already automated through a cron job.

near call <staking_pool_id> ping '{}' --accountId <accountId> --gas=300000000000000