How Ethereum Mining Works [An Overview]
You sure must have heard of Ethreum. It is the second most popular and valuable cryptocurrency after Bitcoin based on market cap. Ethereum has been around since 2013 and has initiated the blockchain 2.0 revolution by introducing smart contracts. In this article, we will try to understand how Ethereum mining works.
On a conceptual level, Ethereum mining is similar to 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
In Ethereum, your balance is a cumulative measure of all the transactions in your account. There are two types of accounts-
- Externally Owned Account- These accounts are code free and make transactions through your private key, just like in Bitcoin.
- 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 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?
A typical Ethereum transaction has the following fields-
- Transaction Hash
- Block Number
- Transaction Fee
- Gas Used by Transaction
- Gas Price
- 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.
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]
Miner collects transactions with high gas limits and transaction fees. The miners run a hashing function called Keccak256 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.
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.
- What is Bitcoin and How Bitcoin Works?
- A Beginner’s Guide to DeFi (Decentralized Finance)
- What are Dapps? (An ultimate guide)
- Libra Currency – A Cryptocurrency by Facebook
- What is Cloud Mining?
- Cloud Mining Bitcoin, Ethereum and Other Altcoins
If you want to learn more about the Crypto ecosystem, sign up for the weekly newsletter.