How Ethereum Mining Works [An Overview]
Tags: ethereum, ethereummining
Published: 2020-03-15 10:18:20

---
title: How Ethereum Mining Works [An Overview]
published: true
date: 2020-03-15 09:44:27 UTC
tags: Ethereum,ethereum,ethereum-mining
canonical_url: https://blog.coincodecap.com/how-ethereum-mining-works-an-overview/?utm_source=rss&utm_medium=rss&utm_campaign=how-ethereum-mining-works-an-overview
---

You sure must have heard of [Ethreum](https://blog.coincodecap.com/tag/ethereum/). It is the second most popular and valuable cryptocurrency after [Bitcoin](https://blog.coincodecap.com/tag/bitcoin/) based on market cap. Ethereum has been around since 2013 and has initiated the [blockchain](https://blog.coincodecap.com/tag/blockchain/) 2.0 revolution by introducing [smart contracts](https://blog.coincodecap.com/tag/smart-contact/). In this article, we will try to understand how Ethereum mining works.

On a conceptual level, Ethereum mining is similar to [Bitcoin mining](https://blog.coincodecap.com/tag/bitcoin-mining/) but the devil lies in the detail.

Unlike bitcoin, Ethreum is an account-based blockchain instead of UTXO based blockchain like Bitcoin.

> **Also Read: [Ethereum versus Bitcoin](https://blog.coincodecap.com/ethereum-versus-bitcoin/)**

In Ethereum, your balance is a cumulative measure of all the transactions in your account. There are two types of accounts-

1. Externally Owned Account- These accounts are code free and make transactions through your private key, just like in Bitcoin.
2. Contract Account- These accounts involve code. They get executed when they are triggered by transactions or messages received from other contracts.

Ethereum transactions are processed through a virtual machine called **[Ethereum Virtual Machine](https://medium.com/mycrypto/the-ethereum-virtual-machine-how-does-it-work-9abac2b7c9e)** or EVM.

EVM executes a pre-programmed contract according to the rules of the transaction. Ethereum’s node keeps a record of the history of past transactions as well as smart contract interactions that have taken place on the Ethereum network.

Now that we have an overview of Ethereum let’s have a look at how Ethereum mining works. Just like in Bitcoin, Ethereum has miners to validate a transaction by providing proof to certify that the block is a valid one.

> Also Read: [What is Bitcoin mining?](https://blog.coincodecap.com/what-is-bitcoin-mining-and-how-it-works/)

### Ethereum Transaction

A typical Ethereum transaction has the following fields-

1. Transaction Hash
2. Block Number
3. Timestamp
4. From
5. To
6. Value
7. Transaction Fee
8. Gas Used by Transaction
9. Gas Price
10. Nonce
11. Gas Limit

Transaction hash is the hash produced after injecting the transaction fields into a hashing function called Keccak256. The block number is generated after the transaction has been mined by a miner.

### Gas used in Ethereum

Let us talk about the most important part of Ethereum which is **GAS.** Gas is the price paid for the computation process.

This is similar to the gas you use in your vehicle. However, in the case of Ethereum, it is gas used to process a transaction or run a smart contract.

So, Gas Limit is the maximum amount of gas you are willing to put into the transaction depending on the computation needed for the transaction.

Let’s say you want to go to a resort located at a distance of 100km from your house via your car. You need to put a more amount of gas in your vehicle compared. If you want to go to your nearby shopping mall via your car which is about 20km from your house. You would need less gas. The same happens in the case of Ethereum. If your transactions involve complex computational tasks( usually occurs while executing a smart contract), it would require more gas compared to a transaction that needs less computational tasks. The exact **price** of the **gas** is **determined** by the network’s miners. The gas price is usually expressed in Wei which is the smallest denomination used in Ethereum. **1 ether** (ETH) is equivalent to 1×1018 **Wei**.

The gas used by a transaction is used to show the amount of gas used from the gas limit set by you. It may happen that you have set the gas limit lower than the required gas. In that case, your transaction won’t be completed. Similarly, if you have set a high gas limit, the remaining gas will be refunded to you. Every block has a maximum Gas limit, which limits block size.

### Consensus Protocol

Just like Bitcoin, Ethereum also uses Proof of Work as a consensus protocol. But the developers of Ethereum have added a twist to it make it scalable with less transaction time compared to Bitcoin.

The time taken to produce in the case of Ethereum is 15 seconds compared to 10 minutes in Bitcoin. The Ethereum mining process is similar to bitcoin.

> Also Read: [How Bitcoin Mining Work? [Technical]](https://blog.coincodecap.com/how-bitcoin-mining-work/)

Miner collects transactions with high gas limits and transaction fees. The miners run a hashing function called [Keccak256](https://keccak.team/index.html) to come up with a hash value lower than the target value. The proof of work function in the case of Ethereum is called **[ethash](https://en.wikipedia.org/wiki/Ethash)**.

### Blocks of Blockchain

Many problems arise with reduced mining time. The security of the whole system will be compromised as any malicious with a bigger chain can make a fork and continue on the chain. The number of blocks produced by different miners will go up. This would lead to a rise in the number of stale blocks( called orphan blocks in Ethereum)

Stale blocks or Orphan blocks are blocks that were propagated to the network and verified by some nodes as being correct but eventually being thrown away as a longer chain was dominant. This is known as Forking.

As the number of forks increases, the trust of the participants will go down as they won’t be able to decide which fork to follow along.

To compensate that, Ethereum uses the GHOST (Greedy Heaviest Observed Subtree) protocol. This protocol selects the path with the highest computational calculation. That doesn’t completely solve the orphan block problem.

In the case of Bitcoin, there is no reward for mining the orphan block. But in Ethereum, the GHOST Protocol combines some of these orphaned blocks as **“uncle blocks”** and assigns partial rewards to the miners of these blocks. Not only that, but it is also reflected in the main Ethereum network. This is done to encourage more Ethereum mining and to make the network secure.

**Also, Read**

- [**What is Bitcoin and How Bitcoin Works?**](https://blog.coincodecap.com/what-is-bitcoin-and-how-it-works/)
- **[A Beginner’s Guide to DeFi (Decentralized Finance)](https://blog.coincodecap.com/a-beginner-guide-to-defi-decentralized-finance/)**
- [**What are Dapps? (An ultimate guide)**](https://blog.coincodecap.com/what-are-dapps-an-ultimate-guide/)
- [**Libra Currency – A Cryptocurrency by Facebook**](https://blog.coincodecap.com/libra-currency-a-cryptocurrency-by-facebook/)

The post [How Ethereum Mining Works [An Overview]](https://blog.coincodecap.com/how-ethereum-mining-works-an-overview/) appeared first on [CoinCodeCap Blog](https://blog.coincodecap.com).