This is a quick “copy & paste guide” for data scientists and developers who are interested in storing the Ergo blockchain to a standardized database format using a Raspberry Pi 4.
We will be using the Ergo Blockchain Explorer (backend) but focus our efforts specifically on the Chain Grabber module.
A few prerequisites before we get started…
- Clean install of Raspberry Pi 4+
- Root file system mounted to SSD (60GB+)
- SSH enabled with stable internet connection
Preparing the RPi
sudo apt update sudo apt full-upgrade
Download latest Java version
sudo apt install default-jdk
echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | sudo apt-key add sudo apt update sudo apt install sbt
Download and unzip precompiled JAR
If you are reading this from the future please visit the code repo and replace with the appropriate versions.
wget https://github.com/ergoplatform/explorer-backend/archive/refs/tags/9.4.3.zip unzip explorer-backend-9.4.3
In the code snippet below we created “ergo” as the username.
sudo apt install postgresql sudo su postgres createuser ergo -P --interactive
Setup and load database schema
psql create database explorer; \c explorer; /i /explorer-backend-9.4.3/modules/explorer-core/src/main/resources/db/V9__Schema.sql
The final line of code above executes a SQL script that creates a bunch of tables and indices to be populated later by the Chain Grabber.
Update app config
This is where you need to edit the database username and password you set up earlier.
sudo nano explorer-backend-9.4.3/modules/chain-grabber/src/main/resources/application.conf
If all goes well the code below returns the latest block height that was stored to the database.
select max(height) from node_headers;
If you found this tutorial remotely helpful, any $ERG sent my way to 9hoco9Y8bXseiWB2gH5m5gb9bKemeyXhrQuhFdDNtu2ipdDUsTv is always appreciated.
If that’s not your jam then I also have a cryptojar for other virtual currencies. :)