How Ethereum Works: Accounts, Gas & the EVM Explained

To truly understand Ethereum, you need to look under the hood. This guide breaks down every core component of the Ethereum network — the state machine, accounts, transactions, gas, the Ethereum Virtual Machine (EVM), and Layer 2 scaling — that together enable the creation of decentralized applications. While the concepts are technical, this guide explains them in plain English, backed by custom infographics and real-world examples. Whether you are a complete beginner or someone brushing up on the fundamentals, this is the most complete guide to how Ethereum works you will find.

The Ethereum State Machine: A Digital Universe of Agreements

Unlike Bitcoin, which is primarily a distributed ledger for recording transactions, Ethereum is a distributed state machine. Think of it as a single, global computer that anyone can use — and that no single person controls. At any given moment, there is a “state” of the Ethereum network, which includes all account balances, smart contract data, and other information. When a transaction is executed, it causes the state to transition to a new state. This is what allows Ethereum to support complex applications and smart contracts, going far beyond simple monetary transactions.

Y(S, T) = S’
Given an old valid state (S) and a new set of valid transactions (T), the Ethereum state transition function Y(S, T) produces a new valid output state S’.

Infographic showing Ethereum as a state machine: World State S(t) transitions to World State S(t+1) via a transaction T, with the formula Y(S,T)=S’. Also compares Ethereum vs Bitcoin.

Ethereum vs. Bitcoin: Two Different Approaches

Bitcoin’s design is intentionally simple: it is a distributed ledger that records who sent how much Bitcoin to whom. Ethereum, by contrast, stores not just balances but also the complete state of every smart contract deployed on the network. This is what makes Ethereum a programmable blockchain — a platform for building applications, not just transferring value. For a deeper look, check out our Ethereum vs. Bitcoin comparison.

FeatureBitcoinEthereum
Primary purposePeer-to-peer digital currencyProgrammable smart contract platform
Data stored on-chainTransaction historyTransaction history + contract state
ScriptingLimited (Bitcoin Script)Turing-complete (EVM)
Native currencyBTCETH (Ether)
ConsensusProof of WorkProof of Stake

Ethereum Accounts: Your Identity on the Blockchain

On Ethereum, your identity and your assets are represented by accounts. There are two fundamental types of accounts, each with distinct characteristics and purposes.

Infographic comparing Externally Owned Accounts (EOA) and Contract Accounts on Ethereum, showing their four fields: nonce, balance, codeHash, and storageRoot.

➤ Externally Owned Accounts (EOAs)

These are the accounts that you, the user, control. They are defined by a cryptographic pair of keys: a public key and a private key. Your public key generates your Ethereum address — the 42-character string starting with 0x that you share with others to receive funds. Your private key is your secret credential, which you use to sign transactions and prove that you are the owner of the account. Critically, you never actually “hold” ETH in a traditional sense; you hold the private key that proves ownership of the ETH recorded on the blockchain.

Important: Never share your private key with anyone. Anyone who has your private key has full control over your account and all the assets it holds.

➤ Contract Accounts

These accounts are not controlled by a user, but by the code of a smart contract. When a transaction is sent to a contract account, it triggers the execution of its code. This code can perform a wide range of actions, such as transferring tokens, creating new contracts, or interacting with other contracts. Unlike EOAs, contract accounts cannot initiate transactions on their own — they can only react to incoming transactions.

➤ The Anatomy of an Ethereum Account

Every Ethereum account, whether an EOA or a contract, has four fundamental fields stored in the network’s state:

FieldEOA ValueContract Account ValuePurpose
nonceNumber of transactions sentNumber of contracts createdPrevents replay attacks
balanceETH balance in WeiETH balance in WeiTracks funds (1 ETH = 10^18 Wei)
codeHashHash of empty stringHash of smart contract bytecodeIdentifies the account’s code
storageRootEmpty (default)Root of Merkle Patricia TrieStores contract’s persistent data

The nonce is particularly important for security. Because each transaction from an account must use a sequentially incrementing nonce, it is impossible for an attacker to rebroadcast a previously signed transaction — the network would reject it as a duplicate.

➤ Public and Private Keys: The Foundation of Security

