Skip to content

Instantly share code, notes, and snippets.

@secretshardul
Last active July 16, 2022 11:13
Show Gist options
  • Save secretshardul/1f0a52a501f6b52827c135783bdee73d to your computer and use it in GitHub Desktop.
Save secretshardul/1f0a52a501f6b52827c135783bdee73d to your computer and use it in GitHub Desktop.
NEAR CLI and staking pool setup
# Update packages
sudo apt update && sudo apt upgrade -y
# Install nodejs
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install build-essential nodejs
PATH="$PATH"
# Install NEAR CLI
sudo npm i -g near-cli
# Log into the CLI for Shardnet. Follow the instructions.
export NEAR_ENV=shardnet
near login
# Deploy your staking pool. Say our account ID is validatoor.stakenet.near,
# then set the staking_pool_id as validatoor.
# The staking pool gets an address validatoor.factory.stakenet.near
near call factory.shardnet.near create_staking_pool \
'{"staking_pool_id": "<pool id>", "owner_id": "<accountId>", "stake_public_key": "<public key>", "reward_fee_fraction": {"numerator": 5, "denominator": 100}, "code_hash":"DD428g9eqLL8fWUxv8QSpVFzyHi1Qd16P8ephYCTmMSZ"}' \
--accountId="<accountId>" --amount=30 --gas=300000000000000
# We need to stake NEAR to match the seat price. To stake-
near call <staking_pool_id> deposit_and_stake \
--amount <amount> --accountId <accountId> --gas=300000000000000
# The staking contract must be pinged every epoch so as
# to not get kicked. Create a cron job to ping periodically
crontab -e # Opens Cron config
# Paste `0 */2 * * * NEAR_ENV=shardnet near call <staking_pool_id> ping '{}' --accountId <accountId> --gas=300000000000000 > ping_tx.txt`
# to ping every two hours
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment