Understanding how to download and interact with the Ethereum blockchain is a crucial part for anyone learning Ethereum.
There are several popular clients to work with the Ethereum blockchain. They are:
- eth – a client written in C++
- geth – a client written in Go
- pyethapp – a client written in python
There’s also Haskell and Java. There is a more detailed description here. Here we will focus on Geth.
What is Geth?
Geth is a multipurpose command line tool that runs a full Ethereum node implemented in Go. It offers three interfaces: the command line subcommands and options, a Json-rpc server and an interactive console.
There are several ways to download Geth. One is to visit https://geth.ethereum.org/downloads/ and download the latest version suitable for your OS.
Another option is to use brew for OSX users. Follow the instructions here. With brew, the steps are essentially:
- brew tap ethereum/ethereum
- brew install ethereum
What this does is install the geth client at /usr/local/Cellar/ethereum/1.7.3/bin
Then you can go to your terminal and run
When you run this command, geth will start downloading the entire blockchain onto your laptop. The location of the chaindata will be shown in the terminal window. Mine for example was: database=/Users/cloudnthings/Library/Ethereum/geth/chaindata
>> geth attach
Once connected, run eth.syncing to get the current block and the highest block.
Note that this your CPU load is going to go through the roof as geth kicks into life as you download the entire blockchain.
To find out the number of peers you are connected to run:
If you have Mist or Ethereum Wallet, you can open it up and you should see the same download status.
So far we have been using main net or the live blockchain. For development purposes, the best option is to run geth in testnet mode like so:
>> geth –testnet
This will take less space and sync even faster.
To go hyper speed, try:
>> geth –testnet –syncmode “fast”
Note that sometimes you might run into errors such as “Synchronisation failed, dropping peer” or “Ancestor below allowance”. This will mainly be due to no peers being available so you’ll just have to be patience and wait. Here I had to wait 20 minutes.
> geth attach ipc:/Users/<username>/Library/Ethereum/testnet/geth.ipc