Book Image

Ethereum Cookbook

By : Manoj P R
Book Image

Ethereum Cookbook

By: Manoj P R

Overview of this book

Ethereum and Blockchain will change the way software is built for business transactions. Most industries have been looking to leverage these new technologies to gain efficiencies and create new business models and opportunities. The Ethereum Cookbook covers various solutions such as setting up Ethereum, writing smart contracts, and creating tokens, among others. You’ll learn about the security vulnerabilities, along with other protocols of Ethereum. Once you have understood the basics, you’ll move on to exploring various design decisions and tips to make your application scalable and secure. In addition to this, you’ll work with various Ethereum packages such as Truffle, Web3, and Ganache. By the end of this book, you’ll have comprehensively grasped the Ethereum principles and ecosystem.
Table of Contents (13 chapters)

Choosing a client for Ethereum

In this recipe, we will focus on installing various clients that implement the Ethereum protocol. This will help you learn what each client has to offer, and will enable you to choose and work with an efficient implementation based on your requirements.

Getting ready

If you are using macOS, you will need homebrew to install the packages.

How to do it...

There are several clients that implement the Ethereum protocol and we will mainly focus on geth and parity. You can get more information about the remaining protocols from the official Ethereum documentation (http://www.ethdocs.org/).

Geth

Geth is the official Go implementation of Ethereum:

  1. To install geth on macOS, the easiest way to follow is using homebrew. Run the following commands in your Terminal to download and install geth:
brew tap ethereum/ethereum
brew install ethereum

This command will install the latest stable version of geth on your Mac. If you want to install the development version of geth, then add the --devel flag to the install command:

brew install ethereum --devel
  1. To install geth on Ubuntu, run 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
  1. If you are using Windows, it is suggested to download the binary from https://geth.ethereum.org/downloads/ and install it by double-clicking the geth.exe file.
  2. Verify the installation by running the geth command:
geth version

It will show the current client details, as displayed here:

Since geth is a development version and still gaining in popularity, some antivirus software may consider it a virus. Also, make sure that you are not violating your organization's policies by using this software.

Parity

Parity is an Ethereum client that is built by Parity Technologies. It is a rust-based implementation and offers some additional functionalities over Go Ethereum:

  1. The easiest way to install parity on Mac or Ubuntu is to use the one-line binary installer. This will handle all the hassle of downloading and installing the package:
bash <(curl https://get.parity.io -kL)
  1. If you are using Windows, then download the binary releases from https://github.com/paritytech/parity/releases and install them. You can also see supported binaries for other operating systems as well.

There's more...

You can build and run the client directly from its source code. To build geth from the source in Ubuntu, follow the steps given later. Make sure you have Go and the C compilers installed:

git clone https://github.com/ethereum/go-ethereum
cd go-ethereum
make geth