HOPRd Diablerets Release Tutorial

Amira Bouguera
HOPR
Published in
10 min readJun 24, 2021

Our latest release, Diablerets, is now available for testing! This tutorial will walk you through how to install and run a node and let you try some basic commands. If you have any questions, don’t hesitate to ask us on our Telegram group.

Disclaimer: This is an early release and we cannot guarantee the security of funds. There is currently no reward for running a node. Therefore, please add only the minimal funds needed for testing (maximum 1xDAI and 10wxHOPR).

What will you learn?

This tutorial will walk you through how to:

  • Install and use HOPRd on your computer
  • Fund your node with xDai and HOPR
  • Withdraw xDai from your node and send them to another one
  • Communicate with other peers by sending and receiving anonymous messages
  • Open, fund, and close communication channels
  • Earn and redeem tickets and turn them into HOPR tokens
  • Run two nodes and communicate using those nodes
  • Open channels and send messages to a public node

Even if you’ve run a node before, we recommend following all the instructions below, as things may have changed considerably since the last time you ran a node.

Installation

In order to use the HOPR network, you need to install a HOPR node. You can do this direct to your device or using a virtual private server (VPS).

Your node takes the form of a node.js process that implements the HOPR protocol. This is known as hoprd.

IMPORTANT: The HOPR node currently works on MacOS, Linux, and AVADO boxes. Windows support will be re-added in a future release. Before installing a node, make sure to complete the following steps.

Linux

  1. Update your Linux OS so it has the latest packages using the following command:
sudo apt-get update

2. Install thegcc, g++, make compiling packages which are required for a node:

sudo apt install gcc g++ make

Mac OS X

  1. Make sure you have theXCode command-line utility:
xcode-select --install

2. Check whether you have Homebrew, the OSX package manager, and install it if it is not installed yet.

Installing hoprd

There are several ways to install hoprd. Unlike in some earlier releases which involved downloading binaries, all installation for HOPR Diablerets occurs via your terminal. After entering the commands given below into your terminal, you will then access your HOPR node(s) via your browser.

NPM

First you need to install NVM. To do so, follow these steps. After installing NVM, please check that it’s correctly installed using the command

nvm ls

Now you can install node.js v14, by running this command:

nvm install v14

After installing, make v14 the default by running this command:

nvm use v14

IMPORTANT: Please only use node.js v14 for now. Other versions are not currently supported. If you’re a MacOS M1 user, make sure to follow these nvm instructions.

To install a node, enter the following commands:

mkdir MY_NEW_HOPR_TEST_FOLDER
cd MY_NEW_HOPR_TEST_FOLDER
npm install @hoprnet/hoprd@1.72

Your node will now install. This may take a few minutes.

If the installation fails, run the following command and try again:

npm install --unsafe-perm=true @hoprnet/hoprd@1.72

Once your node is installed, run the following command:

DEBUG=hopr* npx hoprd --init --admin --host=0.0.0.0:9092 --adminPort=3000 --password='' --identity=./alice-identity --data=./alice-db

Docker

To install a node using Docker, you first need to install Docker on your machine if you don’t have it already. To install Docker, follow these steps.

Now you should download the hoprd image and run it as follows:

docker pull gcr.io/hoprassociation/hoprddocker run --pull always -ti -v $HOME/.hoprd-db-alice:/app/db -p 9091:9091 -p 3000:3000 gcr.io/hoprassociation/hoprd:latest-kiautschou --identity /app/db/.hopr-identity --password switzerland --init --announce --host "0.0.0.0:9091" --admin --adminHost 0.0.0.0 --adminPort 3000

AVADO

You can run the HOPR Diablerets release on your AVADO box.

IMPORTANT: Before installing a new version of HOPR node, withdraw any funds on your node to your personal ERC20 wallet, otherwise your funds will be lost! If you have issues withdrawing your funds, please reach out to community support.

Install process: While connected to your AVADO network or via a VPN, go to the following link. This will show a new package version. Just click the install button and wait until you see the success message. This may take some time.

Testing Your Node

If you’ve made it this far, you have a HOPR node running on your computer. Congratulations! Now let’s start to test.

You can access your node via your browser. Head to http://localhost:3000/ to see it.

