Press enter to see results or esc to cancel.

Installing Raiden on a Raspberry Pi 3

The integration of IoT and Ethereum is emerging as a powerful solution for data management using the blockchain technology. Unfortunately, at present the speed and storage requirements of a typical IoT application exceed the capabilities of the public Ethereum blockchain. The reasons are mainly two, the former is the block time, currently too high to be able to track IoT data. The latter is the gas cost: each transaction has a cost on Ethereum, thus the global amount of gas paid for all the transactions would be highly expensive. As a consequence, currently an interface among the “fast” world of IoT and the “slow but decentralized” one of Ethereum is needed.

Raiden (https://raiden.network/) is a framework for the fast management of transactions. Being built as a off-chain solution, it provides a fast exchange of data among the Raiden nodes using the state channels technology, avoiding the long response time and the gas costs related to on-chain transactions. On the other hand, the starting and the end points of each Raiden state channel are tracked on the blockchain (currently only on Ropsten network) with the related initial and final balances.

In this article the procedure to install Raiden (https://raiden.network/) on a Raspberry Pi 3 is explained. I chose this well-known hardware platform because it is widely used for IoT applications. It is assumed that Raspbian Jessie 8 is the operating system running on the Raspberry Pi 3.

Raspberry Pi 3 used for the Raiden installation

The installation steps can be summarized into the following list. For each point an explanation is reported together with the related bash commands.

  • Step1: Installation of libraries and tools required by the following steps.
# sudo apt-get install geth pip cmake libboost-all-dev
  • Step2: Creation of a temporary swap file to avoid memory overflows. The available memory in a Raspberry Pi 3 is 1 GB and ~20% of RAM is used by Raspbian and other processes. The remaining RAM is not sufficient for the following compilation processes, so a swap space has to be used. I performed some tests without swap, but I always encountered memory overflows. In the example below I created a swap file of 0.5 GB, enough for the compilations. Consider that after the following two steps the swap file can be deleted and so the space reallocated to the root partition.
# sudo dd if=/dev/zero of=/swap bs=1M count=512
# sudo mkswap /swap
# sudo swapon /swap
  • Step3: Installation from source of the tool Z3 (https://github.com/Z3Prover/z3), required by the solc compiler. On the Raspberry Pi this process was very long, about some hours.
# mkdir ~/software
# cd ~/software
# wget https://github.com/ethereum/solidity/releases/download/v0.4.16/solidity_0.4.16.tar.gz
# unzip z3-master.zip
# cd z3-master
# python scripts/mk_make.py
# cd build
# make
# sudo make install
  • Step4: Installation from source of the Solidity compiler (solc). This software is required by Raiden but, unfortunately, currently no binary package is available for the hardware architecture of Raspberry Pi 3 (armv7). This is the cause of the compilations and, definitely, the main reason of this article. Under the computational point of view, also this step has a meaningful duration, although faster than Step3.
# cd ~/software
# git clone --recursive https://github.com/ethereum/solidity.git
# cd solidity-0.x.y
# scripts/install_deps.sh
# scripts/build.sh
  • Step5: Installation of Raiden. The final step is much simpler than Step3 and Step4, being Raiden a set of Python scripts, thus no compilation is required.
# cd ~/software
# git clone https://github.com/raiden-network/raiden.git
# cd raiden-x.y
# sudo pip install --upgrade -r requirements.txt
# sudo python setup.py develop

Now all the tools are properly installed and we can start using them. Currently Raiden network is available only on Ropsten network, thus the first passage is to start geth in light mode (the unique I realized to launch on a Raspberry Pi) and sync it to the test network.

# geth --testnet --light --v5disc --cache 1024 --rpc --rpcport 8545 --rpcaddr 0.0.0.0 --rpccorsdomain "*" --rpcapi "eth,net,web3" console

Once the node is synced, a Ropsten account has to be created and an amout of at least 0.1 ETH assigned to it. After that we can start Raiden as shown below:

# raiden --keystore-path  ~/.ethereum/testnet/keystore

To test if Raiden has been successfully installed, it is possible to query its REST interface with the following command and to check the result:

# curl -X GET http://127.0.0.1:5001/api/1/tokens
[
“0x2d3632ea6f06b2aad472d3f8cf49eefd98b96d71”,
“0x9aba529db3ff2d8409a1da4c9eb148879b046700”,
“0x53c9884988058dd583d816aae9976775fb94b4a4”,
“0x25a8004bd889a0c31e9382f50272e596bf5d8a88”,
“0xa87d050d6ebbbabf1095d50c493a41a51f57a44e”,
“0xc67f4b9a7592b43a474df44939c0630e24c414dd”,
“0xbaa4589a1a49f722293360e352fed692e741442d”,
“0xd7f14d6bff222c650e1ebd60fc4673c737c40134”,
“0xd73860f000e675c15ca8b060da0128f5473b4d96”,
“0xc90e57fe7da3b8f6c86e20f640dd9785c52906f7”,
“0x683aca737b264ae43c91ea3196dd017b186b0e0b”,
“0x78a9b00be464351471f73d3c26485fe0434c92dc”,
“0xcd0d53a45cdda84fee9edb5874a7897ebdc9624e”,
“0xf025f2ddb226684ab66df9fdf3928d053a237dce”,
“0x79fc539d3207a172959d1cb6a73fae18621e96c8”,
“0x3791165e88164c0256a652d746a4a60b11eacb93”,
“0x583cbbb8a8443b38abcc0c956bece47340ea1367”,
“0x4d55ca1059f95a77f5a88a80fff918f095136c2b”,
“0x33511d2c9c1f05036e4b2aea602ac2a5028c113a”,
“0x501a3ea063a97fcc76afba2b1779864c98ad89c8”,
“0x0f114a1e9db192502e7856309cc899952b3db1ed”,
“0xe987ea391d45b837f12601e0a8298779dc17d903”
]

If you find something similar, you have Raiden working on your Raspberry Pi 3, have fun!


At Hive Power we are using blockchain-enabled embedded devices to create energy sharing communities where all participants are guaranteed to benefit from the participation.

Join Hive Power Telegram chat:
https://t.me/hivepower

Learn more about Hive Power:

%d bloggers like this: