Ethereum Tutorial

Ethereum is considered by many to be the second most popular cryptocurrency, surpassed at the moment only by Bitcoin. The Enterprise Ethereum Alliance (EEA) has some big-name founding members too, including Microsoft, Intel, and JPMorgan Chase, according to The Motley Fool. “The adoption of Ethereum by the corporate world,” says CNBC, “means it could eventually be bigger than its early stage rival.” That means it’s time to get to know the Ethereum platform, including its features and applications and what makes Ethereum different from Bitcoin.

Our “Ethereum Explained” Ethereum tutorial video lays it all out for you, and here we’ll cover what’s discussed in the video.

Take a deep dive on Bitcoins, Hyperledger, Ethereum, and Multichain Blockchain platforms with the Blockchain Certification Training Course!

What Is Ethereum?

Ethereum is a blockchain-based computing platform that enables developers to build and deploy decentralized applications—meaning not run by a centralized authority. You can create a decentralized application for which the participants of that particular application are the decision-making authority.

Ethereum Features

  • Ether: This is Ethereum’s cryptocurrency.
  • Smart contracts: Ethereum allows the development and deployment of these.
  • Ethereum Virtual Machine: Ethereum provides the underlying technology—the architecture and the software—that understands smart contracts and allows you to interact with it.
  • Decentralized applications (Dapps): Ethereum allows you to create consolidated applications, called decentralized applications. A decentralized application is called a Dapp (also spelled DAPP, dApp or DApp) for short.
  • Decentralized autonomous organizations (DAOs): Ethereum allows you to create these for democratic decision-making.

These are the most important features of Ethereum and before going deep into the Ethereum tutorial, let’s discuss each of these features in more detail.

Ether

Ether (ETH) is Ethereum’s cryptocurrency. Basically it is the fuel that runs the network. It is used to pay for the computational resources and the transaction fees for any transaction executed on the Ethereum network. Like Bitcoins, ether is a peer-to-peer currency. Apart from being used to pay for transactions, ether is also used to buy gas, which is used to pay for the computation of any transaction made on the Ethereum network.

Also, if you want to deploy a contract on Ethereum, you will need gas, and you would have to pay for that gas in ether. So gas is the execution fee paid by a user for running a transaction in Ethereum. Ether can be utilized for building decentralized applications, building smart contracts and making standard peer-to-peer payments.

Smart Contracts

Smart contracts are revolutionizing the way how traditional contracts worked, which is why it is important for you to know about them in this Ethereum tutorial. A smart contract is a simple computer program that facilitates the exchange of any valuable asset between two parties. It could be money, shares, property or any other digital asset that you want to exchange. These contracts can be created by anyone on the Ethereum network. The contract consists primarily of the terms and conditions mutually agreed on between the parties (peers).

The primary feature of a smart contract is that once it is executed, it cannot be altered, and any transaction done on top of a smart contract is registered permanently—it is immutable. So even if you modify the smart contract in the future, the transactions correlated with the original contract will not get altered; you cannot modify them.

The verification process for the smart contracts is carried out by anonymous parties of the network without the need for a centralized authority, and that’s what makes any smart contract execution on Ethereum a decentralized execution.

The transfer of any asset or currency is done in a transparent and trustworthy manner, and the identities of the two entities are secure on the Ethereum network. Once the transaction is successfully done, the accounts of the sender and receiver are updated accordingly, and in this way it generates a trust between the parties.

Smart Contracts vs. Traditional Contract Systems

In traditional contract systems, you sign an agreement, then you trust and hire a third party for its execution. The problem is that in this type of process, data tampering is possible. With smart contracts, the agreement is coded in a program. The result is not verified by a centralized authority; it is verified by the participants on the Ethereum blockchain-based network. Once a contract is executed, the transaction is registered and cannot be altered or tampered, so it removes the risk of any data manipulation or alteration.

Let’s take an example in which someone named Zack has given a contract of $500 to someone named Elsa for developing his company’s website. The developers code the agreement of the smart contract using Ethereum’s programming language. The smart contract has all the conditions (requirements) for building the website. Once the code is written, it is uploaded and deployed on the Ethereum Virtual Machine (EVM).

EVM is a runtime compiler to execute a smart contract. Once the code is deployed on the EVM, every participant on the network has a copy of the contract. When Elsa submits the work on Ethereum for evaluation, each node on the Ethereum network will evaluate and confirm whether the result given by Elsa has been done as per the coding requirements, and once the result is approved and verified, the contract worth $500 will be self-executed and the payment will be paid to Elsa in ether. Zack’s account will be automatically debited, and Elsa will be credited with $500 in ether.

Smart Contract - Ethereum

The Ethereum tutorial video includes a demo on the deployment of a Ethereum smart contract.

Ethereum Virtual Machine

EVM, as mentioned above in this Ethereum tutorial, is designed to operate as a runtime environment for compiling and deploying Ethereum-based smart contracts. Basically, EVM is the engine that understands the language of smart contracts, which are written in the Solidity language for Ethereum. EVM is operated in a sandbox environment—basically, you can deploy your own stand-alone environment, which can act as a testing and development environment, and you can test your smart contract (deploy it) “n” number of times, verify it, and then once you are satisfied with the performance and the functionality of the smart contract, you can deploy it on the Ethereum main network.

