Ethereum operates as a decentralized global computer, powered by a blockchain that facilitates smart contracts and decentralized applications. At its core are several fundamental concepts that dictate how the network functions, including accounts, transactions, gas, and the mechanisms that keep the system running smoothly, even under strain.
What is an Ethereum Account?
An Ethereum account is an entity that can hold ether (ETH) and execute transactions on the blockchain. There are two distinct types of accounts, though this distinction is set to be abstracted away in future network upgrades.
Externally Owned Accounts (EOA)
An Externally Owned Account is typically controlled by a user through a private key. Its characteristics include:
- Holding an ETH balance.
- Being able to send transactions, which can transfer ETH or trigger contract code.
- Having no associated code itself.
Contract Accounts
A Contract Account is controlled by its code and is deployed on the blockchain. Its features are:
- Holding an ETH balance.
- Containing associated smart contract code.
- Having its code executed when triggered by a transaction or a call from another contract.
- Being able to operate with Turing-complete complexity, manipulate its own storage, and interact with other contracts.
Every action on the Ethereum blockchain originates from a transaction initiated by an EOA. When a contract receives a transaction, the provided data acts as input, and the code is executed by the Ethereum Virtual Machine (EVM) on every node in the network during block validation.
What Are Transactions and Messages?
Transactions
A transaction refers to a signed data package sent from an EOA to another account on the blockchain. It contains:
- The recipient’s address.
- A signature verifying the sender’s intent.
- A value field indicating the amount of ETH (in wei) to be transferred.
- An optional data field for input to contract accounts.
- A gas limit, specifying the maximum computational steps allowed.
- A gas price, denoting the amount the sender is willing to pay per unit of gas.
Messages
Contracts can send "messages" to other contracts. A message is a virtual object that exists only within the EVM and functions similarly to an internal function call. It includes:
- The sender’s address.
- The recipient’s address.
- An optional data field for contract input.
- A gas limit for the execution triggered by the message.
Messages are generated when a contract executes CALL or DELEGATECALL operations. They are sometimes called "internal transactions." While similar to transactions, messages are not initiated by external users but by contracts during execution. The term "transaction" is often used broadly to refer to both, but understanding the distinction is key to grasping Ethereum’s operational layers.
What Is Gas?
Gas is the unit that measures the computational effort required to execute operations on the EVM. Each opcode in the EVM has a fixed gas cost. Since every node on the network performs these computations, gas costs ensure that resources are used efficiently and that the network remains secure against spam.
Gas and Transaction Fees
Every transaction must specify a gas limit and a gas price. The total fee is calculated as:
Transaction Fee = gasUsed × gasPrice- gasUsed: The total gas consumed by all executed operations.
- gasPrice: The amount of ETH (in wei) the sender pays per unit of gas.
If the gas used is within the gas limit, the transaction processes successfully, and any unused gas is refunded. If execution exceeds the limit, all operations are reverted, but the fee is still paid to miners.
Estimating Transaction Costs
To estimate gasUsed, developers can use tools like the estimateGas API. The gasPrice is typically set by the user, though miners prioritize transactions with higher fees. As of recent trends, a standard gasPrice might range from 20 to 100 Gwei (giga-wei), but this fluctuates with network demand.
For example, a simple ETH transfer requires 21,000 gas. At a gasPrice of 20 Gwei, the fee would be:
21,000 × 20 Gwei = 420,000 Gwei = 0.00042 ETHMore complex operations, like token transfers, can require 50,000–100,000 gas, leading to proportionally higher fees.
What Is the Block Gas Limit?
The block gas limit is the maximum total gas allowed in a single block, determining how many transactions can be included. Miners collectively adjust this limit per block, with the protocol allowing a change of ±1/2024 (≈0.0976%) from the previous block’s limit.
How It Works
If a transaction’s gas limit exceeds the current block gas limit, it is rejected. Miners select transactions to maximize their fees, often prioritizing those with higher gas prices. The current average block gas limit hovers around 4–5 million gas, allowing roughly 200–250 simple transfers per block.
The Role of Miners
Miners use client software like Geth or Parity, which allows them to configure gas limits and prices. Default settings often include a minimum gas limit, but miners can adjust these based on network conditions.
What Are "DoS" Attacks on Ethereum?
Ethereum can experience denial-of-service (DoS) conditions when blocks are consistently full, leading to transaction delays. This can arise from malicious attacks or organic congestion.
Malicious DoS Attacks
Malicious actors have historically spammed the network with low-cost transactions designed to consume computational resources. This forced miners to temporarily lower gas limits to mitigate the impact.
Organic Congestion
High demand from activities like token sales (ICOs) can also fill blocks, causing delays. This is not malicious but reflects the network’s limited throughput during peak usage.
Why Doesn’t the Gas Limit Adjust Automatically?
The Ethereum protocol includes a mechanism for miners to vote on gas limits, allowing dynamic adjustment without hard forks. However, many miners have not enabled this feature, leading to persistent congestion during high demand.
Miners can reconfigure their clients to support dynamic adjustment. Recommended settings include:
- Geth:
--gasprice 4000000000 --targetgaslimit 4712388 - Parity:
--gas-floor-target 4712388 --gas-cap 9000000 --gasprice 4000000000
These settings help the network respond to demand while maintaining stability.
👉 Get advanced mining strategies
Frequently Asked Questions
What is the difference between an EOA and a contract account?
An Externally Owned Account is controlled by a private key and can initiate transactions. A contract account is controlled by its code and executes operations only when triggered by a transaction or message.
How can I reduce my transaction fees?
To reduce fees, set a lower gasPrice, but be aware that miners may prioritize higher-paying transactions. Also, optimize smart contracts to use less gas during execution.
What happens if my transaction runs out of gas?
If execution exceeds the gas limit, all operations are reverted, and the spent gas is not refunded. The transaction fails, but the fee is still paid to miners.
Why are blocks sometimes full?
Blocks can fill due to high demand from popular dApps, token sales, or network attacks. This leads to slower transaction processing and higher fees.
How do miners decide which transactions to include?
Miners typically select transactions with the highest gasPrice first, as this maximizes their revenue. They may also prioritize transactions from known addresses or with higher complexity.
Can the block gas limit be increased indefinitely?
No. The limit is constrained by network consensus and hardware limitations. While it can be adjusted dynamically, excessive increases could compromise node performance and decentralization.
Understanding these core concepts is essential for anyone interacting with Ethereum. From managing gas fees to comprehending network congestion, these elements define the user experience and the platform’s capabilities. As Ethereum continues to evolve, staying informed about these mechanisms will help you navigate the ecosystem effectively.