How to get the JURA wallet balance in Raspberry Pi

Jura Protocol Media
6 min readDec 6, 2020

Raspberry Pi is a single-card computer with hardware controllable on the ARM platform. It can run a complete linux system, and can communicate with external devices through software control pins to input and output levels and signals.

Today we demonstrate how to use Raspberry Pi 4 to get the balance of JURA wallet through JURA’s pythonSDK.

Part 1: Required hardware and tools

The tools you need to prepare are as follows, including 7 hardware and 2 software:
1. Raspberry Pi 4 single-card computer 1
2. SD card 1 (the Raspberry Pi system is installed in the SD card)
3. SD card reader (used to insert the SD card into the USB of the computer) 1
4. 1 network cable (to connect the Raspberry Pi to the Internet)
5. USB to TTL 1 (connect Raspberry Pi and computer through serial port)
6. DuPont female-to-female 4 lines (connect USB to TTL and Raspberry Pi pins)
7. 1 PC computer (for programming and operation)
8. Etcher burning software
9. Raspberry Pi image file

Part 2: Flash the Raspberry Pi system to the SD card

Download device buring software from https://www.balena.io/etcher/

Then download the image file from official Raspberry Pi website: https://www.raspberrypi.org/downloads/raspbian/

After decompression, the image file with the extension img is obtained. Use Etcher to select the image, insert the SD card into the card reader, and insert it into the computer USB port.

Select the USB flash drive to be burned in etcher, and click the blue button named Flash! to burn into the device.

Part 3: Start the Raspberry Pi.

After the SD card is successfully burned, remove it from the card reader and plug it into the Raspberry Pi, as shown in the picture.

Plug in the Internet cable, turn on the power, and the Raspberry Pi will start.

Note: The Raspberry Pi does not have a power switch. Plug in the USB adapter and turn on the power.

Part 4: Computer log in to Raspberry Pi through serial port

The serial port is a mechanism that uses 2 wires for communication, plus a total of 4 power wires, which are usually connected via a USB interface. Next, we need to log in the computer to the Raspberry Pi through the serial port. The GPIO interface diagram of Raspberry Pi 4 is as follows:

The yellow box in the figure represents the connection of the TTL serial port. The letter G stands for GND (ground). Connect 5V to VCC (5v power supply). UART TXD connects USB to TTL RXD, UART RXD connects USB to TTL TXD.

The connection effect is shown in the figure below.

Close-up details of the connection:

After opening the device manager, you can find a COM5 port appeared.

Next, use PUTTY to log in to the serial port.

Note the red box, COM5 is the port seen in the device manager. Speed ​​write 115200, Connection type must check Serial, and then click Open. At this time, a login interface will appear. If you see a black screen, just press Enter.

The default account of the Raspberry Pi system is pi, and the default password is raspberry, all in lowercase letters. After logging in, enter the ifconfig command to get the ip address of the Raspberry Pi.

With the ip address, you can log in without using the serial port. At this time you can use ssh to log in, the command is as follows:

ssh pi@192.168.137.209

Note (you need to replace 192.168.137.209 with the IP address you got, because this IP address is the address of my Raspberry Pi, not your address)

SSH login is not necessary, because serial port login can also control Raspberry Pi.

Part 5: System upgrade and installation of necessary software

In order to increase the installation speed, the software warehouse needs to be changed to a domestic address based on where you live (we use Tsinghua University as an example here).

Edit the file /etc/apt/sources.list, delete all the contents of the original file and replace it with the following:

deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib

Edit the file/etc/apt/sources.list.d/raspi.list, delete all the contents of the original file and replace it with the following:

deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui

Then execute the sudo apt update command, and then execute the sudo apt upgrade command to update the system.

Because we use pythonSDK to get the balance, to install python3, pip3, git and commonly used tools, just enter the following commands at once:

sudo apt install python3 python3-pip git

sudo apt install gyp

sudo apt install protobuf-compiler

sudo apt install pandoc

sudo apt install pkg-config

sudo apt install autoconf automake libtool

Then execute the sudo apt update command, and then execute the sudo apt upgrade command to update the system.

After the prerequisite tools are installed, use git to clone the pythonSDK of JURA:

git clone https://github.com/blockchain-sdk/JURA-PythonSDK.git

Enter command cd JURA-PythonSDK to get in the directories

In order to install the library quickly, set the pip3 source to local entity.

pip3 config set global.index-url

(for example, https://pypi.tuna.tsinghua.edu.cn/simple)

Enter the command to update pip3

pip3 install — upgrade setuptools

Next, enter the following command to install the necessary libraries.

pip3 install grpcio

pip3 install grpcio-tools

pip3 install base58

pip3 install secp256k1

Part 6: Get wallet balance update

Open the getbalance.py file.

Go to JURA website wallet, copy the address (in the red box) and fill it in.

After that, enter python3 balance.py to view the current balance.

The balance is 40, the same as the web wallet. Now click to roll the dice in the web wallet.

Next, let’s go back to the Raspberry Pi to take a look:

python3 getbalance.py

You can see the red box, the balance has become 80.

This tutorial ends here, hurry up and try it out.

--

--

Jura Protocol Media

Redefining how blockchain protocols work from the ground up