The EVM, Accounts, Gas & Transactions

The EVM is a stack-based virtual machine with a word size of 256 bits.

2.1 The Ethereum Virtual Machine

The EVM is a stack-based virtual machine with a word size of 256 bits. During execution it has access to:

one call frame up to 1024 words of 32 bytes; only the top 16 reachable directly byte-addressable, linear, zero-initialized, expands in 32-byte words (quadratic cost) per-contract key-value map of 32-byte slots to 32-byte values; very expensive like storage but cleared at end of transaction (EIP-1153, Cancun 2024) read-only input bytes of the call bytes returned by the last external call the contract's immutable bytecode permanent (in receipts) event data; not readable by contracts

Execution is deterministic and sandboxed. Each opcode costs gas (e.g., ADD 3 gas, SSTORE up to 20,000 gas for a zero→nonzero write, SLOAD 2,100 gas cold / 100 gas warm).

2.2 Accounts

Ethereum has two kinds of accounts, both identified by a 20-byte address:

Externally Owned Account (EOA) private key (secp256k1) no (except EIP-7702 delegation, below) Can start transactions no — only reacts to calls nonce, balance nonce, balance, codeHash, storageRoot

An EOA address is the last 20 bytes of keccak256(publicKey). Since the Pectra upgrade (May 2025), EIP-7702 lets an EOA set a *delegation designator* so that it executes the code of a chosen contract — bringing smart-account features (batching, sponsored gas) to existing EOAs. Consequently, "has no code" no longer guarantees "is an EOA".

2.3 Transactions

A transaction is a signed message from an EOA. Main fields:

sequence number of the sender, prevents replay recipient address (empty for contract creation) wei to transfer data / input calldata: function selector + encoded arguments, or init code maximum gas the sender is willing to use maxFeePerGas, maxPriorityFeePerGas EIP-1559 fee parameters prevents cross-chain replay (EIP-155) v, r, s / yParity optional pre-declared addresses/slots (EIP-2930)

Transaction types: legacy (type 0), access-list (type 1), EIP-1559 (type 2, the default), blob (type 3, EIP-4844, used by rollups), and set-code (type 4, EIP-7702).

A message call is an internal call from one contract to another; it is not a transaction itself but runs within one.

2.4 Gas and fees (EIP-1559)

Gas used × effective gas price = fee paid.

Each block has a base fee that adjusts automatically with demand; the base fee is burned.

The priority fee (tip) goes to the block proposer.

effectiveGasPrice = min(maxFeePerGas, baseFee + maxPriorityFeePerGas).

If execution runs out of gas, all state changes revert, but the gas used is still charged.

Unused gas is refunded. Storage-clearing refunds are capped at 1/5 of gas used (EIP-3529).

Base cost of any transaction Calldata byte (zero / nonzero) 4 / 16 (EIP-7623 raises the floor for data-heavy transactions) SSTORE zero → nonzero 20,000 (+2,100 if cold) SSTORE nonzero → nonzero 2,900 (+2,100 if cold) SLOAD cold / warm TSTORE / TLOAD CALL to cold address 2,600 + value transfer costs 375 + 375 per topic + 8 per data byte 32,000 + 200 per byte of deployed code

2.5 Transaction lifecycle

User signs tx (wallet) ──► broadcast to mempool (public or private relay)
        │
        ▼
Block builder orders txs (MEV) ──► proposer includes block
        │
        ▼
Every node executes the tx in the EVM ──► state root updated, receipt + logs stored
        │
        ▼
Block attested ──► justified ──► finalized (~13 min)

2.6 Calls vs transactions

Read-only calls (eth_call) run locally on a node, cost nothing, and change nothing — used for view/pure functions.

Transactions (eth_sendRawTransaction) change state, cost gas, and must be mined.