Getting started with Geth to run an Ethereum node. Geth, short for Go Ethereum, is a command line client application used for running an Ethereum node. An Ethereum node allows you to be private, self-sufficient and trustless on the network. You can use your node to query the blockchain, transfer ETH between accounts, contribute hashing power to mine ETH and secure the network. The Geth application is fast, lightweight, and open source software maintained by the community.
Do I need to run a node?
No, running a node can be difficult for some and you might not need one depending on your use case. Instead of running your own node you can use a third party provider. Some third party providers allow light use for free. They are a great option for testing out a project or developing a full scale system. Below are a few third party client node provider options:
What are the alternatives to a Geth node?
There are other implementation of Ethereum client nodes in different languages. Each implementation below is in different languages and maintained by different teams. It is very healthy to see implementations of nodes in different languages. This makes the network more resilient, diverse and some of the projects below solve slightly different use cases. Geth was the original implementation of a client and is the most popular node in use. See the table below for other client options and click on their link to read about each one. For this tutorial we will focus on the Geth client.
Client | Language | Operating System |
---|---|---|
Geth | Go | Linux, Windows, macOS |
OpenEthereum | Rust | Linux, Windows, macOS |
Nethermind | C# .Net | Linux, Windows, macOS |
Besu | Java | Linux, Windows, macOS |
Erigon | Go / Multi | Linux, Windows, macOS |
What is the GO programming language?
Go is an open source programming language created by Google. It was built to create programs related to networking and infrastructure. It was intended to be an alternative to popular high performance server side languages like Java and C++. To read more about Go visit their official homepage at golang.com. The Go programming language was used to build Geth because of its simplicity to learn and its use in high performing applications.
What are the different node types?
If you are going to run an Ethereum node keep in mind that there are three types of nodes and each consumes data differently. Make sure you choose the type that is most appropriate for your situation.
Full Ethereum node
- Stores the complete blockchain
- Verifies all blocks and transaction states
- Since it participates in consensus it serves the network
- One can query a full node for all types of data requests
- Takes longer to sync then a light node
- Data is pruned and this option does not contain all the historical states that are in an archive node however a full node is able to build them on demand
Light node
- Stores the header of the chain
- Requests are made to the network for other types of data
- It can verify the data against the state roots in the block headers
- Useful for low capacity devices, such as embedded devices or mobile phones, which can not store gigabytes of blockchain data
- Data is pruned and this option does not contain all the historical states that are in an archive node
Archive node
- Stores everything kept in the full node and builds an archive of historical states.
- Needed if you want to query historical information. For example what was my account balance at block #2,789,123.
- This data is in the terabytes which makes archive nodes less attractive for average users
- Archive nodes are useful for applications like block explorers, wallet providers, chain analytic applications, etc.
Operating system for Geth
To determine what operating system to use for Geth consider the following:
- You might want as little bloatware as possible in your operating system
- The server needs to be up and running 24/7 in order to synchronize all block on the network and perform consensus
- Do you have an extra monitor or do you want to run headless (no monitor)?
- What other application need to run on the machine? Python, Java, Docker, etc.?
If you want a simple setup with no down time consider going with a Linux ubuntu server. It is super easy to install the operating system and there are plenty of YouTube videos that outline the process.
If you do not have an extra monitor you can use Putty to connect to your server. Putty is a free SSH and Telnet client terminal emulator. If is a very useful tool to log into a server and run command line requests.
Hardware options and requirements for Geth
If you want to run a node on your own computer you need to make sure you have a capable machine. Consider the following:
- What are your project requirements?
- Is speed or performance a priority?
- Do you want a PC that can be out of site and fit under the desk?
- Do you have a PC or laptop you can use to run the Geth client?
Hardware options for Geth
There are multiple hardware options to run a Geth node. You can use one of the following options below. Select an option to skip to the selected material:
- PC or NUC (Next Unit of Computing – small form factor computer)
- Raspberry Pi 4
PC or NUC hardware requirements for Geth
To get started with Geth and run a node the minimum hardware requirements are noted below:
CPU with 2+ cores |
4GB RAM |
320GB of free storage space to sync the Mainnet |
8 MBit/sec download Internet service |
To get started with Geth and run a node the recommended hardware requirements are noted below:
Fast CPU with 4+ cores |
16GB+ RAM |
Fast SSD with at least 500GB of free space |
25+ MBit/sec download Internet service |
If you plan on setting up a light node then the hardware requirements are lower since you will only be storing block headers and receive small state updates.
A potential mid range PC setup
A mid range PC setup will cost approximately $620. For example see the component list and estimated prices below.
Component | Estimated Price in USD |
---|---|
AMD Ryzen 5 3600 6 core 12 threads | $120 |
Roswell Micro ATX tower | $30 |
Sabrent 1TB Rocket NVMe 4.0 M.2 SSD 5000 MB/s (read) and 4400 MB/s (write) | $170 |
16 GB of 3200 Ram | $90 |
500 Watt EVGA PSU | $40 |
X570 Gen 4 Micro ATX motherboard | $130 |
Total | $620 |
With an NVMe and Gen 4 motherboard one should be able to sync the Ethereum mainnet blockchain in less time then advertised. An M.2 SSD that connects directly to the board with fast reads and writes makes a difference in performance.
Installing Geth on your PC, NUC or server
There are multiple ways to download and install Geth on your PC, NUC or server:
- From the official Geth repository
- Using the command line in Ubuntu
- Docker Hub as a container
Download Geth from the official repository
Download Geth from the official GitHub repository. Make sure you only download an Ethereum client from the official repositories. There is no other software dependencies that you need to download for Geth to run.
- Download Geth from the official website
- Extract the the files with 7zip or your software of choice
In the folder where the files were extracted run the Geth program using the command below with the desired sync mode and other options (if necessary).
./geth --syncmode "option"
If you are using a light client it can take approximately 10 minutes after the node’s initialization before it starts receiving updates from the network.
For fast sync it can take anywhere from 3 hours to 2 days to complete depending on your hardware and internet connection.
Download Geth using the command line in Ubuntu
Install Geth from a Ubuntu terminal window with the following commands:
- sudo apt-get install software-properties-common
- sudo add-apt-repository -y ppa:ethereum/ethereum
- sudo apt-get update
- sudo apt-get install Ethereum
Create a new folder to store the ethereum network data. To start the Ethereum node using the Geth console type the following command:
user@ubuntu:~/machinename$ geth
This command will connect to the Ethereum network and sync the blockchain. For fast sync it can take anywhere from 3 hours to 2 days to complete depending on your hardware and internet connection.
Download Geth from Docker Hub as a container
After installing the Docker software on your machine visit this this page on Docker Hub for detailed instructions on how to run Geth in a container. Make sure you know basic Docker and Linux commands to get started (run, stop, prune, tail logs, etc).
In your terminal window (Putty) on the machine you want to install Geth type the Docker pull command to install Geth from Docker Hub.
docker pull ethereum/client-go
After you pull this image from Docker Hub follow the Ethereum Geth Node Configuration instructions for a quick tutorial to get your node running in a container. Running the one command on this page is the fastest way to get your node running. It will probably take 1-2 days to fully sync the Ethereum block chain to your new Geth node.
It is very important to read all documentation to make sure you download the Geth software from the approved repository and configure your node securely. Read more about running commands on the Docker Hub page. Always have security in mind and make sure the PC you are running your node on has a firewall and has proper security.
Raspberry Pi hardware requirements for Geth
To get started with Geth and run a node on a Raspberry Pi the minimum hardware requirements are noted below:
Raspberry Pi 4 Model B / 4 GB RAM |
Micro SD Card >= 16 GB |
SSD with at least 500GB of free space |
Power cord |
Case, heat sink and fan |
A POTENTIAL Raspberry Pi HARDWARE SETUP
A Raspberry Pi 4 setup will cost approximately $239.98. For example see the component list and estimated prices below.
Component | Estimated Price in USD |
---|---|
Raspberry Pi 4 Model B / 8 GB RAM kit | $119.99 |
External SSD with at least 1TB free space | $119.99 |
Total | $239.98 |
Keep in mind that a Raspberry Pi might not be as fast as a PC build. Data transfer through a USB cable is not as fast as data transferred through an NVMe. If you are building a high performance trading system where milliseconds count consider a different alternative.
Installing Geth on your Raspberry Pi 4
Follow this tutorial on the official Ethereum.org website to get started with Geth. How to turn your Raspberry Pi 4 into an Ethereum node. There are two images that you can download onto your Pi. The Eth 1.0 runs Geth by default and Eth 2.0 runs Prysm beacon chain by default.
Choose a Geth sync mode
After setting up your machine and downloading the client software you are ready to download and synchronize the blockchain to your PC. To get started with Geth there are a three options you can use to specify the sync mode of the Geth client:
Type one of the following commands |
–syncmode “fast” |
–syncmode “full” |
–syncmode “light” |
By default, Geth will run in –syncmode “fast”, this is the recommended option for running a an Ethereum node. When using “fast” synchronization, the node will first download blocks until it reaches the tip of the chain. Once the node is in sync with the network it will validate transactions like a full node.
If you select “full” synchronization, the node validates every transaction from in each block until it reaches the tip of the chain. This selection is not advised, as it doesn’t provide any benefit to re validate old blocks in the chain. It could take multiple days, or even weeks, to synchronize the complete blockchain. Once the node is in sync, it will continue full validation of new transactions.
If you select “light” synchronization, the node only downloads several recent block headers, which makes it very quick synchronize part of the chain. The limitation to this selection is that the node is not able to perform reliable validation as it does not have enough records from the chain.
If you are operating on a device with low bandwidth or little memory (a phone or microcontroller), it can be to your benefit to use a light node. The light node is updated by other full nodes on the network with high level information.
If you need complete data the fast sync options is the best to use.
Tailing the Geth logs
Tailing the Geth logs will look like the screen print below:
Common Geth commands and configuration
Below is a list of some commonly used Geth commands. These commands will help you get started calling basic functions in Geth. For a complete list of Geth command line options visit the Go Ethereum documentation.
Description | Geth Command |
Create an account, creates the address and location of the keystore file | ./geth account new |
List all accounts located in the keystore folder | ./geth account list |
Increase the amount of memory allocated to geth, default 1024 (MB) | ./geth –cache VALUE |
Set maximum number of full node peers, default 25 | ./geth –maxpeers VALUE |
Set maximum number of light node peers, default 100 | ./geth –lightpeers VALUE |
Export a copy of the Blockchain data to FILEPATH | ./geth export FILEPATH |
Import Blockchain data from FILEPATH | ./geth import FILEPATH |
1 thought on “Getting started with Geth to run an Ethereum node”