02 — Blockchain Fundamentals

Concepts, vocabulary, design principles, theoretical models. Prerequisite for understanding the other files.


1. Definition

Blockchain = an append-only distributed ledger where blocks of transactions are chained by cryptographic hashes, with decentralized consensus for ordering and validity.

Minimum components:

  1. Chained data structure: block \(n\) contains the hash of block \(n-1\).
  2. Consensus mechanism: a rule for accepting the next block among nodes without central coordination.
  3. Incentive system: native tokens to align miners/validators.
  4. Cryptographic identity: public keys as pseudonyms.

Differences from traditional databases

Aspect RDBMS Blockchain
Trust Operator is the root of trust No root of trust; consensus
Throughput 1M+ TPS 7 (Bitcoin) to 100k (Solana)
Latency ms s to min
Append-only Optional By design
Reversibility Yes Costly (hard fork)
Auditing Internal logs Public on-chain
Scalability Vertical + sharding Limited by consensus

2. Basic vocabulary

Term Definition
Block A set of transactions + header (prevhash, timestamp, nonce, merkleroot).
Block height The sequential number of the block since genesis.
Tx (transaction) An atomic operation: transfer, contract call, data inscription.
UTXO Unspent Transaction Output (Bitcoin model).
Account model Ethereum model: per-address state (balance + storage).
Mempool Pool of unconfirmed broadcasted txs.
Confirmation Number of blocks after the block containing the tx.
Finality Guarantee that a tx will not be reverted. Probabilistic (PoW) or deterministic (BFT).
Fork A divergence of the chain. Soft fork (backward-compat) vs hard fork.
Reorg (reorganization) Chain replacement: a node swaps its tip for a longer/heavier chain.
Genesis block Block 0; configured at launch.
Coinbase tx A special tx that creates new coin as a reward to the miner/validator.
Halving Bitcoin: mining reward drops 50% every 210k blocks (~4 years).
Difficulty The hash target that PoW must reach. Auto-adjusted.
Hashrate Total hashing speed of the network (H/s).
TPS Transactions Per Second.
Gas Unit of "work" for a tx in Ethereum-like chains.
Gas price Price per unit of gas in wei (10⁻¹⁸ ETH).
Slippage Difference between expected and executed price on a DEX.
MEV Maximal Extractable Value — profit from reorderinginsertingcensoring txs.
Sandwich attack MEV: front-run + back-run of a vulnerable tx.
Liquidation Forced sale of collateral in lending when the ratio falls.
Slashing Penalty (loss of stake) for a validator misbehaving in PoS.
TVL Total Value Locked — capital deposited in a protocol.
Bridge A system to transfer value between different chains.
Wrapped token An IOU token representing another asset (WBTC, wETH).
DAO Decentralized Autonomous Organization — governance via token voting.
Vesting Schedule for unlocking tokens.
Cliff Initial period with no unlock before vesting begins.
Airdrop Free distribution of tokens.
Yield farming Strategy of providing liquidity to earn reward tokens.
Impermanent loss LP loss from relative fluctuation of pairs vs simple HODL.
Composability "Money legos": composable protocols (output = input of the next).
Permissionless Anyone can useparticipateaudit.
Permissioned Controlled access (Hyperledger, R3 Corda).
Oracle A system that delivers off-chain data on-chain (Chainlink, Pyth).
Settlement Final settlement on the L1.
DA (Data Availability) Guarantee that tx data is accessible for verification.
Validity proof Mathematical proof (zk) of correct execution.
Fraud proof A mechanism that allows contesting an invalid tx (optimistic rollup).
Sequencer The entity that orders txs in a rollup (centralized today in most).
Fork choice rule The rule for choosing the canonical chain (LMD-GHOST in Ethereum PoS).

3. Fundamental properties

Immutability

Block \(n\) contains \(H(\text{block}_{n-1})\). Changing an old block = recompute all subsequent hashes + outvalue the work of the entire network.

It is not absolute: hard forks rewrite (DAO 2016, BSVBCHBTC). "Immutability" is practical resistance to tampering, not mathematical impossibility.

Decentralization