Any programming language in the smart contract is compiled into the bytecode, which the EVM understands. This bytecode can be read and executed using the EVM. One of the most popular languages for writing a smart contract is Solidity. Once you write your smart contract in Solidity, that contract gets converted into the bytecode and gets deployed on the EVM. And thereby EVM guarantees security from cyberattacks.

How Does EVM Work?

Suppose person A wants to pay person B 10 ethers. The transaction will be sent to the EVM using a smart contract for a fund transfer from A to B. In order to validate the transaction, the Ethereum network will perform the proof-of-work consensus algorithm.

The miner nodes on Ethereum will validate this transaction—whether the identity of A exists or not, and if A has the requested amount to transfer. Once the transaction is validated, the ether will be debited from A’s wallet and will be credited to B’s wallet, and during this process, the miners will charge a fee to validate this transaction and will earn a reward.

All the nodes on the Ethereum network execute smart contracts using their respective EVMs.

Proof of Work

Every node in the Ethereum network has:

  • The entire history of all the transactions—the entire chain
  • The history of the smart contract, which is basically the address at which the smart contract is deployed, along with the transactions associated with the smart contract
  • The handle to the current state of the smart contract

The goal of the miners on the Ethereum network is to validate the blocks. For each block of transaction, miners use their computational power and resources to get the appropriate hash value by varying the nonce. The miners will vary the nonce and pass it through a hashing algorithm—in Ethereum, it is the Ethash algorithm.

This produces a hash value that should be less than the predefined target as per the proof-of-work consensus. If the hash value generated is less than the target value, then the block is considered to be verified and the miner gets rewarded.

When the proof of work is solved, the result is broadcast and shared with all the other nodes in order to update their ledger. If other nodes accept the hashed block as valid, then the block gets added to the Ethereum main blockchain, and as a result the miner receives a reward, which as of today stands at 3 ethers. Plus the miner receives the transaction fees that have been generated for verifying the block. All the transactions that are aggregated in the block—the cumulative transaction fees associated with all the transactions—are also given as a reward to the miner.

Proof of Stake

In Ethereum, a process called proof of stake is also under development. It is an alternative to proof of work, and is meant to be a solution to minimize the use of expensive resources spent for mining using proof of work. In proof of stake, the miner—who is actually the validator—can validate the transactions based on the amount of cryptocoins he or she holds before actually starting the mining. So based on the accumulation of cryptocoins the miner has beforehand, he or she has a higher probability of mining the block. However, proof of stake is not widely used as of now compared to proof of work.

Gas

Just like we need fuel to run a car, we need gas to run applications on the Ethereum network. To perform any transaction within the Ethereum network, a user has to make a payment—shell out ethers—in order to get a transaction done, and the intermediary monetary value is called gas. On the Ethereum network, gas is a unit that measures the computational power required to run a smart contract or a transaction. So if you have to do a transaction that updates the blockchain, you would have to shell out gas, and that gas costs ethers.

In Ethereum, the transaction fees are calculated using a formula (see screenshot below). For every transaction, there is gas and its correlated gas price. The amount of gas required to execute a transaction multiplied by the gas price equals the transaction fees. “Gas limit” refers to the amount of gas used for the computation and the amount of ether a user is required to pay for the gas.

EVM Gas

Below is a screenshot from the Ethereum network showing the transaction cost. You can see for this particular transaction, the gas limit was 21,000, the gas used by the transaction was 21,000, and the gas price was 21 Gwei, which is the lowest denomination of ether. So 21 Gwei * 21,000 gave the actual transaction fees: 0.000441 ethers, or about 21 cents as of today. As mentioned, the transaction fee goes to the miner who has validated the transaction.

Ethereum Virtual Machine Gas

To understand the gas limit and the gas price, let’s consider an example using a car. Suppose your car has a mileage of 10 kilometers per liter and the price of petrol is $1 per liter. Then driving a car for 50 kilometers would cost you five liters of petrol, which is worth $5. Similarly, to perform an operation or to run code on Ethereum, you need to obtain a certain amount of gas, like the petrol, and the gas has a per-unit price, called gas price.

If the user provides less than the amount of gas to run a particular operation, then the process will fail and the user will be given the message “out of gas.” And Gwei, as noted above, is the lowest denomination of ether used for measuring a unit of a gas price.

Ethereum Mining vs. Bitcoin Mining

The hashing algorithm is the primary difference between Ethereum mining and Bitcoin mining.

Bitcoin uses SHA-256, and Ethereum uses Ethash. The average time taken on Bitcoin for mining a block is 10 minutes, whereas on Ethereum it is 12 to 15 seconds. As of today, the mining reward for Bitcoin is 12.5 bitcoins; for Ethereum it’s 3 ethers plus the transaction fee—the cumulative transaction fees of all the transactions of a block. As of April 10, 2019, the value of 1 bitcoin is $5249.03, whereas 1 ether is $180.89.

