Skip to content

johnpaul199812/NEAR-STAKEWARS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 

Repository files navigation

NEAR-STAKEWARS

#How to set up a Shardnet Node for NEAR STAKEWARS

video guide: https://youtu.be/fETzE8QWPPY

#Get a vps server at digitalocean with this link https://m.do.co/c/3d3f5749db15, 100$ in free credits to buy server image

#once yours vps is ready,you can ssh login with the droplet console image or you can use mobaxterm to ssh login, download mobaxterm here https://mobaxterm.mobatek.net/download.html

#now register with this form for participating in the testnet https://nearprotocol1001.typeform.com/to/Z39N7cU9

#Challenge 001#

#make sure the linux machine is up-to-date

sudo apt update && sudo apt upgrade -y

#Before you start, you may want to confirm that your machine has the right CPU features.

lscpu | grep -P '(?=.*avx )(?=.*sse4.2 )(?=.*cx16 )(?=.*popcnt )' > /dev/null \
  && echo "Supported" \
  || echo "Not supported"

#install Node JS and NPM

curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - 
sudo apt install build-essential nodejs 
PATH="$PATH"

#install NEAR-CLI

npm install -g near-cli

#Set up the environment

export NEAR_ENV=shardnet
echo 'export NEAR_ENV=shardnet' >> ~/.bashrc

#Challenge 002#

#Install developer tools

sudo apt install -y git binutils-dev libcurl4-openssl-dev zlib1g-dev libdw-dev libiberty-dev cmake gcc g++ python docker.io protobuf-compiler libssl-dev pkg-config clang llvm cargo

#Install Python pip

sudo apt install python3-pip

#Set the configuration

USER_BASE_BIN=$(python3 -m site --user-base)/bin

export PATH="$USER_BASE_BIN:$PATH"

#Install Building env

sudo apt install clang build-essential make

#Install cargo and rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env

#Now download and build binary

git clone https://github.com/near/nearcore 
cd nearcore 
git fetch 
git checkout 1897d5144a7068e4c0d5764d8c9180563db2fe43
cargo build -p neard --release --features shardnet

#check the version

~/nearcore/target/release/neard --version

#now you have to initialize the working directory, delete old files and download new config file and new genesis.json

~/nearcore/target/release/neard --home ~/.near init --chain-id shardnet --download-genesis 
rm ~/.near/config.json ~/.near/genesis.json
wget -O ~/.near/config.json https://s3-us-west-1.amazonaws.com/build.nearprotocol.com/nearcore-deploy/shardnet/config.json 
wget -O ~/.near/genesis.json https://s3-us-west-1.amazonaws.com/build.nearprotocol.com/nearcore-deploy/shardnet/genesis.json

#Run the node

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

image

#you can see log outputs in your console. Your node should be able to find peers, download headers to 100%, and then download blocks.

#Activating the node as validator

#Now you will need to create a wallet https://wallet.shardnet.near.org/

#Authorize Wallet Locally

near login

image

#Grant Access to Near CLI

image

image

#paste your account id,e.g johnpaulnodes.shardnet.near

image #you will see this, its fine

image

#now paste your account id in the Cli and press ENTER

image

image

#Copy your wallet json and make some changes

cd ~/.near-credentials/shardnet/
cp <wallet.json> ~/.near/validator_key.json

#NOTE:<wallet.json> ---> is your wallet name file e.g in mine johnpaulnodes.shardnet.near.json

#you should be able to open this file,copy the content

#now do this

nano validator_key.json

#then paste the content here, then edit the account ID and Private Key parameter accordingly

#should look like this

image

#File content must be in the following pattern

{
"account_id":"johnpaulnodes.factory.shardnet.near",
"public_key":"ed25519:72wzgPZgDx2SgE7Nffd6xfXSe4RNv57JE2ZXZ8xGH",
"secret_key":"ed25519:55Xbx9zd7pbjDjmmWhMav7ozmreJWyYyiKBVFboG8UjCegUQkxH8bwQkeEuJHxD"
}

Secret here isn't real 🤣🤣🤣

#then exit with CTRL+O press Enter, then CRTL+X

#Create a service file

sudo tee /etc/systemd/system/neard.service > /dev/null <<EOF
[Unit] 
Description=NEARd Daemon Service 
[Service] 
Type=simple 
User=$USER
#Group=near 
WorkingDirectory=$HOME/.near 
ExecStart=$HOME/nearcore/target/release/neard run     
Restart=on-failure 
RestartSec=30 
KillSignal=SIGINT 
TimeoutStopSec=45 
KillMode=mixed 
[Install] 
WantedBy=multi-user.target 
EOF

#start the service and see logs

sudo systemctl daemon-reload 
sudo systemctl enable neard 
sudo systemctl start neard
journalctl -u neard -f

image

#now running

#Challenge 003#

#Mounting a staking pool

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

#NOTE: Change , , , parameters e.g mine near call factory.shardnet.near create_staking_pool '{"staking_pool_id": "johnpaulnodes", "owner_id": "johnpaulnodes.shardnet.near", "stake_public_key": "ed25519:72wzgPZgDx2SXSe4ba7RNv57JE2ZXZ8xGH", "reward_fee_fraction": {"numerator": 5, "denominator": 100}, "code_hash":"DD428g9eqLL8fWUxv8QSpVFzyHi1Qd16P8ephYCTmMSZ"}' --accountId="johnpaulnodes.shardnet.near" --amount=30 --gas=300000000000000

#if its sucessful

#check your pool by running

near proposals

#your node should be here

image

#you can deposit and stake more depending on ur wallet balance

near call johnpaulnodes.factory.shardnet.near  deposit_and_stake --amount 1200 --accountId johnpaulnodes.shardnet.near --gas=300000000000000

#NOTE: johnpaulnodes.factory.shardnet.near and johnpaulnodes.shardnet.near should be replace by yours

#Challenge 004#

#monitor your node and be a validator confirming transactions on testnet and get >95% of uptime.

#Log Files, the command below will show you the log file

journalctl -n 100 -f -u neard | ccze -A

image

#Validator: A “Validator” will indicate you are an active validator

#97 validators: Total 97 validators on the network

#33 peers: You current have 33 peers. You need at least 3 peers to reach consensus and start validating

#Check your node version

curl -s http://127.0.0.1:3030/status | jq .version

#NOTE:install jq if you dont have it

sudo apt install curl jq

#Challenge 006#

#Create a cron task on the machine running node validator that allows ping to network automatically

#Create a new crontab, running every 5 minutes

crontab -e 
*/5 * * * *  export NEAR_ENV=shardnet && near call johnpaulnodes.factory.shardnet.near ping '{}' --accountId johnpaulnodes.shardnet.near --gas=300000000000000

#NOTE: replace johnpaulnodes.factory.shardnet.near and johnpaulnodes.shardnet.near with yours

#check crontab to see if it is running

crontab -l

#check wallet on web to see recent activity in interval of 5 minutes

image

About

How to set up a Shardnet Node for NEAR STAKEWARS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published