3 dimensions (Vitalik 2017, The Meaning of Decentralization):

  1. Architectural: number of physical machines (Bitcoin: ~15k full nodes, millions of SPV).
  2. Political: number of individuals/organizations in control.
  3. Logical: the state is unique (≠ logically decentralized).

Blockchain: architecturally + politically decentralized; logically centralized (1 ledger).

Censorship resistance

An attacker can pay more to exclude your tx temporarily (front-running through the fee market), but eventually another miner/validator includes it. Nakamoto consensus assumes 50%+ honest.

Trustlessness (partial)

"Don't trust, verify". You verify mathematics + consensus, not a person. But: trust in the protocol design, in the code, in the majority of validators being honest, in the compiler, in the hardware...

Final settlement

A tx confirmed after \(k\) blocks is (probabilistically in PoW, deterministically in BFT) immutable.


4. Vitalik's Trilemma (Scalability Trilemma)

Vitalik Buterin, 2017: a blockchain can optimize 2 of 3:

  1. Decentralization — anyone can validate.
  2. Security — resistance to attack at a reasonable hardware cost.
  3. Scalability — high throughput (TPS).

Bitcoin/Ethereum L1: dec + sec, sacrifices scalability. Solana: sec + scalability, sacrifices dec (high HW cost to validate). Permissioned chains: scalability + sec, sacrifice decentralization.

Modern solutions: rollups (L2) attack the trilemma by assuming L1 dec+sec, but moving execution off to an L2 that can optimize scalability without compromising the L1.


5. CAP / FLP / Byzantine generals

CAP (Brewer 2000)

A distributed system under network partition can guarantee 2 of:

  • Consistency
  • Availability
  • Partition tolerance

In blockchain (always P), one chooses between C (BFT, finality) and A (Nakamoto, eventual consistency).

FLP (Fischer-Lynch-Paterson 1985)

In an asynchronous network with 1 failure, deterministic consensus is impossible. Workarounds:

  • Synchronous (assumes timing bounds): PBFT, Tendermint.
  • Probabilistic: Nakamoto consensus.
  • Randomized: Algorand (VRF-based).

Byzantine Generals Problem (Lamport-Shostak-Pease 1982)