How is Ethereum mining different from Bitcoin mining?

Bitcoin

Ethereum

Hashing Algorithm

SHA-256

Ethash

Time taken to mine a block

An average of 10 minutes

An average of 12-15 seconds

Reward

12.5 BTC

3 ETH

USD - 04/10/2019

1 Bitcoin = 5249.03

1 Ether = 180.89

Below is a screenshot of an Ethereum reward that has been given to the miner of the block. As you can see, the reward is 3 ethers plus the total accumulated transaction fees of all the underlying transactions in this block, which are 0.0666 ethers.

Ethereum Virtual Machine Gas - 4

Decentralized Applications (Dapps)

Let’s compare decentralized applications with traditional applications. When you log in to Twitter, for example, a web application gets displayed that is rendered using HTML. The page will call an API to access your personal data (your information), which is centrally hosted. It’s a simple process: your front end executes the backend API, and the API goes and fetches your information from a centralized database.

DAPP

If we transform this application into a decentralized application, when you log in, the same web application gets rendered, but it calls a smart contract-based API to fetch the information from the blockchain network. So the API is replaced by a smart contract interface, and the smart contract will fetch the information from the blockchain network, which is its backend.

That blockchain network is not a centralized database; it’s a decentralized network in which the participants of the network (the miners) validate (verify) all the transactions that are happening using the smart contract on the blockchain network. So any transaction or action happening on a Twitter-type application that has now been transformed will be a decentralized transaction.

A Dapp consists of backing code that runs on a distributed peer-to-peer network. It is a software designed to work in the Ethereum network without being controlled by a centralized system, as mentioned, and that is the primary difference: it provides direct interaction between the end users and the decentralized application providers.

An application qualifies as a Dapp when it is open-source (its code is on Github) and it uses a public blockchain-based token in order to run its applications. A token acts as fuel for the decentralized application to run. Dapp allows the backend code and data to be decentralized, and that is the primary architecture of any Dapp.

Equip yourself with the structure and mechanism of Ethereum and Hyperledger with the Blockchain Certification Training! Enroll now!

Decentralized Autonomous Organizations (DAOs)

A DAO is a digital organization that operates without a hierarchical management; it operates in a decentralized and democratic fashion. So basically a DAO is an organization in which the decision-making is not in the hands of a centralized authority but rather in the hands of certain designated authorities or a group or designated people as a part of an authority. It exists on a blockchain network, where it is governed by the protocols embedded in a smart contract, and thereby, DAOs rely on smart contracts for decision-making—or, we can say, decentralized voting systems—within the organization. So before any organizational decision can be made, it has to go through the voting system, which runs on a decentralized application.

Here’s how it works. People add funds through the DAO, because the DAO requires funding in order to execute and make decisions. Based on that, each member is given a token that represents that person’s percentage of shares in the DAO. Those tokens are used to vote in the DAO, and the proposal status is decided based on the maximum votes. Every decision within the organization has to go through this voting process.

Real-World Applications of Ethereum Explained in Ethereum Tutorial

  • Voting systems: As we’ve seen with DAO, voting systems are adopting Ethereum. The results of polls are publicly available, ensuring a transparent and fair democratic process by eliminating voting malpractices.
  • Banking systems: Ethereum is getting adopted widely in banking systems, because with Ethereum’s decentralized system it is very difficult for hackers to gain unauthorized access. It also allows payments on an Ethereum-based network, so banks are also using Ethereum as a channel to make remittances and payments.
  • Shipping: Deploying Ethereum in shipping helps with the tracking of cargo and prevents goods from being misplaced or counterfeited. Basically, Ethereum provides the provenance and tracking framework for any kind of asset required in a typical supply chain.
  • Agreements: With Ethereum smart contracts, agreements can be maintained and executed without any alteration. So in any industry that has fragmented participants, is subject to disputes and requires digital contracts to be present, Ethereum can be used as a technology for developing smart contracts and for digitally recording the agreements and the transactions based on them.

Next Steps

Head over to our “Ethereum Explained” Ethereum tutorial video to see an in-depth demo on how to deploy an Ethereum smart contract locally, including installing Ganache and Node in a Windows environment. And if you really want to take your career to the next level, what are you waiting for? Sign up for Simplilearn’s Blockchain Basics course or Blockchain Certification course. Remember that blockchain is the underlying technology not just for Ethereum but for Bitcoin and other cryptocurrencies. And according to Indeed, the average salary for a blockchain developer is almost $90,000 per year, and some blockchain developer salaries are as high as $193,000!

About the Author

SimplilearnSimplilearn

Simplilearn is one of the world’s leading providers of online training for Digital Marketing, Cloud Computing, Project Management, Data Science, IT, Software Development, and many other emerging technologies.

View More
  • Disclaimer
  • PMP, PMI, PMBOK, CAPM, PgMP, PfMP, ACP, PBA, RMP, SP, and OPM3 are registered marks of the Project Management Institute, Inc.