Mining is the process of generating a block of transactions and adding it to the Ethereum blockchain.
Traditional mining functions in a similar manner as proof-of-work (PoW) consensus mechanisms do. Mining is the lifeblood of PoW. Ethereum miners – computers executing software – use their time and processing power to verify transactions and generate blocks.
Why miners exist?
In decentralized systems like Ethereum, we need to ensure that everyone agrees on the order of transactions. Miners help this happen by solving computationally difficult puzzles to produce blocks, securing the network from attacks.
Who can mine Ethereum?
Anyone can mine the Ethereum network using their PC, though not everyone may do so profitably. Miners must purchase dedicated hardware in order to mine profitably in most situations. While it is true that anyone may use their computer to run mining software, it is unlikely that the typical PC would be able to earn enough block rewards to cover its costs of
Cost of mining
- The hardware necessary to establish and maintain a mining rig has several costs.
- The electricity cost of running the mining rig
- If you’re mining in a pool, most mining pools charge a fixed percentage fee of each block produced by the pool.
- Costs of equipment required to maintain mining rigs (ventilation, energy monitoring, electrical wiring, and so on)
Use a mining calculator, such as the one provided by Etherscan, to further analyze profitability.
How Ethereum Transactions Are Mined
- A buyer creates and signs a transaction request using the secret key of a specific account.
- The user broadcasts the transaction request to the entire Ethereum network from a node.
- Each node in the Ethereum network adds the request to their local mempool, a list of all transaction requests they’ve heard about that haven’t yet been committed to the blockchain in a block, when they hear about the new transaction request.
- In essence, a mining node combines numerous dozens or hundreds of transaction requests into a possible block in such a way that it maximizes the revenue from transaction fees while still staying below the block gas limit. The mining node then goes on to:
- Verifies each transaction request against the blockchain and, if successful, executes the code of the request, changing its local EVM state. The miner keeps the transaction fee for each such request.
- The process of generating the proof-of-work “certificate of legitimacy” for the potential block, when all transaction requests in the block have been verified and performed on the local EVM copy.
- Finally, a miner will complete creating a certificate for a block that includes our requested transaction. The miner then sends the completed block, which includes the certificate and another checksum of the claimed new EVM state.
- All other nodes are informed of the new block. They verify the certificate, execute all transactions on the block themselves (including any transactions broadcasted by our user), and ensure that their new EVM state after execution of all transactions is identical to that claimed by the miner’s block. These nodes only append this block to the end of their blockchain and accept
- All transactions in the new block are removed from each node’s local mempool of unfulfilled transaction requests.
- New nodes download all blocks in sequence, including the block containing our transaction of interest. They create a local EVM copy (which starts as a blank-state EVM) and then go through the process of executing every transaction in each block on top of their own EVM copy, checking state checksums at each step.
- Every transaction is computed once and included in a new block, but it is verified and executed by each participant in the process of progressing the canonical EVM state. This emphasizes one of blockchain’s fundamental principles: Don’t trust anything.