Introduction
Blockchain is an append-only distributed ledger where each block cryptographically links to the previous one. Immutability is guaranteed by hash chaining: altering any block invalidates all subsequent hashes. Consensus mechanisms ensure all nodes agree on the canonical chain without a central authority.
Block Structure
The block header contains: previous_block_hash, merkle_root, timestamp, nonce, difficulty_target, and version. The block body is a list of transactions. The block hash is computed as SHA256(SHA256(header)). For Proof of Work, the block_hash must be less than the difficulty_target. For Proof of Stake, the block is signed by the selected validator. Blocks are linked by including the previous_block_hash in each header, forming the chain.
Merkle Tree
The Merkle tree is a binary tree of transaction hashes. Leaf nodes are SHA256(transaction). Internal nodes are SHA256(left_child + right_child). The root is the Merkle root stored in the block header. This structure enables Merkle proofs: proving a transaction is included in a block with O(log N) hashes, without downloading the full block. SPV (Simplified Payment Verification) clients use Merkle proofs to verify transactions efficiently.
Proof of Work
Miners compete to find a nonce such that SHA256(SHA256(header)) is less than the difficulty_target. The process is probabilistic: expected solve time equals difficulty divided by hash_rate. Difficulty is adjusted every 2016 blocks to target a 10-minute block time. PoW is energy-intensive. A 51% attack requires controlling the majority of the network hash rate. Orphan blocks occur when two valid blocks are found simultaneously; the network eventually converges on one.
Proof of Stake
Validators stake collateral (cryptocurrency) to be eligible to propose and attest to blocks. A validator is selected proportionally to their stake. Ethereum’s PoS requires 32 ETH stake per validator; committees of validators attest to blocks each epoch (32 slots). Slashing penalizes validators for equivocating (signing conflicting blocks). PoS is energy-efficient compared to PoW. A 51% attack requires controlling 51% of the total staked value.
UTXO vs Account Model
Bitcoin uses the UTXO (Unspent Transaction Output) model: each transaction consumes previous UTXOs and creates new ones. Benefits include privacy (each transaction can use new addresses) and parallel validation (independent UTXO sets can be validated concurrently). Ethereum uses the account model: each address has a balance, a nonce (prevents replay), and contract storage. The account model is simpler for smart contracts. Sequential nonces prevent transaction replay attacks.
Transaction Validation
Validation steps: check that the signature is valid (sender signed with their private key); check that inputs are unspent (UTXO not previously spent, or account has sufficient balance); check that the nonce is correct (account model); check that the fee is at or above the minimum fee. Valid transactions are added to the mempool. Nodes gossip valid transactions across the P2P network.
Smart Contracts
Smart contracts are code deployed to the blockchain as bytecode (Ethereum EVM). All validating nodes execute them deterministically. State is stored in each account’s storage trie. Gas limits computation cost and prevents infinite loops. Solidity compiles to EVM bytecode. Deploying a contract creates a new account with a code hash. Contract calls trigger state transitions recorded on-chain.
See also: Coinbase Interview Guide
See also: Stripe Interview Guide 2026: Process, Bug Bash Round, and Payment Systems