Unfortunately, what you’ll see for now is an error message like the one shown below:

That’s because before we can use a node, you need to fund it. HOPR nodes need two kinds of funds: HOPR tokens and the native token of the chain HOPR is running on. In this case, the tokens are wxHOPR and xDAI.

You can see the xDAI address of your node in the warning message. This address is unique to your node and it’s where you’ll need to send funds.

Usually we tell people to follow these steps to receive xDai tokens on their addresses, but for this release we’re funding nodes so you can test our protocol.

Please ask for funds on our Telegram group by sending us your address node address and you will receive funds shortly.

Once your node receives the xDAI and wxHOPR tokens, you’ll be able to use hoprd. From now on, proceed in your browser, but keep your terminal running.

To get a list of all available commands, type help. You can play around and test all these commands if you want, but if you’d like a more structured experience, we’ve provided a list of commands you can try in the HOPRD test sheet.

One of the new features in this release is the identity function, which lets you assign different identities to different nodes (don’t confuse this with the “alias” function, which is a way to make managing node addresses easier — an identity is a completely separate node).

You can try this out by running TWO nodes from the same device and sending messages between them.

Advanced Task: Playing Hide and Seek

Alice and Bob decide to hide from each other and keep sending anonymous messages to one another. To play this game, you’ll need to run two local nodes on your computer. The first node will be called Alice and the second will be called Bob.

You’ll need to use two different terminal/cmd clients and assign a different port to each node. Below we will be using ports 3000 & 3010. Close your currently running node before you start this.

Unfortunately, AVADO users won’t be able to do this part solely on their AVADO box. If you’re using AVADO, you can keep using that node as Alice and set up a second node as Bob using one of the install methods explained above.

NPM

If you installed via NPM:

Alice’s node :

DEBUG=hopr* npx hoprd --init --admin --host=0.0.0.0:9092 --adminPort=3000 --password='' --identity=./alice-identity --data=./alice-db

Bob’s node:

DEBUG=hopr* npx hoprd --init --admin --host=0.0.0.0:9093 --adminPort=3010 --password='' --identity=./bob-identity --data=./bob-db

Docker

If you installed via Docker, use the following commands:

Alice’s node :

docker run --pull always -ti -v $HOME/.hoprd-db-alice:/app/db -p 9091:9091 -p 3000:3000 gcr.io/hoprassociation/hoprd:latest-kiautschou --identity /app/db/.hopr-identity --password switzerland --init --announce --host "0.0.0.0:9091" --admin --adminHost 0.0.0.0 --adminPort 3000

Bob’s node:

docker run --pull always -ti -v $HOME/.hoprd-db-bob:/app/db -p 9092:9092 -p 3010:3010 gcr.io/hoprassociation/hoprd:latest-kiautschou --identity /app/db/.hopr-identity --password switzerland --init --announce --host "0.0.0.0:9092" --admin --adminHost 0.0.0.0 --adminPort 3010

VPS Users

If you’re running your nodes on a VPS, make sure you’ve logged in to your server with the port forwarding feature. This will let you log in as the same server user and have two running nodes.

1st terminal/cmd client:

ssh -L 3000:127.0.0.1:3000 <root or username>@<Your_server_ip>

2nd terminal/cmd client:

ssh -L 3010:127.0.0.1:3010 <root or username>@<Your_server_ip>

Now that both your nodes are running, you can start playing. You’ll learn how to send messages via another node and watch that node earn tickets, which you can redeem for HOPR.

Start by opening http://localhost:3000/ and http://localhost:3010/ in different tabs to access both nodes. The Alice node will be the node you set up earlier, but the Bob node is new, with a new address. It will need to be funded.

Using the withdraw command, withdraw xDAI from your first node (Alice) to the second node (Bob). You may not be able to withdraw HOPR in the same way (this is a known bug that we’re looking into), but that doesn’t matter. Only Alice needs HOPR for what comes next.

After both nodes are funded, you can now open, close channels and send messages.

  1. Start by setting up an alias for each node. Setting an alias makes it easier to interact with other nodes instead of using their full HOPR addresses each time.

To find your node’s HOPR addresses, use the command address
in each node to see their xDai and HOPR addresses.

Now use the following commands to set an alias for Bob in Alice’s node and vice versa:

