Ethereum Tutorial:

In this Ethereum Tutorial blog, I will explain the inner working of ethereum’s architecture and I will also show you the implementation of ethereum through a simple smart contract.

I see Ethereum as a programmable blockchain that will serve a majority of B2C enterprise in the future. Ethereum grants developers the freedom of creating complex models to be executed on the blockchain, instead of restricting them to predefined operations like the Bitcoin blockchain.

With this approach, Ethereum has turned itself into a platform for a plethora of decentralized applications and organizations which includes, but isn’t limited to crypto-currencies.

I’ll be covering a variety of topics in an exhaustive manner through the run of this “Ethereum Tutorial” blog. These topics include:

You may go through this recording of Ethereum Tutorial where our instructors have explained the topics in a detailed manner with real-world problems and projectsthat will help you to understand this concept better.

Ethereum Tutorial | Ethereum Smart Contracts | Edureka

Ethereum Tutorial: Ethereum Accounts

The Ethereum network has two types of accounts, namely:

External Accounts

Contract Accounts

These accounts, both External and Contract are referred to as “state objects” and comprise the “state” of the ethereum network. Every state object has a well-defined state. For external accounts, the state comprises of the account balance while for contract accounts the state is defined by the memory storage and balance.

I’ll be referring to external accounts simply as accounts. These accounts are owned by are represented by external agents of the network which include every ordinary user, miners, automated agents, etc.

These accounts are generally controlled with the help of public key cryptography algorithms like RSA. The main purpose of External accounts is to serve as a medium for users to interact with the Ethereum Blockchain.

Contract accounts, on the other hand, are a collection of code that resides on the blockchain at a specific address. These contracts are invoked by external accounts, or by other contracts through a specific call-to-action function. These contracts are written in high-level scripting languages like Solidity, Serpent or LLL. Every contract that resides on the ethereum blockchain is stored in a specific format called EVM (Ethereum Virtual Machine) bytecode which is an ethereum specific binary format.It will only be fair that I explain EVM now that I’ve told you about EVM-bytecode.

Ethereum Tutorial: Ethereum Virtual Machine

Ethereum, in a rustic way, defines a set of generalized protocols which have become the pillars of the development of decentralized applications. At the heart of this, lies the Ethereum Virtual Machine. The figure below explains the architecture:

It is important to note that, the Ethereum Virtual Machine is not only completely sandboxed, but also completely isolated. This means that code that is currently running on the EVM has no access to the network or the file-system and can sparingly access other contracts.Now that we understand the core of the platform, let’s take a deeper look at the network nodes.

Ethereum Tutorial: The Ethereum Network

The ethereum network is a public blockchain network. It forms the basis of all decentralized peer-to-peer applications and organizations run on the network. The network is comprised of two types of nodes namely, full nodes and light-weight-nodes.

Full nodes contain the entire history of transactions since the genesis block. They are a full-fledged proof of the integrity of the blockchain network. Full nodes have to contain each and every transaction that has been verified according to the rules set up by Ethereum’s specifications.

Light-weight nodes on the other hand only contain a subset of the entire blockchain. These types of nodes are mostly used in e-wallets which have to be light-weight in nature and hence the entire blockchain cannot be stored on them. These nodes, in contrast, do not verify every block or transaction and may not have a copy of the current blockchain state. They rely on full nodes to provide them with missing details (or simply lack particular functionality). The advantage of light nodes is that they can get up and running much more quickly, can run on more computationally/memory constrained devices, and don’t eat up nearly as much storage.Every public blockchain has a currency attached to it. Ethereum is no different. Let’s take a deeper look into Ethereum’s cryptocurrency.

Ethereum Tutorial: Ether and Gas

Ether is the name of the crypto-currency used to pay for transactions on the ethereum network. Asides from paying for general transactions and services, Ether is also used to buy Gas, which in turn is used to pay for computation within the EVM.

Ether is the metric unit and has a lot of denominations which help accurately pay for transactions and gas. The smallest denomination a.k.a base unit is called Wei. The denominations along with their specific names can be seen in the table below:

Units

Wei Value

Wei

wei

1 wei

1

Kwei

1e3 wei

1,000

Mwei

1e6 wei

1,000,000

Gwei

1e9 wei

1,000,000,000

microEther

1e12 wei

1,000,000,000,000

milliEther

1e15 wei

1,000,000,000,000,000

Ether

1e18 wei

1,000,000,000,000,000,000

As discussed earlier, we know that EVM is responsible for running code that is deployed on its network. So what’s stopping someone from running an infinite loop on the EVM and completely overloading its memory? This is where the concept of Gas comes in.

Gas is used as a metric for paying for computational resources on the network. Every contract on the network has a set maximum amount of gas that it can use for its computations. This is known as the “Gas Limit” Other associated gas terms are as follows:

Gas Price: This is the cost of gas in terms of tokens like Ether and its other denominations. To stabilize the value of gas, the Gas Price is a floating value such that if the cost of tokens or currency fluctuates, the Gas Price changes to keep the same real value.

Gas Fee: This is effectively the amount of Gas needed to be paid to run a particular transaction or program (called a contract).

Hence, if someone tries to run a piece of code that runs forever, the contract will eventually exceed its gas limit and the entire transaction that invoked the contract will be rolled back to its previous state.

Now that we know about the currency, let’s take a look at the process that generates new currency.

Ethereum Tutorial: Mining

Ethereum, much like other public blockchain technologies ensures security through an incentive-based model. This is called a proof-of-work mechanism. The figure below shows how ethereum mining works:

From a more technical perspective, the proof-of-work algorithm used is called Ethash, which is a hashing algorithm inspired by the Dagger-Hashimoto Algorithm.

Now that we’ve seen the working architecture of ethereum and discussed it’s essential elements, let’s see a real-world problem and the ethereum approach to solve the same.

Ethereum Tutorial: Decentralized Crowd Funding Use Case

Problem Statement: A good ‘idea’ isn’t everything in today’s world to start a successful business. A lot of funding and effort is needed to implement an idea. This is where organizations like “Kickstarter” come into the picture. They provide projects with the public exposure needed for donations towards their project to get it up an running, but the centralized architecture of such a motive has its downsides, mainly in the way the rewards are handled. Since the centralized authority makes all the decisions, systems are prone to rules like:

anyone who missed the deadline for the campaign cannot get in any more

any donor who changed their mind can’t get out

Approach:

We take a decentralized methodology to address the problem as explained in the picture below:

In case you are interested in learning solidity, check out our blog on Solidity Programming, which is used for developing personalized smart-contracts.

If you wish to learn Blockchain and build a career in Blockchain Technologies, then check out our Blockchain Certification Training which comes with instructor-led live training and real-life project experience. This training will help you understand Blockchain in depth and help you achieve mastery over the subject.

Got a question for us? Please mention it in the comments section and we will get back to you as soon as possible.