How Blockchains Work

Part 1 of The Crypto Primer

Trevor Thorburn
5 min readAug 16, 2021

Modern society is built on top of records. These records show who owns what land, who is a citizen of which country, and who is trustworthy to lend to. These records only function their desired purpose, like proving you own your house, if they have three key attributes: they’re immutable, auditable and timestamped. They must be immutable in the sense that they can’t be changed arbitrarily, auditable in that people can check them, and timestamped so everyone knows what the status quo is. Normally, these records (or ledgers) are so important that they’re controlled by governments or regulated entities. Unfortunately, because of this centralization, these ledgers can be brittle. When the terrorist group ISIS took over Syria in 2015, one of the first things it did was redistribute the ownership of land to its members. When relative peace returns to the region, it will prove incredibly difficult to unwind this. Blockchain technology gives humans a transnational way of keeping robust records. For the first time in human history, information can be put in a place where even if it is inconvenient for a powerful actor, that actor cannot change it. It is hard to understate how much of a game changer this simple fact is. For the first time, those in power cannot dictate what is true or not.

As early as the 1990s, academics were thinking about how they might use blockchain-like technology to meet the requirements laid out above. In 1991, a paper by Stuart Haber and Scott Stornetta explored using cryptographically secured blockchains to timestamp digital files in a way that couldn’t be tampered with. It wasn’t until 2009, however, when the pseudonymous Satoshi Nakamoto published a whitepaper detailing their vision for Bitcoin.

In this paper, Nakamoto describes how blockchain technology can be used to build a tamper-proof distributed ledger. This distributed ledger is kept track of by a network of independent computers, called nodes, around the world. Each node in the network has a complete copy of the ledger and comes to consensus with other nodes as to what it contains. Blockchain technology helps make this ledger immutable — meaning it is really hard to go back and change the record once everyone has agreed on it.

On the blockchain, each block contains three categories of information. The information in a block consists of data, the hash of the block, and the hash of the previous block.

Example of Data on Bitcoin

From: Serena 👩🏽

To: William 👱🏼‍♂️

Amount: 3 BTC

At its most basic, this data could simply be the identities of the two parties in a transaction, and the value sent between them. A hash is a long string of characters that serves as a unique digital fingerprint, which identifies the block and all of its content. If something on the block is changed, the hash changes.

The combination of a block’s hash and that of the previous block enables the blockchain. This is because the validity of a new block relies upon the hash of the previous block. Block three includes the hash of block two, while block two includes the hash of block one.

Let’s say a hacker attempts to rewrite block two so that it shows funds were sent to them instead of the real recipient. Since they changed information on the block, the hash of that block would change, as illustrated in red. This would make block three and all following blocks invalid, as they no longer have a hash that matches the previous block.

Hashes alone are not enough to prevent tampering. Modern computers are powerful enough to calculate so many hashes per second, a hacker could tamper with a block and recalculate the hashes of all the later blocks to make it valid again. To mitigate this, blockchains use proof mechanisms like Proof-of-Work to slow down the creation of new blocks. Each Bitcoin block, for example, takes about 10 minutes to create. Bitcoin blocks are created by “miners”, who compete to solve complex math problems to determine the next hash. Because of Proof-of-Work, these hashes are computationally difficult to find but easy to check. The miners are then rewarded for their efforts with a small amount of BTC.

On top of hash functions and proof mechanisms, blockchains also secure themselves with distributed peer-to-peer networks. Any individual with a moderately powerful computer can set up a node. Upon doing so, they receive a full copy of the ledger. When a new block is mined, everyone on the network gets a copy. Each member then checks to make sure that it hasn’t been tampered with, and if it checks out, they add it to their own blockchain ledger. If it has been tampered with, it is rejected. This results in consensus being formed.

The data that is held on a block can be much more complex than just the identities of the participants and the amount transacted. Projects like Ethereum, Cardano, and Solana have built blockchains that support Turing-complete programming logic on each block. These programmable blockchains thus support smart contracts. Smart contracts are just like normal contracts, except they are completely digital and execute automatically when certain conditions are met. Smart contracts are both distributed and immutable thanks to the blockchain. However, just like a normal contract, if a smart contract is poorly written, it can be exploited.

Smart contracts have the ability to disintermediate (i.e. take the middleman out of) tons of processes. For example, right now when a startup wants to raise money through a crowdfunding campaign, they usually go somewhere like Kickstarter. Here, backers pledge money to the project. If the funding goal of the project is met, the startup gets funded, and if it isn’t, the funds are returned to the backers. This entire process requires both backers and the startup to trust that Kickstarter won’t steal their money. Instead of trusting a third-party intermediary to live up to their word, the startup could instead use a smart contract, which outlines the terms, and holds the money in escrow until conditions are met. If the goal is met, the smart contract executes and automatically pays the startup. If the goal isn’t met, the funds are automatically returned to the backers.

--

--