Alice’s command

 alias [Bob’s HOPR address] Bob

Bob’s command

alias [Alice’s HOPR address] Alice

2. Alice is now able to send messages to Bob as follows:

send ,Bob hello

It’s important not to forget the comma “,” otherwise the message won’t be sent and you’ll get an error.

Bob’s node will receive the message ‘hello’, but there’ll be no indication of the sender’s identity. HOPR allows full anonymity, so this is a feature, not a bug!

Still, in general it’s useful if the people we’re messaging know who they’re talking to. Alice can make her identity known to Bob by changing her settings:

settings includeRecipient true

After doing this, try sending another message from Alice to Bob and you will see that the message will be identified as coming from Alice’s node.

3. Now, use Alice’s nodes to open a channel with Bob and fund that channel with some HOPR using this command:

open Bob 0.01

The minimum amount required to fund a channel is 0.1 HOPR. This is basically the payout for 1 ticket. However, in general it’s recommended to fund the channel with enough HOPR to cover a few tickets.

Opening a channel requires interacting with a smart contract on the blockchain, so you’ll need to wait a bit for the channel to open. When that happens you’ll see a message saying “Successfully opened channel”.

4. You can now verify that this channel exists and is open by writing the command channels in both nodes. The channels command displays all currently open channels. For example :

Channel: 0xa0b92e6d400f556c2139661e799ccc867da28ce079c382388086882806e34dd8
CounterParty: Z35Qj
Status: OPEN
Total Balance: 0.01 HOPR
My Balance: 0.01 HOPR

This means Alice has an open channel with node Z35Qj. The channel is opened and the balance available in it is 0.01 HOPR. Alice’s balance is the same, since she was the one funding this channel.

On Bob’s side, you’ll see a similar message displayed. But here Bob’s balance will equal 0, since he hasn’t funded the channel.

Alice can now send messages to herself using Bob as a relay node. This will allow him to earn tickets which can then be redeemed into HOPR tokens.

5. First verify in Bob’s node whether Bob has any tickets. You will see something like this:

admin > tickets

finding information about tickets…
Tickets:
- Pending: 0
- Unredeemed: 0
- Unredeemed Value: 0 HOPR
- Redeemed: 0
- Redeemed Value: 0 HOPR
- Losing Tickets: 0
- Win Proportion: 0%

6. In Alice’s node, send a message to yourself (Alice, represented by the default alias “me” which always identifies your own node) via Bob’s node using the following command:

send Bob,me what’s up

Now use the tickets command again and you should see that unredeemed tickets changed from 0 to 1.

7. You can now use Bob’s node to redeem the ticket he earned or he can continue acting as a relayer, earning more tickets and redeeming them all at once. You can keep doing this, repeating the previous step, until Alice runs out of HOPR to pay for the messages. When you decide to redeem, use the command redeemTickets in Bob’s node to do so.

7. Remember how much balance Bob had in this channel? 0
Type the channels command again after redeeming tickets and you will see that Bob’s balance in the channel has increased.

8. Time to say goodbye to Alice and close this channel. To close it, use Bob’s node and type:

close Alice

Wait a few minutes and then call the same function again and the channel will be completely closed.

During this cool-off period, make sure to redeem all the tickets Bob’s node earned, because after the channel is closed, this process will not be possible anymore.

Want to continue playing?

Using identities is a great way to test the new function and run tests on a single device. But you can also send messages to other users! You can find a list of all publicly available peers that you can open channels with by using the command peers.

Choose one of those peers, preferably one with quality 1, and then ping them to check that they are online using ping [peer’s HOPR address].

After checking that the peer is online, you can now follow the same steps as between Alice and Bob.

Thanks for participating, we hope you had a fun experience and learned more about the HOPR protocol. You can now call yourself a proud user of HOPRd.

Yours Truly,

The HOPR team

Keep up to date with the progress of the HOPR protocol, our demos, our papers and so much more!

Website: https://www.hoprnet.org
Twitter: https://twitter.com/hoprnet
Telegram: https://t.me/hoprnet
Forum: https://forum.hoprnet.org

--

--

Amira Bouguera
HOPR
Writer for

Mathematician, Cryptographer and Blockchain Engineer