Ethereum Blockchain Development with DApps and Ethereum VM


Ethereum Blockchain Development with DApps and Ethereum VM

Recipe ID: hsts-r31


Self-paced training

We offer blockchain introduction, Hyperledger for system admin, Ethereum, Solidity, Corda R3, Hyperledger for developers, blockchain cybersecurity and more classes in self-paced video format starting at $60. Click here to learn more and register. For complete self-paced blockchain training, visit our Complete Blockchain Development Training page.


Update on Feb 2021

The latest version of this tutorial along with all updated source codes is available via the below link:
https://myhsts.org/blog/ethereum-dapp-with-evm-remix-golang-truffle-and-solidity-part1.html

Recipe Overview

For those who are not familiar with blockchain technology reading History and Evolution of Blockchain Technology from Bitcoin article is strongly recommended. Also, if you wish to learn and practice Hyperledger blockchain development, visit Comprehensive Hyperledger Training Tutorials page to get the outline of our Hyperledger tutorial articles.
We have written two sets of tutorials to explore Ethereum and Solidity programming in depth. First set covers the following nine recipes:

In short, you learn about how to set up and configure Ethereum and develop blockchain applications using Solidity programming language. We explore its key components, including smart contracts and Web3.JS API via an Auction Decentralized Application (DApp) step-by-step.
In second set, we will discuss more advance topics in Ethereum blockchain development and solidity while building a Tontine DApp game step-by-step. Specifically, we cover Truffle and Drizzle. For instance, we show you how a tool such as Truffle can be an assistant in building, testing, debugging, and deploying DApps. In summary, we are going to cover four main topics:

The 2nd set consists of 8 recipes as follows:

IMPORTANT: Understanding and completing the first set of recipes are required prior to working on second set of recipes.

In this recipe, we introduce the most well-established and mature smart-contract-driven blockchain: Ethereum. It focuses more on enabling developers to build and run distributed applications, decentralized apps (DApps), by providing them with built-in tools and currency vehicles.

In this recipe, we start our exploration by building a decentralized auction DApp to sell vehicles on top of the Ethereum blockchain. Along the way, we will introduce you, from a developmental standpoint, to   the tools, concepts, and fundamental basics required to build decentralized applications. This recipe and its follow-up tutorial articles are organized around the following four major topics: i- A general overview of Ethereum, ii- Introducing Solidity (auction smart contract), iii- Introducing web3.js (auction frontend) and iv- The smart contract deployment environment.

 

Introduction to Ethereum

In its first years, the bitcoin system has proven impressive, but it has narrow capabilities. However, the situation changed  after the introduction of the Ethereum blockchain, which, unlike bitcoin, can be extended to much more than just managing a digital currency. In fact, Ethereum is a general-purpose blockchain that is more suited to describing business logic, through advanced scripts, also known as smart contracts. Ethereum was designed with a broader vision, as a decentralized or world computer that attempts to marry the power of the blockchain, as a trust machine, with a Turing-complete contract engine.

Although Ethereum borrows many ideas that were initially introduced by bitcoin, there are many divergences between the two. The following table summarizes the main areas of difference between Ethereum and bitcoin:
Ethereum blockchain development


Ethereum Virtual Machine and Smart Contracts

The Ethereum virtual machine and smart contracts are key elements of Ethereum, and constitute its main attraction. The smart contract is a concept that was introduced in the 1990s by Nick Szabo, as a set of commitments specified in digital form. In Ethereum, smart contracts represent a piece of code written in a high-level language (Solidity, LLL, Viper) and stored as bytecode in the blockchain, in order to run reliably in a stack-based virtual machine (Ethereum Virtual Machine), in each node, once invoked. The interactions with smart contract functions happen through transactions on the blockchain network, with their payloads being executed in the Ethereum virtual machine, and the shared blockchain state being updated accordingly. The following diagram provides a general overview of the smart contract execution environment and the interaction between the virtual machine and the blockchain ledger:

 

Ethereum blockchain development 

Ether and Gas

Like bitcoin, the Ethereum network has a built-in cryptocurrency, called ether. In addition to operating as a digital currency for payment, ether is used in Ethereum's pricing mechanism for running DApps on the system. Ethereum isn't a free network; you have to pay in ether, whether for transaction fees, or for smart contract deployment or execution. The protocol defines the cost for each computation in a dedicated unit called gas, and the total cost is paid, in order to incentivize miners and avoid denial of service attacks. We will look at the relationship between ether and gas in the next sections.

 

Your first smart contract

Before we go any further, let's be concrete and jump into our first smart contract right away. The following code shows what a standard Hello World smart contract, written in a higher programming language (Solidity), looks like:

pragma solidity ^0.4.24;

contract HelloWorld {
string message = "hello world";

function setMessage(string msg_)       public { message = msg_;
}

function getMessage() public view returns (string) { return message;
}
}

If you're a developer, this code should be understandable; there is nothing complex. We define a variable, message, with two functions, a setter and a getter. What differs is the fact that we are dealing with a contract that easily stores a given message in Ethereum's blockchain, without using an I/O stream or database connection. We will take a closer look at the meaning of each element later in our next recipe. You can copy , paste, and compile this code by using an online IDE, such as Remix (http://remix.ethereum.org/). You will find further details on handling Remix in the follow-up recipes.

Congratulation! You have created your first Hello World smart contract.

 

What's a DApp?

Have you heard about Web 3.0?

This buzzword is all about a decentralized web, enabled by blockchain networks running DApps, instead of classic client-server web applications. DApp is an abbreviation for decentralized application, and it refers to an unstoppable application running on top of a peer-to-peer blockchain network. The DApp's unstoppability comes from the fact that it eliminates the need for any middlemen to operate, and its execution is replicated across a distributed network.

 

DApp Architecture

Generally, a DApp is a two-tier application, comprised of two main components:

 

In the frontend, if you are familiar with Bootstrap or any other framework, you can continue using it. You won't need to manage user accounts, create accounts, or log in to access your DApps, as the network is anonymous, and we only deal with anonymous accounts (addresses), without identification. On Ethereum, the backend operations are ensured by the smart contract, which is validated by the peer-to-peer network. The following diagram shows the layers of a typical DApp and the interactions between the frontend and backend:
Ethereum blockchain development

In our next recipe, we build Auction DApp With Ethereum and Solidity Programming Language.
To conclude this recipe, we like to recommend our Learn Hands-on Blockchain Ethereum Development & Get Certified in 30 Hrs, and Become Blockchain Certified Security Architect in 30 hours courses to those interested in pursuing a blockchain development career. This recipe is written by Brian Wu who is our senior Blockchain instructor in Washington DC. His Blockchain By Example book is highly recommended for learning more about blockchain development.

Related Training Courses

Hands-on Node.JS, MongoDB and Express.js Training
Advance JavaScript, jQuery Using JSON and Ajax
Learn Hands-on Blockchain Ethereum Development & Get Certified in 30 Hrs
Learn Blockchain Hyperledger Development & Get Certified in 30 Hrs
Become Blockchain Certified Security Architect in 30 hours
Blockchain Certified Solution Architect in 30 hours
Introduction to Python Programming
Object Oriented Programming with UML


Private and Custom Coding Classes

We offer private coding classes for beginners online and offline (at our Virginia site) with custom curriculum for most of our classes for $59 per hour online or $95 per hour in virginia. Give us a call or submit our Private Coding Classes for Beginners form to discuss your needs.


View Other Classes!