Ethereum uses Elliptic Curve Digital Signature Algorithm (ECDSA) cryptography to generate key pairs. Your private key is a 64-character hexadecimal string generated randomly. From this private key, a public key is derived mathematically. Your Ethereum address is then derived by taking the last 20 bytes of the Keccak-256 hash of the public key. This one-way process means that while anyone can derive your address from your public key, no one can work backwards to find your private key.

The Lifecycle of a Transaction: From Your Wallet to the Blockchain

A transaction is a cryptographically signed instruction from an account that tells the Ethereum network to update its state. Every state change on Ethereum — from sending ETH to calling a smart contract — is the result of a transaction.

Step-by-step infographic showing the 6 stages of an Ethereum transaction: Create & Sign, Broadcast to Network, Validator Picks It Up, Included in a Block, Block Propagated, Finality Achieved.
The six stages every Ethereum transaction goes through, from creation to finality.

What Is Inside a Transaction?

Every transaction submitted to the Ethereum network contains the following fields:

FieldDescription
fromThe sender’s address (must be an EOA)
toThe recipient’s address (EOA or contract)
valueAmount of ETH to send, in Wei
nonceSender’s transaction counter (prevents replays)
gasLimitMaximum gas units the sender is willing to use
maxFeePerGasMaximum total fee per gas unit (base fee + tip)
maxPriorityFeePerGasMaximum tip per gas unit for the validator
dataOptional data field for contract interactions
signatureCryptographic proof that the sender authorized this

The Six Steps of a Transaction

1. Creation and Signing

You create a transaction request (e.g., sending ETH, interacting with a contract) and sign it with your private key. This proves you authorized the transaction and prevents forgery.

2. Broadcasting

Your transaction is broadcast to the Ethereum network and added to the mempool — a waiting area for pending transactions that have been submitted but not yet included in a block.

3. Validator Selection

A validator on the network selects transactions from the mempool to include in a new block. Validators are economically incentivized to prioritize transactions offering a higher priority fee (tip).

4. Inclusion in a Block

Your transaction is bundled with dozens or hundreds of other transactions into a new block. The EVM executes the transaction, updating the network’s state.

5. Block Validation and Propagation

The validator broadcasts the new block to the rest of the network. Other nodes verify the block’s validity and add it to their copy of the blockchain.

6. Finality

Under Ethereum’s Proof of Stake consensus, a transaction achieves economic finality after approximately two epochs (roughly 12.8 minutes). At this point, reversing the transaction would require an attacker to destroy at least one-third of all staked ETH — making it economically irrational.

Types of Ethereum Transactions

Not all transactions are the same. There are three main types:

Transaction TypeDescriptionExample
Regular transferSends ETH from one EOA to anotherSending 0.5 ETH to a friend
Contract deploymentCreates a new smart contract on the networkDeploying a new DeFi protocol
Contract interactionCalls a function on an existing smart contractSwapping tokens on Uniswap

Gas: The Fuel of Ethereum

Every operation on the Ethereum network, from a simple ETH transfer to a complex smart contract interaction, requires a certain amount of computational effort. This effort is measured in gas. Gas fees are the payments users make to have their transactions processed by the network.

Gas serves several critical purposes: it compensates validators for the computational resources they expend, it prevents the network from being spammed with unnecessary transactions, and it provides a mechanism for allocating the network’s limited block space fairly.

Infographic explaining the EIP-1559 gas fee model: Total Fee = Gas Used × (Base Fee + Priority Fee). Shows base fee, priority fee, gas limit, and a worked example of a simple ETH transfer.

➤ The EIP-1559 Gas Fee Model

Before August 2021, gas fees were determined by a simple auction: users bid for block space, and validators included the highest bidders. This made fees unpredictable and often resulted in users overpaying. EIP-1559 introduced a new model that separates the fee into two components and burns part of it, making ETH a deflationary asset.

Total Fee = Gas Used × (Base Fee + Priority Fee)

➤ Base Fee vs. Priority Fee: What’s the Difference?

The base fee is set by the protocol itself and adjusts automatically based on network congestion. If the previous block was more than 50% full, the base fee increases by up to 12.5%. If it was less than 50% full, it decreases by up to 12.5%. This mechanism makes fees more predictable. Crucially, the base fee is burned — it is permanently removed from circulation, reducing the total supply of ETH over time.

The priority fee (also called a “tip”) is an optional amount you add on top of the base fee. This tip goes directly to the validator who includes your transaction in a block. A higher tip makes your transaction more attractive to validators and can result in faster confirmation during periods of high demand.

➤ Gas Limit and Unused Gas

The gas limit is the maximum amount of gas you are willing to spend on a transaction. For a simple ETH transfer, the gas limit is always 21,000 units. For smart contract interactions, it can be much higher. If your transaction uses less gas than the limit, the unused portion is refunded to you. If your transaction runs out of gas mid-execution, the EVM reverts all state changes, but you still pay for the gas that was consumed up to that point.

➤ A Real-World Gas Fee Example

Let’s say you want to send 1 ETH to a friend. The current base fee is 10 gwei, and you set a priority fee of 2 gwei. A standard ETH transfer uses 21,000 gas units.

Total Fee = 21,000 × (10 + 2) gwei = 252,000 gwei = 0.000252 ETH

– Your account is debited: 1.000252 ETH
– Your friend receives: 1.0 ETH
– The base fee burned: 0.00021 ETH
– The validator receives as tip: 0.000042 ETH

For a full breakdown of how gas fees are calculated and how to minimize them, read our guide: Gas Fees Explained: Understanding Ethereum Transaction Costs

The Ethereum Virtual Machine (EVM): The Heart of the Network

The EVM is the runtime environment for smart contracts on Ethereum. It is a sandboxed virtual machine — completely isolated from the host computer’s file system, network, and other processes. This isolation is what makes it safe to run code written by anyone in the world: the EVM cannot reach outside its sandbox, no matter what the code tries to do.

Every node on the Ethereum network runs an identical copy of the EVM. When a transaction triggers a smart contract, every node executes the same code and arrives at the same result. This determinism is what makes Ethereum trustless: you don’t need to trust any single party, because the outcome is mathematically guaranteed.

Layered architecture diagram of the EVM showing: Smart Contract Bytecode, EVM Execution Engine (Stack, Memory, Storage), Gas Metering, and State Output.

How the EVM Executes Smart Contracts

Smart contracts are written in high-level languages like Solidity, but they are compiled down to EVM bytecode — a series of low-level instructions — before being deployed. When a transaction triggers a contract, the EVM reads the bytecode instruction by instruction and executes each one. Each instruction has a corresponding gas cost, which is deducted from the transaction’s gas limit as execution proceeds.

Stack, Memory, and Storage: The Three Data Stores

The EVM uses three distinct types of data storage, each with different characteristics and costs:

Data StorePersistenceGas CostDescription
StackPer instructionVery lowA last-in, first-out (LIFO) structure with a depth of 1,024 items. Used for intermediate calculations during execution.
MemoryPer transactionMediumA temporary byte array that is cleared at the end of each transaction. Used for larger, temporary data.
StoragePermanentHighA persistent key-value store associated with the contract account. Writing to storage is the most expensive EVM operation because it modifies the global state.

Opcodes: The Language of the EVM

EVM bytecode is made up of opcodes — single-byte instructions that tell the EVM what to do. There are over 140 opcodes in the EVM instruction set, covering everything from basic arithmetic (ADD, SUB, MUL) to blockchain-specific operations (BALANCE, BLOCKHASH, SSTORE). Each opcode has a defined gas cost, reflecting the computational resources it requires.

Blocks: How Transactions Are Grouped and Finalized

Transactions are not processed one by one. Instead, they are grouped together into blocks — batches of transactions that are validated and added to the blockchain together. Each block references the hash of the previous block, forming the “chain” in blockchain.

What Is Inside an Ethereum Block?

  • block header with metadata (timestamp, block number, parent hash, etc.)
  • A list of transactions (typically dozens to hundreds per block)
  • The state root — a cryptographic fingerprint of the entire Ethereum state after all transactions in the block have been applied
  • The validator’s signature proving they created the block

Ethereum targets a new block approximately every 12 seconds. Each block has a gas limit — a cap on the total amount of gas all transactions in the block can consume. This limits the computational work per block and keeps the network manageable.

How Finality Works After The Merge

After Ethereum’s transition to Proof of Stake (known as “The Merge” in September 2022), the concept of finality changed significantly. Under Proof of Stake, blocks are organized into slots (12 seconds each) and epochs (32 slots = ~6.4 minutes). A transaction achieves economic finality after two epochs (approximately 12.8 minutes), at which point reversing it would require an attacker to burn at least one-third of all staked ETH — a cost so enormous it makes attacks economically irrational.

Layer 2 Scaling Solutions: Making Ethereum Faster and Cheaper

To handle the high demand for block space and keep transaction fees low, Ethereum relies on Layer 2 scaling solutions. These are separate blockchains that run on top of the main Ethereum chain (Layer 1). They process transactions off-chain, bundle them together, and then submit a compressed summary to the main chain. This allows them to offer significantly faster and cheaper transactions while still inheriting the security of the Ethereum network.

Infographic showing how Layer 2 solutions (Optimistic Rollups, ZK-Rollups, State Channels) process transactions off-chain and submit compressed batches to Ethereum Layer 1.

➤ Optimistic Rollups

Optimistic Rollups (used by networks like Arbitrum and Optimism) process transactions off-chain and assume they are all valid by default — hence “optimistic.” They submit batches of transactions to Layer 1 along with a bond. If anyone detects a fraudulent transaction, they can submit a fraud proof within a challenge window (typically 7 days) to dispute it. This model offers high throughput and is compatible with existing Ethereum smart contracts.

➤ ZK-Rollups

ZK-Rollups (used by networks like zkSync and Starknet) use zero-knowledge proofs to cryptographically prove that a batch of transactions is valid, without revealing the underlying data. This means they can achieve near-instant finality on Layer 1 without a challenge window. ZK-Rollups are considered the more technically advanced solution and are expected to dominate the scaling landscape in the long term.

Learn more about the different types of Layer 2s in our guide: Layer 2 Solutions Explained: Arbitrum, Optimism, and Ethereum Scaling

Key Takeaways

Discover more

Frequently Asked Questions

What is the difference between an EOA and a contract account?

An EOA (Externally Owned Account) is controlled by a user with a private key and can initiate transactions. A contract account is controlled by smart contract code and can only execute operations in response to a transaction it has received. Both types can hold ETH and interact with other contracts.

Why do I need to pay gas fees?

Gas fees compensate validators for the computational resources they use to process your transaction and secure the network. They also prevent the network from being spammed with unnecessary transactions. Under EIP-1559, part of the fee (the base fee) is burned, which reduces the total supply of ETH over time.

What happens if my transaction runs out of gas?

If your transaction runs out of gas during execution, the EVM reverts all state changes made by that transaction. However, you still pay for the gas that was consumed up to that point — the work was done, even if the transaction ultimately failed.

What is the EVM?

The Ethereum Virtual Machine (EVM) is the runtime environment for smart contracts on Ethereum. It is a sandboxed, deterministic virtual machine that executes smart contract bytecode. Every node on the Ethereum network runs an identical copy of the EVM, ensuring that all nodes reach the same result for any given transaction.

How long does an Ethereum transaction take to finalize?

A transaction is typically included in a block within a few seconds to a few minutes, depending on the gas fee you offer. However, economic finality — the point at which reversing the transaction would be economically irrational — is achieved after approximately two epochs, or about 12.8 minutes.

What is the mempool?

The mempool (short for “memory pool”) is a waiting area for transactions that have been broadcast to the network but have not yet been included in a block. Validators select transactions from the mempool to include in new blocks, typically prioritizing those with higher priority fees.

Valery"Val" Kovalenko

Valery Kovalenko is a Ukrainian blockchain enthusiast and self-proclaimed "Ethereum maximalist with a sense of humor." When he's not explaining gas fees to his grandmother or arguing about Layer 2 solutions on Twitter, he's probably debugging smart contracts while eating varenyky. Val discovered Ethereum in 2016 after accidentally sending Bitcoin to the wrong address and decided there had to be a better way.