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.
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
# 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
- 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
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:
Learn more about Hive Power: