Running Stratis Core Full Node on RPI3

Mike Dennis
Apr 28 · 8 min read

This is a guide for how to run the Stratis Core C# full node (Core) on a Raspberry PI 3 (RPI) with no front end UI. The RPI is not yet an officially supported platform for Core but I personally have been staking successfully for several weeks directly from source code with decent up-time. There are some tips and tricks though to get it running successfully. I will lead you through my approach in this article.

Disclaimers: This is not yet an officially supported platform for Core so do so at your own risk. I provide no guarantees or assurances of the stability of Core for maintaining your funds or staking performance. This is completely unsupported and you are at your own risk. These steps are only recommended for users that have a strong technical background and are technically competent on the Linux OS. If things like docker containers, networking, REST APIs, or firewall configurations are things that scare you, this probably isn’t the best approach for you and you may be better off using the supported full node deployments.

For supported Core platforms visit:

Configuring your RPI

Memory and Swap File

The RPI has limited memory (approx. 1GB) and Core can be fairly memory hungry especially during initial block download (IBD) phase. Therefore you should make sure you allocate a decent sized swap file. I recommend 2GB if you have a sufficiently large SD card.

Set CONF_SWAPSIZE=2048 in dphys-swapfile

sudo dphys-swapfile swapoffsudo nano /etc/dphys-swapfile sudo dphys-swapfile swapon

Further info:

Install Docker

We will use docker to build and run the Stratis Core node from source code. So you will need to install docker onto your RPI. This can be done from the following commands:

curl -sSL https://get.docker.com | sh
sudo usermod -aG docker pi

Further info:

Configure Firewall

It’s recommended to setup a firewall on your RPI so you can only access it from your local network (or trusted PCs) and only the peer to peer (P2P) ports for Core are accessible externally. I personally used the UFW firewall on RPI.

I blocked everything except the following:

Ports enabled for my home network (subnet 192.168.0.0/24)
22 : SSH port- used to remote connect to RPI
16174: Stratis Core RPC port- only needed if you need to RPC into node
37221: Stratis Core API port- use to connect to node from home network

Port enabled for external access
16178: Stratis Core P2P protocol

To install and configure UFW with the above:

sudo apt install ufw
sudo ufw allow from 192.168.0.0/24 to any port 22
sudo ufw allow from 192.168.0.0/24 to any port 16174
sudo ufw allow from 192.168.0.0/24 to any port 37221
sudo ufw allow port 16178
sudo ufw enable
sudo ufw status

You should get something like this:

Status: activeTo Action From
— — — — — —
22 ALLOW 192.168.0.0/24
16174 ALLOW 192.168.0.0/24
37221 ALLOW 192.168.0.0/24
16178 ALLOW Anywhere
16178 (v6) ALLOW Anywhere (v6)

If you have problems getting UFW configured check out this reference:

Clone, Build, & Run Core

Create Virtual Directory for Core Node Data

Docker can map virtual directories from inside the docker container to your host’s file system. It is nice to map the Core’s data directory to a virtual directory so you can easily access some the Core’s configuration such as peers.json and wallet files. To do so create a folder on your RPI to host the Stratis Core nodes data:

mkdir ~/stratisnode

Run DotNet Docker Container

The dotnet SDK can be hosted and run from within a docker container. This will allow us to build and run the Stratis Core from source code. Run the dotnet sdk docker container with the following command:

docker run -it --name stratis -p 16178:16178 -p 16174:16174 -p 37221:37221 -v ~/stratisnode:/root/.stratisnode microsoft/dotnet:2.1.500-sdk

-p options expose ports from the Core node in the container to the host
16178- P2P
16174 -RPC
37221- API

-v maps the virtual directory you created into the containers core datadir directory

-it runs the container in interactive mode, see docker docs for more details

Get Stratis Core Source

Clone the Core source from the release branch into your running docker container:

git clone -b release/3.0.3.0 https://github.com/stratisproject/StratisBitcoinFullNode.git

-b release/3.0.3.0 is the release branch from the Stratis Core github repository. At time of writing 3.0.3.0 is the most recent Core release.

This will download the code for the current Stratis Core release into StratisBitcoinFullNode directory.

Find IP of running dotnet sdk Container

There might be an easier way but the containers internal IP can be found by running the following command on the running container.

docker inspect 9e3aa86199cf

Replace 9e3aa86199c with the id of your running dotnet sdk container, list of running containers and their ids can be found by running docker ps

The “IPAddress” at the end of this big list will be your containers internal IP address, make note of it as you will use it in the step below.

Run Stratis Core in DotNet Container

Below are an example command to build and start the node. Once the node is running hit CTRL+P+Q to exit container and leave it running in background.

cd ./StratisBitcoinFullNode/src/Stratis.StratisDdotnet run -c Release -apiuri=”http://172.17.0.2" -server=1 -rpcuser=”[USER]” -rpcpassword=”[PASSWORD]" -rpcallowip=”172.17.0.0/24" -maxblkmem=2 -maxoutboundconnections=8 -maxinboundconnections=8

