Skip to main content

Setup & Configuration

Install Docker​

Install Docker Engine from official site

Create a mnemonic​

This mnemonic will be used only for Restake.app.

First, download and install the Sentinel dVPN CLI:

wget https://github.com/sentinel-official/sentinel-dvpncli/releases/tag/v0.3.2/sentinelcli_linux_x86_64.tar.gz
tar xvzf sentinelcli_linux_x86_64.tar.gz
sudo mv ${HOME}/sentinelcli /usr/local/bin

Now, create a new key and mnemonic by running:

sentinelcli keys add keyname

You’ll be asked to set a passphrase. Make sure to write down and safely store both:

  • The mnemonic phrase
  • The operator address

Finally, don’t forget to add funds to the operator address before using it.

Clone and configure Restake​

Clone the repository and copy the sample .env file ready for your mnemonic

git clone https://github.com/eco-stake/restake.git

Go into Restake directory

cd restake

Rename the file .env.sample to .env, then open it

mv .env.sample .env
nano .env

Add your mnemonic:

MNEMONIC=my hot wallet seed words here that has minimal funds

Pre-build your Docker containers with the following commands:

docker compose run --rm app npm install
docker compose build --no-cache

Navigate to the src directory

cd src/

Rename the file .networks.local.json to .networks.local.json.sample, then open it:

mv networks.local.json.sample networks.local.json
nano networks.local.json

Replace the file with the following code block. For the restUrl field, choose your preferred RPC endpoint from this list:

.networks.local.json
{
"sentinel": {
"prettyName": "Sentinel 881",
"restUrl": [
"https://api.sentineldao.com:443"
],
"autostake": {
"correctSlip44": false,
"delegationsTimeout": 300000,
"queryTimeout": 300000
}
}
}

If it doesn’t work, try changing the restURL field or use the default configuration below.

.networks.local.json (default config)
{
"sentinel": {
"prettyName": "Sentinel 881",
"autostake": {
"correctSlip44": false,
"batchPageSize": 50,
"delegationsTimeout": 50000
}
}
}

Running the script​

Run this command adding as last word sentinel which is the network we are going to enable

sudo docker compose run --rm app npm run autostake sentinel

You should see something like that:

> restake@0.1.0 autostake
> node scripts/autostake.mjs sentinel

[09:30:19.711] βš›
[09:30:20.268] Loaded Sentinel 881
[09:30:20.458] Bot address is sent1eyhgvkqu48luluafpfn4myg5jr04g6zje9zkkf
[09:30:20.459] Not an operator
[09:30:20.460] Autostake finished

The message "Not an Operator" is fine as we have to submit our operator to Chain Registry

Setting up a timer to run the script on a schedule​

You should setup your script to run at the same time each day. We will use the methos based on systemd-timer which allows to run a one-off service with specified rules. This method is arguably preferable to crontab, which we will not cover.

Create a systemd unit file​

The unit file describes the application to run. We define a dependency with the timer with the Wants statement. Create the restake.service file

sudo nano /etc/systemd/system/restake.service

Add the following code block

restake.service

/etc/systemd/system/restake.service
[Unit]
Description=restake service with docker compose
Requires=docker.service
After=docker.service
Wants=restake.timer

[Service]
Type=oneshot
WorkingDirectory=/home/trinity/restake
ExecStart=/usr/bin/docker compose run --rm app npm run autostake sentinel

[Install]
WantedBy=multi-user.target

Create a systemd timer file​

The timer file defines the rules for running the restake service every hour. All rules are described in the systemd documentation.

Create the restake.timer file

sudo nano /etc/systemd/system/restake.timer

Add the following code block

restake.timer

/etc/systemd/system/restake.timer
[Unit]
Description=Restake bot timer

[Timer]
AccuracySec=1min
OnCalendar=*-*-* *:00:00

[Install]
WantedBy=timers.target

Enable and start the 2 created services​

sudo systemctl enable restake.service
sudo systemctl enable restake.timer
sudo systemctl start restake.timer

Check the restake.timer status

With systemctl

sudo systemctl status restake.timer

Or with journalctl in real time:

sudo journalctl -u restake.service -f --output=cat

You should see something like that:

● restake.timer - Restake bot timer
Loaded: loaded (/etc/systemd/system/restake.timer; enabled; vendor preset: enabled)
Active: active (waiting) since Thu 2023-07-13 12:24:40 UTC; 4min 19s ago
Trigger: Thu 2023-07-13 13:00:00 UTC; 30min left
Triggers: ● restake.service

Jul 13 12:24:40 trinity-management systemd[1]: Started Restake bot timer.

Check the restake.service status

sudo systemctl status restake.service

You should see something like that:

● restake.service - restake service with docker compose
Loaded: loaded (/etc/systemd/system/restake.service; enabled; vendor preset: enabled)
Active: inactive (dead)
TriggeredBy: ● restake.timer

Now you are ready to submit your operator to Restake.app