Run Random Beacon in KEEP Network Testnet

Alex Novy
5 min readApr 12, 2020

--

This manual should guide you on how to set up a KEEP Network node for staking in Testnet. Please note that the Ethereum Ropsten network has been selected by the KEEP team to stake on.

Before you start please make sure that your environment meets all requirements:

  • Linux basic knowledge
  • VPS with 2 vCPU, 4 GiB RAM, 1 GiB HDD, Linux Ubuntu 18.04 LTS Bionic
  • Favorite SSH Client, I am using iTerm in MacOS
  • Google Chrome with MetaMask extension installed
  • Some luck

Let’s get started!

Create a wallet and export Keystore file

Go to https://myetherwallet.com and create a new wallet and select “By Keystore File”, set the password and write down this passphrase for later use. Click NEXT.

On the next page press “Download Keystore File”. As a result you will have a file like “UTC — 2020–04–11T21–11–10.519Z — 8f076df6434f7a8da4793118f9f8cf82f958e319”. Rename it like “keep_wallet.json” for later use in this guide.

Get tokens from the faucet, delegate stake and authorize contracts

Open keep_wallet.json with your favorite text editor and find the address section. Example “address”:”8f076df6434f7a8da4793118f9f8cf82f958e319". Write down the address and add a prefix 0x, Example 0x8f076df6434f7a8da4793118f9f8cf82f958e319.

In your browser paste URL: https://us-central1-keep-test-f3e0.cloudfunctions.net/keep-faucet-ropsten?account=0x8f076df6434f7a8da4793118f9f8cf82f958e319 (You have to change this address to your ether address). The KEEP faucet will issue a 300k KEEP tokens for the provided wallet. After a while, you will see text like:

Created token grant with 300000000000000000000000 KEEP for account: 0x8F076DF6434F7A8dA4793118f9F8cf82f958E319 You can manage your token grants at: https://dashboard.test.keep.network You can find us on Discord at: https://discord.gg/jqxBU4m

Load some test Ether to your wallet for tx fees on https://faucet.ropsten.be/ Then import your keep_wallet.json into MetaMask and change the MetaMask network to Ropsten Test Network. Additionally, you can use another faucet: https://faucet.metamask.io/

Let’s start the delegation process.

In your browser navigate to https://dashboard.test.keep.network/tokens. In the TOKENS section, you should see 300k granted tokens and also verify that you have 0 KEEP tokens staked.

Choose Grant ID, Token amount (300k in my case, you can stake less, but not less than 100k), Fill all the addresses fields with your ether wallet and press DELEGATE STAKE. MetaMask popup windows will ask you to confirm the transaction.

After a successful transaction, you will see 300k tokens staked. Nice, but also we need to authorize contracts in the AUTHORIZER section.

Here you have to press on the AUTHORIZE button for every contract!

Now it looks good and we can go to the next section of the guide.

Create Infura account and write down the RPC URLs

In your browser navigate to https://infura.io/register and create an account. Log in with your email and password. After that you have to create a project, let's call it KEEP.

On the SETTINGS page, you have to change ENDPOINTS to ROPSTEN like on the image below and copy both lines above for later use

https://ropsten.infura.io/v3/64d2f306afc347a0a75ecd510799f196 wss://ropsten.infura.io/ws/v3/64d2f306afc347a0a75ecd510799f196 

Configuration of the VPS

Login to your server using your favorite SSH client, add firewall rules for SSH and KEEP client and enable the firewall.

sudo ufw allow 22/tcp
sudo ufw allow 3919/tcp
yes | sudo ufw enable

After that, we have to install docker-engine on the server

sudo apt-get update
sudo apt-get remove docker docker-engine docker.io
sudo apt install docker.io curl -y
sudo systemctl start docker
sudo systemctl enable docker
sudo docker --version

If you see a message like Docker version 18.09.7, build 2d0083d then you are good to go.

Create all directories and files used by KEEP client

In your home directory run commands below