-apiuri will should contain the IP of the dotnet container you got in the previous step. This will allow you to access the API from another PC on your local network.

You can remotely control the node fully through the API. So exposing RPC is an optional step. If you want to allow RPC access use the -server -rpcuser -rpcpassword options. Replace RPC [User] and [Password] with the credentials you want to use to restrict access to RPC.

-rpcallowip can be used to restrict which IP can access your node via RPC. In this example I have set it to the subnet of my docker host. This allows any of my other containers to access my node via RPC. This is because I have setup a reverse proxy to expose my nodes RPC endpoint. I have been working on a remote monitoring dashboard that uses RPC to monitor your node which I will talk about in a future article. If you want to only allow access from a specific PC on your local network you can enter it’s IP there instead. If you just want to use the API you don’t need to include any of the RPC options above.

Arguments for -apiport and -rpcport are optional you can add those options if you want to map to different ports than the Stratis Core defaults. Just ensure your firewall settings are updated accordingly. It’s a good security practice to use different ports than the defaults.

The -maxblkmem, -maxoutboundconnections, -maxinboundconnections are used to reduce the memory footprint of the node since the RPI has limited memory. I’ve found that these settings currently work best through trial and error.

If you have set everything up properly, your Core node should start syncing and your node’s datadir data should be writing node data in the virtual directory you created in the previous step.

Syncing Stratis Blockchain

You can leave your Core node running in the background by exiting the containers interactive mode by hitting CRTL+P+Q.

You can reattach to the Core node by doing:

docker attach 9e3aa86199cf

Just replace the container id above with your running containers id (which you can get via the docker ps command)

Syncing will take a significant amount of time due to the low memory in the RPI. I had to start and restart my node several times and it took several days to eventually sync the whole blockchain. If your node dies and you need to restart your node, use the dotnet command in the previous step.

Control Stratis Core through API

Once your Core node is running, and you have your firewall setting setup properly you should be able to access the API by browsing to the swagger page on the node from a browser on another PC on your network by navigating to http://192.168.1.1:37221/swagger Where the IP is the IP of your RPI (not the IP of the docker container hosting your node) and the port is the port you configured as the API in the firewall,and node in previous steps.

Creating a wallet

To create a wallet on your RPI execute the following through the swagger page:

GET api/wallet/mnemonic
language: English
wordCount: 12

This will generate the 12 word backup phrase for your private key. Save and record these words exactly as given. You will need these to create your wallet in the step below, and to restore your wallet if you ever need to restore it from scratch.

POST api/wallet/create
{
“mnemonic”: “string”,
“password”: “string”,
“passphrase”: “string”,
“name”: “string”
}

Enter the 12 words provided by the previous step in the mnemonic field. Choose a strong password and a passphrase. They can be the same if you want. Enter “default” for the name of the wallet. If you have done this successfully you will have a file called default.wallet.json in your ~/stratisnode/stratis/StratisMain directory.

Be sure to record the 12 words, password, passphrase and the date/time you created the wallet and save somewhere safe. You will need this information if you ever need to restore your wallet from backup in the future.

Transfer funds to Wallet

From swagger page:

GET /api/wallet/unusedaddress
WalletName: default
AccountName: account 0

This will return a STRAT address you can use for receiving funds to your newly created wallet.

Prior to sending funds to your wallet make sure you are comfortable with the steps below for withdrawal of funds from your wallet, as they are somewhat more complicated. Always send a small amount to test that you can receive funds properly prior to sending a large amount.

Get Wallet Balance

From swagger page:

GET /api/wallet/balance
WalletName: default

Send Funds from Wallet

From swagger page:

POST api/wallet/build-transaction
POST api/wallet/send-transaction

You will need the walletName, accountName, and password from previous steps to build the transaction. Put the recipient STRAT address in destinationAddress and amount (in STRAT) in amount.

Once you have built the transaction you can send it using the send-transaction method.

Again be sure to test your process with a small amount before trying a larger amount.

Staking

From swagger page:

To start staking

POST api/staking/startstaking
password: your wallet password from previous steps
name: default

To get staking status

GET api/staking/getstakinginfo

Node Status

This is a useful function to remotely see the status of the RPI node. From swagger page:

GET api/node/status

It will provide information like current block synced and current peers etc.

Final Notes

Some other users have reported that you can speed up syncing process by syncing from another computer to a external hard drive and then hooking that hard drive up to your RPI. I have not tried this myself although it should work.

Some other users have been able to get the Core wallet UI running on the RPI. I believe this involves a source code change. I have not tried this myself as I have no x-windows installed on my RPI but may be an option as well.

Other useful information and help can be found in the Stratis discord channel:

Please leave comments below if you find any errors in these steps and procedures. Most of this was created from my somewhat fading memory so I may have missed a step or two.

If you like this guide, feel free to send a STRAT donation to:

SeGWjZNZCn2g5EbErKEnR4A4d27kAMaU6Q

Which is a wallet running on a RPI!!

Mike Dennis

Written by

Blockchain Developer

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade