Raspberry Pi 4: a zcashd Full node guide
The purpose of this guide is to help educate Zcashers who are interested in running a full node on a low-powered Raspberry Pi 4.
If you find this guide useful, consider donating ZEC to support ZecHub:
zs1txa9wzxsc46w4940c4t76wjlylhntyp7vcppsp8re32z02srqse038melgglew4jwsh3qes4m4n
What you will learn
- How to create a bootable Ubuntu Server microSD card
- How to setup internet connectivity on the Raspberry Pi 4
- How to access your Raspberry Pi 4 remotely
- How to install zcashd
- How to setup zcashd
- How to use zcashd
Prerequisites
- 8GB Raspberry Pi 4 Canakit or equivalent
- A computer with a microSD card drive
- A Wi-Fi network or an ethernet cable with an internet connection
- External SSD/HHD with USB3 support
note: keeping your server secure is not simple by any means. Any tips/recommendations/best practices beyond what is talked about in this guide please create a PR and help keep this guide as up-to-date as possible.
Contents:
Prepare the SD Card
In this step you will create a bootable SD card that will allow your Raspberry Pi 4 to boot.
-
Insert the microSD card into your computer. You may need to use the adapter that comes with the Canakit or any other equivalent adaptor.
-
Install Raspberry Pi Imager for your operating system. Download the version for the OS you currently have access to.
For example in linux you would type the following after downloading:
sudo dpkg -i imager_latest_amd64.deb
rpi-imager
-
Choose OS and Storage Device. Since Raspberry Pi 4's are 64 bit, I recommend choosing "Other general-purpose OS" => Ubuntu => Ubuntu Server 22.10 (64 bit). Click on Storage and select your SD Card
-
Before writing to SD card, click on Advanced options by clicking on the white gear icon near the bottom right corner.
-
Here you can update:
- Hostname of your Raspberry Pi 4
- Enable SSH
- Create a username and pw
- Enable and configure your wi-fi if needed
Boot Ubuntu Server
If you have an extra monitor and keyboard plug those in now. Note: these are optional.
- Install the SD card you just formatted into the Raspberry Pi 4 and also plug in the External SSD/HHD into the USB3 port. Also plug in the power cord and turn it on.
Connect remotely to your Raspberry Pi 4
-
We now need to connect to your Raspberry Pi 4. Things we need:
- Username and pw (from previous step)
- IP address so we can use SSH
- Monitor, and keyboard (optional)
-
If you have a monitor and keyboard connected directly to your pi, the rest of this section can be skipped.
-
Two ways to find your IP address are via your router admin page, or with nmap. If using the router, it depends on which manufacture and I'll defer those details to a quick google search.
- For nmap, first make sure it is installed:
sudo apt-get install nmap
-
Using your username, pw, and IP address we can now login using SSH
-
ssh <username>@<ip address of your pi>
note: you must plugin your username and your IP address, and your pw when prompted.
-
For example: ssh ubuntu@192.168.1.25
where the username is ubuntu and IP address is 192.168.1.25.
-
If youâre curious which version Raspberry Pi you are using, try this command:
cat /sys/firmware/devicetree/base/model ; echo
Installing zcashd
Setup zcashd
-
We now need to transfer all the zcashd binary files to your Raspberry Pi 4. As of Zcashd v5.3 the needed files include:
zcashd
zcash-cli
zcash-tx
zcash-gtest
zcash-inspect
zcashd-wallet-tool
fetch-params.sh
-
These files are found in the /src directory of your latest release download location if you compiled them yourself. Otherwise, the precompiled files are where you downloaded them.
-
Two ways of achieving the tranfers are either using SFTP, or by using your External drive.
SFTP
sftp username@<ip of RaspberryPi4>
put zcashd
put zcash-cli
put zcash-tx
put zcash-gtest
put zcash-inspect
put zcashd-wallet-tool
put fetch-params.sh
OR
Simply copy the files onto the External before you plug it into the Raspberry Pi 4.
-
If you already have a full node synced and want to save time, you can also copy the blocks and chainstate data.
cd ~/.zcash/
tar -zcvf blocks.tar.gz /blocks
tar -zcvf chainstate.tar.gz /chainstate
-
Using External SSD/HHD on your Raspberry Pi 4
-
Mount the External SSD/HDD in the Media folder so you can see it:
lsblk
will display all drives connected. Most will be of the format sda
id
will show your user and group id's.
sudo mount -o umask=0077,gid=<groupid>,uid=<userid> /dev/sda1 /media/portableHD/
-
Keep an eye on both who owns the folders/files and also the permissions.
sudo chown -R <username>: portableHD
sudo chmod -R 700 portableHD/
-
If you copied the blocks and chainstate .gz files from your other computer untar these now. Make sure they are in the .zcash folder on your External drive.
tar - xvzf blocks.tar.gz
tar - xvzf chainstate.tar.gz
-
Setup /media/portableHD/.zcash/zcash.conf
-
notice how we moved the datadir to the External SSD/HDD which has much more space available.
-
Since the default .zcash folder location has been moved, we need to tell zcashd this by using symbolic links:
cp -rp ~/.zcash/* /new_dir
// Make copy of datadir or supply with an external HD
rm -rf ~/.zcash
// Remove default folder
ln -s /media/portableHD/ ~/.zcash
// Symbolic link new data location to the default so zcashd is happy
-
Run fetch-params.sh script to download needed data for zcashd
./fetch-params.sh
-
Start a new 'screen' [ program in linux ]. Open zcashd with -datadir set:
-
Create an alias so you dont have to type out all these extra data location commands
alias zcash-cli="./zcash-cli -datadir=/media/portableHD/.zcash/"
-
Ready to use!
zcash-cli getblockchaininfo
Using zcashd
-
How do you check the status of your node?
tail -n 500 <path to>/.zcash/debug.log
-
To get current height from your log
tail -n 10 <path to>/.zcash/debug.log | grep -o 'height=[^b]*'
zcash-cli getinfo
-
Create a z2z transaction (Sapling) using the hex version of your memo from above
zcash-cli z_sendmany "ztestsapling1kg3u0y7szv6509732at34alct46cyn0g26kppgf2a7h5tpqxldtwm7cmhf8rqmhgt" "[{\"address\": \"ztestsapling2kg3u0y7szv6509732at34alct46cyn0g26kppgf2a7h5tpqxldtwm7cmhf8rqmhgtmpakcz5mdv\",\"amount\": 0.0001, \"memo\":\"5A656348756221\"}]"
-
How do you resume your zcashScreen after you detached it?
screen -r zcashScreen
-
How do you stop zcashd ?
zcash-cli stop
-
How do you create a UA?
zcash-cli z_getnewaccount
-
Now build a UA receiver according to your needs. This includes Orchard only, Orchard + Sapling, and finally Orchard + Sapling + Transparent.
-
Note you can tell the difference between receivers by how long they are.
zcash-cli z_getaddressforaccount 0 '["orchard"]'
zcash-cli z_getaddressforaccount 0 '["orchard","sapling"]'
zcash-cli z_getaddressforaccount 0 '["orchard","sapling","p2pkh"]'
-
How do you send ZEC using a UA?
zcash-cli z_sendmany "fromOaddress" "[{\"address\": \"dOrchardAddress\",\"amount\": 0.0001, \"memo\":\"yourMemoinHex\"}]" <minconf> <fee> <privacyPolicy>
It should be noted both, from AND destination addresses can be transparent,sapling, or orchard addresses however you may need to adjust the privacyPolicy flag in order for the transation to be valid. (Some combos wont work if privacyPolicy doesn't make sense!)
Sources