Hashtag Web3 Logo

How Blockchains Work

12 min
beginner

What problem does a blockchain solve?

Imagine you and a friend keep score in a game, but you each write the score on your own paper. If there is a disagreement, who is right?

A blockchain solves this by giving everyone the same paper, and making it so nobody can erase what was already written.

In the real world, this matters for money. If Alice sends $100 to Bob, how do both sides know the money actually moved? Today, a bank keeps the record. A blockchain replaces the bank with math and thousands of computers.

Blocks: bundles of transactions

A blockchain is, quite literally, a chain of blocks.

Each block is a container. It holds a list of recent transactions — "Alice sent 2 ETH to Bob," "Charlie sent 0.5 ETH to Diana," and so on. A typical Ethereum block holds a few hundred transactions.

Block #1 Prev hash: 0000... Timestamp: Jan 2015 Alice → Bob: 2 ETH Eve → Frank: 1 ETH Grace → Hank: 5 ETH Hash: a3f8... Block #2 Prev hash: a3f8... Timestamp: Jan 2015 Bob → Carol: 1 ETH Dana → Eve: 3 ETH Frank → Grace: 2 ETH Hash: 7b2c... Block #3 Prev hash: 7b2c... Timestamp: Jan 2015 Hank → Alice: 4 ETH Bob → Dana: 1 ETH Carol → Eve: 2 ETH Hash: d91e...

Notice the blue text: each block's "Previous hash" matches the hash of the block before it. This is what creates the chain. If you change even one character in Block #1, its hash changes completely, and Block #2's "Previous hash" would no longer match. The chain breaks.

Hashes: digital fingerprints

A hash is a fingerprint for data. You feed any amount of data into a hash function, and it spits out a fixed-length string of characters. The same input always gives the same output. But change even one letter, and the output is completely different.

"Hello World" SHA-256 a591a6d40bf420404a011733cfb7b190... "Hello World!" SHA-256 7f83b1657ff1fc53b92dc18148a1d65d... Adding one character ("!") completely changes the output. This is called the "avalanche effect."

This is what makes blockchains tamper-proof. Each block contains the hash of the previous block. Change one old transaction, and its block's hash changes. That breaks every block after it. To fake a transaction, you would need to redo the hash for every block that comes after — and do it faster than the entire network adds new ones.

Nodes: thousands of copies

A blockchain does not live on one computer. It lives on thousands of computers called nodes. Each node keeps a complete copy of the entire blockchain.

New Transaction Alice → Bob: 2 ETH 💻 Node 1 ✓ Valid 💻 Node 2 ✓ Valid 💻 Node 3 ✓ Valid 💻 Node 4 ✓ Valid 🏴‍☠️ Attacker ✗ Rejected

When someone broadcasts a transaction, every node checks it independently. Does Alice actually have 2 ETH? Is the signature valid? If most nodes agree the transaction is good, it gets included in the next block.

If an attacker tries to submit a fake transaction, the other nodes reject it. To successfully cheat, an attacker would need to control the majority of the network's computing power (in Proof of Work) or staked tokens (in Proof of Stake) — which for large blockchains costs billions of dollars.

Consensus: how nodes agree

With thousands of independent computers, how do they agree on which transactions are valid and in what order? This is called consensus, and it is the hardest problem in blockchain design.

There are two main approaches:

Proof of Work Used by: Bitcoin How it works: 1. Miners race to solve a math puzzle 2. First to solve it gets to add the block 3. Winner earns a reward (new coins) Security model: Cheating requires more computing power than the entire network. ⚡ Downside: Uses a lot of energy Proof of Stake Used by: Ethereum How it works: 1. Validators lock up tokens as collateral 2. Network picks a validator randomly 3. Validator proposes the next block Security model: Cheating means losing your staked tokens (called "slashing"). ✓ Uses 99.95% less energy

Proof of Work is like a lottery where buying a ticket requires solving a hard math problem. The more computing power you have, the more tickets you buy. Bitcoin uses this method.

Proof of Stake is like a security deposit. Validators put up their own money (ETH) as collateral. If they act honestly, they earn a small reward. If they try to cheat, their deposit gets taken away. Ethereum switched to Proof of Stake in September 2022 and now uses 99.95% less energy than before.

How a transaction actually works

When you send ETH to someone, here is what happens step by step:

1. You sign Your wallet signs the transaction with your key 2. Broadcast Transaction sent to the network (mempool) 3. Validate Nodes check: do you have enough ETH? 4. Confirmed Added to a block. Done. Irreversible. ~1 second ~1 second ~12 seconds ~12 seconds

On Ethereum, new blocks are added every 12 seconds. Once your transaction is in a block, it is permanent. After a few more blocks are added on top, it becomes practically impossible to reverse.

Why this matters

Blockchains are slow (12 seconds per block) and expensive (you pay gas fees for every transaction) compared to a regular database. So why use one?

Because they solve a problem regular databases cannot: trust without a middleman. A bank can freeze your account. A company can edit its database. A blockchain cannot be changed by anyone once a transaction is confirmed.

FeatureRegular databaseBlockchain
SpeedMilliseconds12+ seconds
CostFree (for the company)Gas fees per transaction
Who controls itThe company that owns itNo single entity
Can be editedYes, by the database adminNo, once confirmed
Needs trustYes, trust the companyNo, trust the math
Best forSpeed-sensitive appsMoney, ownership, voting

The right question is not "blockchain or database?" It is "which parts of my app need trust guarantees, and which parts need speed?" Most Web3 apps use both.

Key takeaways

  • A block is a bundle of transactions. A chain is blocks linked by hashes.
  • A hash is a digital fingerprint. Change one bit of input, and the entire hash changes.
  • Nodes are computers that each hold a copy of the blockchain and verify transactions independently.
  • Consensus is how nodes agree. Proof of Work uses computing power. Proof of Stake uses staked tokens.
  • Blockchains are slow and expensive, but they remove the need to trust a middleman.

Quiz: How Blockchains Work

1 / 5

What is a block in a blockchain?