Ethereum blockchain
TL;DR: A replicated state machine: accounts hold balance + code + storage, the EVM mutates them deterministically per transaction, miners/proposers order blocks and you pay in gas. This is the mental model you need to read traces and reason about smart-contract bugs.
What it is
Ethereum is a quasi-Turing-complete distributed virtual machine. State is a Merkle-Patricia trie keyed by 20-byte addresses; each account is either an EOA (externally owned, controlled by a secp256k1 keypair) or a contract (code + per-account storage trie). A transaction is a signed message that triggers EVM execution, charging gas for every opcode. Since The Merge (Sep 2022) consensus is proof-of-stake; the post-Dencun (Mar 2024) data layer adds blob-carrying transactions (EIP-4844) used by rollups.
Preconditions / where it applies
- Reading on-chain state, decoding tx traces, or writing PoCs that interact with mainnet/forknet
- Understanding why a transaction reverted, who can call a function, what storage slot holds what
- Building or auditing anything that runs on an EVM chain (Ethereum, Arbitrum, Optimism, Base, Polygon, BSC, Avalanche C-chain)
Technique
Key primitives to internalise:
- Accounts. EOA = address derived from
keccak256(pubkey)[12:]. Contract = address derived fromkeccak256(rlp(sender, nonce))[12:]forCREATEorkeccak256(0xff || sender || salt || keccak256(initcode))[12:]forCREATE2. - Gas. Every opcode has a cost; tx specifies
maxFeePerGas/maxPriorityFeePerGas(EIP-1559). Thebase feeis burned, priority fee paid to the proposer. Out-of-gas = revert. - Storage. Per-contract slot map.
mapping(k => v)lives atkeccak256(abi.encode(k, slot)). Usecast storage <addr> <slot>to read. - Calls.
CALLruns target code in target context.DELEGATECALLruns target code in caller’s context (used by proxies — and the source of many ownership bugs).STATICCALLforbids state writes. - Logs / events. Indexed topics + data, written to bloom filters in the block. The canonical attribution source.
- Reading state:
1 2 3
cast call 0xCONTRACT "balanceOf(address)(uint256)" 0xVICTIM --rpc-url $RPC cast storage 0xCONTRACT 0 cast 4byte-decode 0xa9059cbb000...
- Forking for PoC.
anvil --fork-url $RPC --fork-block-number Ngives you a local mainnet clone where you canvm.prankany address.
Detection and defence
- Defenders use trace-level monitoring (Tenderly, Phalcon, OpenZeppelin Defender) to flag suspicious
selfdestruct,delegatecall, largetransfers. - For RPC providers: rate-limit
eth_callwith high gas, watch fordebug_traceCallabuse. - For users: hardware wallets, EIP-712 typed-data signing prompts, and address book / simulation in the wallet UI.
Related: smart-contracts-overview, solidity-basics, foundry-toolkit.
References
- Ethereum.org developer docs — accounts, txs, EVM, gas, consensus
- Yellow Paper — formal EVM spec
- EVM Codes — opcode reference with gas costs
- EIP-1559 — fee market
- EIP-4844 — blob transactions