Guides

Understanding how a blockchain works technically

Blockchain technology underpins Bitcoin, allowing secure transactions without intermediaries by using blocks, hashing, and consensus mechanisms.

Jordan Fraser 6 min read

Understanding how a blockchain works technically

A blockchain is often described as a database, which is technically true and not very illuminating. What actually distinguishes it from a normal database is who keeps the copy, and what happens when someone tries to edit the past.

The problem blockchains were designed to solve

Before blockchains, moving digital value between two parties who didn’t know or trust each other required a trusted intermediary, typically a bank or payment processor, to keep the authoritative record and prevent the same unit of value from being spent twice. That reliance on a central record-keeper is workable, and it’s how the vast majority of the world’s financial system still operates, but it means every transaction depends on that intermediary staying honest, staying solvent and staying operational, and it gives that intermediary the power to block, reverse or delay any transaction it chooses. Digital cash schemes proposed in the 1980s and 1990s repeatedly ran into the same unsolved problem, known as double-spending: without a trusted central party, what stops someone from copying a digital token and spending the same copy twice with two different recipients before anyone notices? Bitcoin’s 2008 design paper was the first widely adopted solution to that problem that didn’t require a central authority to solve it, using the combination of a shared, replicated ledger and a costly-to-fake consensus mechanism described below.

A ledger with no single owner

A blockchain is a record of transactions maintained not by one company or server but by many independent computers, called nodes, each holding a full copy of the same ledger. When a new transaction happens, it’s broadcast to the network, and nodes work to include it in the shared record. No single node’s copy is the official one; the network agrees, collectively, on which version is valid.

Blocks, linked by hashes

Transactions aren’t added to the ledger one at a time; they’re grouped into blocks, and blocks are added to the chain in sequence. Each block contains, along with its transactions, a cryptographic hash, a fixed-length fingerprint produced by running the previous block’s data through a hash function. Change even one character of data in an old block and its hash changes completely, which breaks the link to every block that came after it, since each of those blocks recorded the old, now-incorrect hash. Reversing a transaction from several blocks back would mean recomputing that block and every block after it, faster than the rest of the network is adding new ones, which is the property that makes an established blockchain’s history practically immutable rather than theoretically immutable.

What a hash function actually does

A cryptographic hash function takes any amount of input data, a single transaction or an entire block’s worth of them, and produces a fixed-length string of characters that looks like random noise. Two properties make it useful for a blockchain. First, it’s deterministic: the same input always produces the exact same output, so any node can independently verify a block’s hash matches its contents. Second, it’s effectively one-way and highly sensitive to input: there’s no practical way to work backward from a hash to figure out what produced it, and changing even a single bit of the input, a decimal point in a transferred amount, for instance, produces a completely different, unrelated-looking hash rather than a similar one. That second property is what makes tampering detectable rather than merely difficult to notice: an altered block doesn’t produce a hash that looks close to correct, it produces one that looks nothing like it, which is immediately obvious to any node checking the chain.

Public and private keys: how ownership is proven

Ownership on a blockchain is proven cryptographically rather than by any central registry checking identification. Each wallet is built around a mathematically linked pair of keys: a private key, which must be kept secret and is used to sign, or authorize, outgoing transactions, and a public key, from which a public address is derived and which can be shared freely, since it only allows others to send funds to it, not move funds out. When a transaction is signed with a private key, anyone on the network can use the corresponding public key to verify the signature is valid, without ever having access to the private key itself, in the same way a wax seal on a letter can be verified as genuine by anyone holding the matching stamp design without needing to possess the stamp. Because the private key is the sole proof of ownership, whoever holds it controls the funds, regardless of who originally acquired them, which is the underlying reason self-custody and key management are treated as such serious concerns in crypto.

How the network agrees on what’s true

Anyone can, in principle, propose a new block. What stops the network from filling up with conflicting versions is a consensus mechanism, a rule for which proposed block the network accepts. Bitcoin uses proof-of-work: computers called miners compete to solve a computationally expensive puzzle, and the first to solve it gets to add the next block and collect a reward, with the puzzle’s difficulty adjusted so blocks arrive roughly every ten minutes regardless of how much computing power is competing. Ethereum switched from proof-of-work to proof-of-stake in September 2022: instead of computing power, participants called validators lock up, or stake, ETH as collateral, and validators are selected to propose and confirm blocks in proportion to their stake, with dishonest behaviour punished by forfeiting part of that stake.

What happens when two nodes disagree

Because block proposal happens across a distributed network rather than through a single coordinator, it’s possible, and in fact routine at a small scale, for two valid blocks to be proposed at close to the same time, creating a temporary fork where different parts of the network see different versions of the latest block. Consensus rules resolve this automatically rather than through negotiation: in a proof-of-work chain like bitcoin, nodes follow the chain representing the greatest cumulative computational work, so as soon as one branch pulls ahead by gaining the next block, nodes that had been building on the shorter branch abandon it and switch over, discarding whatever transactions were only recorded on the losing branch, which is why transactions aren’t considered fully final the instant they’re included in a block, but rather grow more secure as additional blocks are added on top of them. Ethereum’s proof-of-stake consensus resolves the same kind of fork using an explicit finality mechanism, where validators periodically vote to formally checkpoint blocks as finalized, after which reversing them would require an economically catastrophic and detectable violation by a large portion of the staked validator set.

Why this design matters practically

The combination, a shared ledger with no single point of control, and a consensus rule that makes rewriting history expensive, is what lets a blockchain support transactions between parties who don’t know or trust each other without a bank or clearinghouse in the middle verifying each one. It’s also why blockchain transactions are irreversible in a way a credit card chargeback isn’t: there’s no central authority with the power to undo an entry once enough of the network has built on top of it. That property is a feature for censorship resistance and a real risk for user error, since a mistyped address or an authorized-but-fraudulent transaction can’t be reversed the way a bank transfer sometimes can.

Sources