Blockchains and Smart Contracts using Ethereum

A very beginners’ tutorial

This tutorial is aimed at those who are eager to learn blockchains and smart contract but totally new to Ethereum and has little knowledge about blockchains.

It provides a set of examples where for each example it is explained, step by step, how to design, develop and use it.

Before you begin

It is assumed that you have a basic understanding about the blockchain concepts: transactions, blocks, mining, contracts etc. If not, you first need to make a small reading about these concepts.

It is not expected from you to know about any specific programming language. However, a basic understanding about distributed algorithms will make you understand the advanced examples more easily.

Lastly, make sure that your computer has at least 4 GB of RAM and a relatively fast CPU since a very large file (around 3 GB) will be created in when you first do mining (in a today’s regular computer, it takes around 7 minutes to create this file). It is especially important to know this information, if you are planning to use a Virtual Machine (something which I do not personally recommend).

Introduction

Many beginners are having a hard time following Ethereum and Solidity tutorials and their official documentations. Code snippets are simply not up-to-date and badly organized, something that can be really frustrating to figure out on your own. It is quite painful to figure out the actual API usage rather than what’s described in the documentation.

To this end, this article aims at making the beginners’ start for developing blockchain applications using Ethereum less painful. By following the examples in their given order, at the end of tutorial you will have basic understanding about how Ethereum works and how to interact with it.

The readers should try to avoid checking other resources as much as possible, since all necessary information is given. Hence, external links are also avoided throughout the tutorial as much as possible.

At the end of the tutorial, links to documentations and useful resources are given for those who want to go deeper.

Using Ethereum

Ethereum is a blockchain platform that runs applications called smart contracts. There are several clients for interacting Ethereum: cpp-ethereum is a client written C++, ethereumj is in Java and go-ethereum (geth) in go-lang. > Note that Ethereum and these clients are not the same thing, the clients are external software that are merely interacting with Ethereum and they can have additional features that are not provided in Ethereum.

In this tutorial, we focus on geth since it is one of the leading implementations for the moment. geth implements a javascript runtime environment (JSRE) that can be used in either interactive (console) or non-interactive (script) mode.

Local Private Network

It is better to start learning blockchains using Ethereum in an environment which is totally in our control. In this sense, we will start by setting up such an environment (i.e. local private network) in our local machine and execute all the examples there.

Ethereum performs transaction between addresses. An address can signify an account or a contract, but not a node. Consequently, it is sufficient to create a network with single node which has several accounts (with some initial balance).

The examples below should be followed in order:

Conclusion

Now you have a basic understanding about how to interact with Ethereum using geth and how to design, develop and use contracts.

Related