Step 3. Activate your node & Deploy a new staking pool contract (3)

verse2
verse2
Published in
4 min readJul 22, 2022

Step 3. Activate your node & Deploy a new staking pool contract

In Step 3, we will go through how to activate a node and deploy a staking pool contract to receive NEAR tokens from delegators.

Authorize Wallet Locally
Log into the NEAR wallet.

near login

If you’re connected to testnet, please insert the following command.

echo ‘export NEAR_ENV=shardnet’ >> ~/.bashrc
source .bashrc

The browser may not open right after inserting the command. In this case, copy the URL and paste it to a new window.

If authorization is completed, you will see the following page.

Return to console and insert account ID in Terminal that is authorized.

If you see the message, ‘Logged in as {account id}.shardnet.near with public key {key string } successfully!’, you successfully logged in.

Generate the Validator Key File

Now, let’s create a validator key.

near generate-key <pool_id>
cp ~/.near-credentials/shardnet/<pool_id>.json ~/.near/validator_key.json

Insert account ID to <pool_id>. (letters before .shardnet.near)

Move to `~/.near/` and edit validator_key.json’ file.

Change the value of “account_id” to “<pool_id>.factory.shardnet.near”.
Change “private_key” to “secret_key”.

Now, Let’s run a node by using the systemd command in the background job.

(The command for foreground as follows.)

cd nearcore
./target/release/neard — home ~/.near run

For systemd setting, please insert the following in Terminal.

sudo vi /etc/systemd/system/neard.service

When the editor opens, please fill in as follows.

Description=NEARd Daemon Service
[Service]
Type=simple
User=<USER>
#Group=near
WorkingDirectory=/home/<USER>/.near ExecStart=/home/<USER>/nearcore/target/release/neard run StandardOutput=file:/home/<USER>/.near/neard.log StandardError=file:/home/<USER>/.near/nearderror.log
Restart=on-failure
RestartSec=30
KillSignal=SIGINT
TimeoutStopSec=45
KillMode=mixed

[Install]
WantedBy=multi-user.target

In <USER> section, type the current machine’s user name.
To find the current username, insert `whoami` in Terminal.
To enable neard, insert the following commands.

sudo systemctl enable neard

The commands for a start and reload neard as follows.

sudo systemctl start neard
sudo systemctl reload neard

You can check the node running log with the following commands.

sudo apt install ccze
journalctl -n 100 -f -u neard | ccze -A

For your reference, to check the standard output message from neard, you need to insert the following command.

cat ~/.near/nearderror.log

(In order to check current standard output message, you need to check the file name of nearderror.log.)

Activation is completed! You need to the deploy staking pool contract.

Insert the following commands.

near call factory.shardnet.near create_staking_pool ‘{“staking_pool_id”: “<pool_id>”, “owner_id”: “<pool_id>.shardnet.near”, “stake_public_key”: “<account_public_key>”, “reward_fee_fraction”: {“numerator”: 5, “denominator”: 100}, “code_hash”:”DD428g9eqLL8fWUxv8QSpVFzyHi1Qd16P8ephYCTmMSZ”}’ — accountId=”<pool_id>.shardnet.near” — amount=30 — gas=300000000000000

The following sections of command, you need to insert directly.

  • Pool ID: Staking pool name, the factory automatically adds its name to this parameter, creating {pool_id}.{staking_pool_factory}
    Examples: verse2.factory.shardnet.near
  • Owner ID: The SHARDNET account that will manage the staking pool.
  • Public Key: The public key in your validator_key.json file.
  • 5: The fee the pool will charge (e.g. in this case 5 over 100 is 5% of fees).
  • Account Id: The SHARDNET account deploying the staking pool.

If the transaction is completed successfully, check your pool in explorer.

You enter the proposal stage initially; you need to stake NEAR tokens more than Seat Price to be in the Active stage.

The command to stake is as follows.

near call <your_pool_id>.factory.shardnet.near deposit_and_stake — amount <stake_amount> — accountId <account_id>.shardnet.near — gas=300000000000000

When the stake transaction is completed, you need to Contract Ping.

near call <your_pool_id>.factory.shardnet.near ping ‘{}’ — accountId <your_pool_id>.shardnet.near — gas=300000000000000

A ping issues a new proposal and updates the staking balances for your delegators. A ping should be issued each epoch to keep reported rewards current.

Please refer to the document for more useful commands.

Well done! Now, the node is activated. You created the staking pool.

Let’s move on to Step 4. The final step.
https://medium.com/verse2/step-4-monitoring-node-status-4-8c218cdac881

This article is <The Stake Wars III set up : Step 3. Activate your node & Deploy a new staking pool contract> provided by verse2. If you would like to read the entire series, please see the list below. We recommend you read the articles sequentially.

Step 1. Create your shardnet wallet & Set up a server
Step 2. Set up your validator node
Step 3. Activate your node & Deploy a new staking pool contract
Step 4. Monitoring node status

verse2 is specialized in developing DeFi services and serious Crypto Investor at the same time. The team has in-depth knowledge and experience in the DeFi sector by developing and operating various protocols.

verse2 [Homepage | Twitter | Medium]

--

--

verse2
verse2
Editor for

Build, incubate, invest — Making all possible in the crypto. / verse2.io