mkdir -p $HOME/keep-client/config
mkdir -p $HOME/keep-client/keystore
mkdir -p $HOME/keep-client/persistence
# Get your server's IP
export SERVER_IP=$(curl ifconfig.me)
# Change with your ID from Infura.
export INFURA_PROJECT_ID="64d2f306afc347a0a75ecd510799f196"
# Change with your ETH Wallet.
export ETH_WALLET="0x8f076df6434f7a8da4793118f9f8cf82f958e319"
cat <<EOF >>$HOME/keep-client/config/config.toml
# Ethereum host connection info.
[ethereum]
URL = "wss://ropsten.infura.io/ws/v3/$INFURA_PROJECT_ID"
URLRPC = "https://ropsten.infura.io/v3/$INFURA_PROJECT_ID"
# Keep operator Ethereum account.
[ethereum.account]
Address = "$ETH_WALLET"
KeyFile = "/mnt/keystore/keep_wallet.json"
# Keep contract addresses configuration.
[ethereum.ContractAddresses]
KeepRandomBeaconOperator = "0x440626169759ad6598cd53558F0982b84A28Ad7a"
TokenStaking = "0xEb2bA3f065081B6459A6784ba8b34A1DfeCc183A"
KeepRandomBeaconService = "0xF9AEdd99357514d9D1AE389A65a4bd270cBCb56c"
# Keep network configuration.
[LibP2P]
Peers = ["/dns4/bootstrap-0.test.keep.network/tcp/3919/ipfs/16Uiu2HAmCcfVpHwfBKNFbQuhvGuFXHVLQ65gB4sJm7HyrcZuLttH","/dns4/bootstrap-1.test.keep.network/tcp/3919/ipfs/16Uiu2HAm3eJtyFKAttzJ85NLMromHuRg4yyum3CREMf6CHBBV6KY","/dns4/bootstrap-2.test.keep.network/tcp/3919/ipfs/16Uiu2HAmNNuCp45z5bgB8KiTHv1vHTNAVbBgxxtTFGAndageo9Dp","/dns4/bootstrap-3.test.keep.network/tcp/3919/ipfs/16Uiu2HAm8KJX32kr3eYUhDuzwTucSfAfspnjnXNf9veVhB12t6Vf","/dns4/bootstrap-4.test.keep.network/tcp/3919/ipfs/16Uiu2HAkxRTeySEWZfW9C83GPFpQUXvrygmZryCN6DL4piZrbAv4"]
Port = 3919
# Override the node’s default addresses announced in the network
AnnouncedAddresses = ["/ip4/$SERVER_IP/tcp/3919"]
# Storage is encrypted
[Storage]
DataDir = "/mnt/persistence"
EOF

After that copy content of your keep-wallet.json and paste a wallet file on the server

nano $HOME/keep-client/keystore/keep_wallet.json

Run docker container and check the logs

I’ve built a docker image and it will be used to run our node.

# You can set password permanently in VPS user's profile
echo "export KEEP_CLIENT_ETHEREUM_PASSWORD=your_eth_wallet_password" >> ~/.profile
# OR use a temporary environment variable
export KEEP_CLIENT_ETHEREUM_PASSWORD="your_eth_wallet_password"
sudo docker run -dit \
--restart always \
--volume $HOME/keep-client:/mnt \
--env KEEP_ETHEREUM_PASSWORD=$KEEP_CLIENT_ETHEREUM_PASSWORD \
--env LOG_LEVEL=debug \
--name keep-client \
-p 3919:3919 \
novy4/keep-client:latest --config /mnt/config/config.toml start
# To access the logs
sudo docker logs keep-client -f
# To exit the logs
CTRL+C or COMMAND+C

Scroll up the logs, you should see KEEP word in the console, It means that we’ve successfully started our node!

UPDATE: To get a new version from the docker hub and to restart your node follow next simple steps:

export KEEP_CLIENT_ETHEREUM_PASSWORD="your_eth_wallet_password"

sudo docker stop keep-client
sudo docker rm keep-clientsudo docker images -a | grep "keep-client" | awk '{print $3}' | xargs sudo docker rmisudo docker pull novy4/keep-client:latestsudo docker run -dit \
--restart always \
--volume $HOME/keep-client:/mnt \
--env KEEP_ETHEREUM_PASSWORD=$KEEP_CLIENT_ETHEREUM_PASSWORD \
--env LOG_LEVEL=debug \
--name keep-client \
-p 3919:3919 \
novy4/keep-client:latest --config /mnt/config/config.toml start
# To access the logs
sudo docker logs keep-client -f
# To exit the logs
CTRL+C or COMMAND+C

That’s all folks, happy staking!

--

--