Given \(n\) generals, \(f\) traitors, reach consensus:

  • Synchronous authenticated: \(n \geq f + 1\) suffices.
  • Synchronous unauthenticated: \(n \geq 3f + 1\) (Lamport's bound).
  • Asynchronous authenticated: \(n \geq 3f + 1\) (Castro-Liskov PBFT).

Blockchain: assumes a Byzantine adversarial environment (miners can lie, censor, mining pools cooperate).


6. Tx models

UTXO (Bitcoin)

State = a set of UTXOs (Unspent Transaction Outputs). Each UTXO has (value, script).

A tx consumes UTXOs (inputs) and creates UTXOs (outputs). Total in ≥ total out (the difference = fee).

Advantages:

  • Parallelism (independent txs can process simultaneously).
  • Privacy (each UTXO goes to a new address).
  • Stateless per-tx validation (input scripts are self-sufficient).

Disadvantages:

  • Complex smart contracts are hard (no persistent state).
  • The UTXO set grows; a storage challenge.

Account-based (Ethereum)

State = map[address] → (balance, nonce, code, storage).

Tx = (from, to, value, data, gas, signature).

Advantages:

  • Natural smart contracts.
  • Replay protection via nonce.
  • Storage rent / state expiry possible.

Disadvantages:

  • Sequential (txs from the same from need ordering).
  • Replay across chains: needs a chain ID (EIP-155).
  • Complex state management.

Hybrid / others

  • Cardano (eUTXO): UTXO + more expressive scripts.
  • Sui (object-centric): objects instead of accounts.
  • MimbleWimble (Beam, Grin): confidential UTXOs + cut-through.

7. Cryptographic primitives (review)

For details see ../cryptography/. Usage summary:

Primitive Use in blockchain
SHA-256 Bitcoin block hash, txid (double-SHA256), Merkle tree
Keccak-256 Ethereum address, contract address, MPT, EVM SHA3 opcode
RIPEMD-160 Bitcoin address (HASH160 = RIPEMD160(SHA256))
secp256k1 Bitcoin/Ethereum signing curve (ECDSA)
Schnorr (BIP340) Bitcoin Taproot
Ed25519 Solana, Cardano, Algorand, Near, Stellar
BLS12-381 Ethereum 2.0 consensus (signature aggregation)
BN254 Ethereum SNARK precompiles
Pedersen commitments Confidential Transactions (Monero, Mimblewimble)
Bulletproofs Range proofs (Monero)
zk-SNARKs (Groth16) Zcash Sapling, Polygon zkEVM
zk-STARKs StarkNet, Polygon Zero
Halo2 Zcash Orchard, Scroll
Verifiable Random Function (VRF) Algorand, Cardano Praos, Chainlink VRF
Verifiable Delay Function (VDF) Filecoin, Ethereum (planned), Chia

8. Wallets

Self-custody (non-custodial)

The user controls the private keys. Not your keys, not your coins.

  • Hot wallets: software, connected to the internet. MetaMask, Phantom, Rabby, Frame.
  • Cold wallets: offline. Hardware (Ledger, Trezor, Coldcard, Keystone), paper wallets, air-gapped computers.
  • Smart wallets / smart contract wallets: ERC-4337 (account abstraction). Argent, Safe (Gnosis), Coinbase Smart Wallet.

Custodial

The operator holds the keys. Coinbase, Binance, exchanges. Convenience vs counterparty risk.

Backup standards

  • BIP-32: hierarchical deterministic.
  • BIP-39: 12/24-word mnemonic seed.
  • BIP-44: multi-coin / account derivation paths.
  • SLIP-39: Shamir secret sharing backup (Trezor).

Smart contract wallets

ERC-4337 (Account Abstraction) features:

  • Multisig.
  • Social recovery.
  • Spend limits.
  • Batched txs.
  • Custom signature schemes (passkey, hardware).
  • Paymasters (someone pays gas for the user — sponsorship).

9. Network topology

P2P architecture

  • Full node: stores the entire chain, validates everything.
  • Pruned node: the entire chain but discards old data.
  • Light client / SPV: only headers + Merkle proofs on demand (BIP-37, BIP-157/158 Compact Filters).
  • Archive node: the entire chain + historical state of each block.
  • Relay node: forwards without validating (mining pools).

Bootstrap

Bitcoin: hardcoded DNS seeds (seed.bitcoinstats.com, etc.) → discover peers. Ethereum: ENR (Ethereum Node Records, EIP-778) + DHT discovery.

Networking

  • Bitcoin: TCP port 8333, plain (Tor optional).
  • Ethereum: devp2p RLPx (encrypted), execution layer port 30303; consensus layer libp2p port 9000.
  • Solana: custom UDP gossip protocol.

10. Encoding and serialization

Codec Use
RLP (Recursive Length Prefix) Ethereum encoding
SSZ (Simple Serialize) Ethereum 2.0 consensus encoding
Borsh Solana, Near
Bincode Solana derived
Protobuf Tendermint, Cosmos
Cap'n Proto some L2s
DER DER signatures Bitcoin pre-Schnorr
JSON-RPC Most blockchain APIs

11. Address formats

Chain Format Example
Bitcoin (legacy P2PKH) Base58Check 1... 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
Bitcoin (P2SH) Base58Check 3... 3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy
Bitcoin (Bech32 SegWit) bc1q... bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4
Bitcoin (Taproot) Bech32m bc1p... bc1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqzk5jj0
Ethereum hex 20 bytes 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 (vitalik.eth)
Solana Base58 So11111111111111111111111111111111111111112 (wSOL)
Cosmos Bech32 with prefix cosmos1... cosmos1...
Cardano Bech32 addr1... addr1q9...
Tron Base58Check with prefix T TKkeiboTkxXKJpbmVFbv4a8ov5rAfRDMf9
Polkadot SS58 1FRMM8PEiWXYax7rpS6X4XZX1aAAxSWx1CrKTyrVYhV24fg
TON base64url or raw EQDrjaLahLkMB-hMCmkzOyBuHJ139ZUYmPHu6RRBKnbdLIYI

ENS (Ethereum Name Service): vitalik.eth resolves to 0xd8dA... — human-readable on Ethereum.


12. Addresses + privacy

A public chain = everyone sees:

  • The balance of each address.
  • The complete tx history.
  • Counterparties.
  • Timing patterns.

Pseudonymity ≠ anonymity. Chain analysis heuristics (Chainalysis, TRM, Elliptic):

  • Common input ownership: txs with multiple inputs probably belong to the same owner.
  • Change address detection: identifying change vs receiver.
  • Address clustering: grouping addresses of the same owner.
  • Off-chain data: exchange KYC + on-chain links.

Mitigations:

  • CoinJoin (Wasabi, Samourai, Whirlpool).
  • Privacy coins (Monero, Zcash, Dash PrivateSend).
  • Tornado Cash (sanctioned).
  • Wrapping in privacy-focused rollups (Aztec).

13. Typical Web3 stack

┌──────────────────────────────────────────────┐
│  Frontend (React, Next.js, Vue)              │
│  + WalletConnect, RainbowKit, ConnectKit     │
├──────────────────────────────────────────────┤
│  Wallet (MetaMask, Phantom, Rabby, Coinbase) │
├──────────────────────────────────────────────┤
│  RPC provider (Alchemy, Infura, QuickNode,   │
│  self-hosted node)                           │
├──────────────────────────────────────────────┤
│  Smart contracts (Solidity, Vyper, Rust)     │
│  + libraries (OpenZeppelin, Solady)          │
├──────────────────────────────────────────────┤
│  L1/L2 chain                                 │
└──────────────────────────────────────────────┘

Indexers/data: The Graph, Goldsky, Subsquid, Dune Analytics. Oracles: Chainlink, Pyth, RedStone, API3. Dev tools: Hardhat, Foundry, Truffle (legacy), Anchor (Solana), Anvil/forge. Testing: Foundry (Solidity-native), Hardhat + Mocha, Brownie (Python).


14. State of the art 2026

  • Bitcoin: monetary Layer 1; L2 evolution (Lightning + Stacks + Arch + Babylon).
  • Ethereum: settlement + DA layer; execution on L2s (Arbitrum, Base, OP, Scroll, zkSync).
  • Solana: high-perf monolithic L1; competitive in UX + speed.
  • Cosmos: app-chain ecosystem; IBC interoperability.
  • Polkadot: parachains, shared security, relay chain.
  • Modular thesis: separation of execution / settlement / DA / consensus (Celestia, EigenDA, Avail).

Statistics (~May 2026):

  • Bitcoin marketcap: ~US$ 2.5T.
  • Ethereum marketcap: ~US$ 600B.
  • Total crypto marketcap: ~US$ 4T.
  • Stablecoin marketcap: ~US$ 250B.
  • DeFi TVL: ~US$ 200B.
  • Daily DEX volume: ~US$ 10B.

15. Bibliography

  • Antonopoulos, Mastering Bitcoin, O'Reilly 2017 (free github), 3rd ed.
  • Antonopoulos + Wood, Mastering Ethereum, O'Reilly 2018.
  • Narayanan, Bonneau, Felten, Miller, Goldfeder, Bitcoin and Cryptocurrency Technologies, Princeton 2016 (free).
  • Werner, Perez, Gudgeon, Klages-Mundt, Harz, Knottenbelt, SoK: Decentralized Finance (DeFi), AFT 2022.
  • Zamyatin et al., SoK: Communication Across Distributed Ledgers (2021).
  • Vitalik Buterin's blog: vitalik.ca / vitalik.eth.limo.
  • Bitcoin Optech newsletter (bitcoinops.org/en/newsletters/).
  • Ethereum Research forum: ethresear.ch.
  • 0xResearch (Blockworks) podcast.
  • Bankless newsletter/podcast.
  • Messari research reports.

16. Cross-reference

  • Crypto primitives: ../cryptography/10-criptomoeda.md.
  • Consensus detail: 03-consensus.md.
  • Specific chains: 04-l1-bitcoin.md, 05-l1-ethereum.md, 06-l1-alt.md.
  • DeFi: 09-defi.md.
  • Regulation: 13-regulation.md.