Blockchains Explained: A Primer on Cryptocurrencies, Bitcoin, and Ethereum

Article summary

Blockchains are nothing new: Bitcoin’s blockchain was implemented in 2009, and research papers on blockchains date back to the early ’90s.

While I had heard about Bitcoin and blockchains, I didn’t fully understand them, and the gaps in my knowledge came to light when my grandma asked me to explain Bitcoin to her. This post is intended to explain what blockchains are, how they work, why someone would want to use them, and what’s coming up next.

Note: This post often refers to Bitcoin and Ethereum to explain concepts, but these are examples of blockchains and are not totally equivalent.

A New Take on Money

In your everyday life, if you want to buy something, you exchange money with a business or person for the thing you want to buy. Before computing was widespread, people used physical representations of money (dollars, coins, gold). Now, we also use digital records of money.

Whether you rely on physical or digital means, you are trusting some kind of outside group to create and regulate the physical representations of money (the Federal Reserve), keep accurate bookkeeping records (banks, state and national laws on bank records, etc.), and prevent theft, double-spending, and fraud (laws, law enforcement, counterfeit protection, etc.). I’m glossing over some things here, but the point is that everyone follows the rules that external entities have made–because if someone breaks those rules, those entities have the authority to step in and act.

Cryptocurrencies have the same ideas—creation, regulation, accurate bookkeeping, and prevention of theft—but there’s no outside group to monitor them. This makes Bitcoin and other cryptocurrencies “trustless.” In other words, there is no outside group or third party that must be trusted for transactions to occur.

Wait, what? If there’s no outside group, who keeps track of things? How do I know that they won’t falsify the bookkeeping?

In this model, instead of having banks or other middlemen keep track of transactions, everyone has a copy of the “master record” of transactions. Additionally, everyone can participate in the bookkeeping.

Let’s back up a bit, though. This “master record” is a ledger of all of the transactions for a given currency. In the world of cryptocurrency, this ledger is known as a blockchain. It’s a big record of all transactions for a given cryptocurrency. A transaction is one person or party (say, Alice) sending money to another person or party (say, Bob) in exchange for something.

Rather than having the blockchain (master ledger of transactions) be managed by a select few groups (banks, Department of Treasury, etc.), cryptocurrencies distribute the blockchain to all participants. This makes blockchains distributed instead of centralized. A blockchain can be described as a distributed database.

Because everyone has a copy of the blockchain, we don’t have to worry about one group falsifying the data without the rest of us knowing. Theoretically, a bank could illegally take money from my account, and it’d be my record against theirs. In a cryptocurrency, everyone has the same record. In the cause of fraud by one party, it would be one false record against thousands or millions of correct, matching records.

Because there is no outside authority, blockchain networks rely on the distributed blockchain to create consensus. Consensus means that all participants in the network agree on what transactions have taken place. They also agree to the rules on creating and exchanging money, and trust that everyone else is following the rules, too.

Umm, but what about when new transactions happen? How does the blockchain get updated, and how does everyone agree that the new copy is correct?

Good question.  First, some more technical details:

A blockchain is made up of a bunch of blocks of transactions that contain a timestamp and a pointer to the previous block (such that they form a chain). Each block is created at a regular time interval, or a moving average.

The blockchain is a file that is copied and distributed to nodes. A node is a computer that is connected to the blockchain network. Each node has a copy of the ledger and adds the next block.

With US dollars, there are a bunch of transactions happening at any given time: people buying coffee, getting paychecks, paying student loans, shopping at the mall, and so on. If you want to buy something at a store, you bring the item to the checkout, give them money, and then you’re free to walk out the door with your purchase.

With cryptocurrencies, the transaction doesn’t happen instantly. If Alice wants to send Bob some money in the form of Bitcoin to buy Bob’s new e-book, she requests a transaction. Transaction requests are broadcast to all of the nodes in the blockchain network.

Each of the nodes in the network are tasked with validating a group of transaction requests that have occurred since the last block was formed. Each node checks the individual transactions to make sure they’re good (i.e. does Alice have enough money to pay Bob? Has she already spent that money in an earlier, or other pending request?).

When a set of transactions are grouped and validated, they’re recorded as a block of transactions, and they are added onto the blockchain as a new entry. Once that happens, everyone in the network updates their copy of the blockchain to include the latest block.

Proof of Work

The secret sauce that ensures this work is done honestly and orderly is called “proof of work,” or PoW. Creating PoW for a block of transactions is called mining, and those who mine are called miners.

PoW is a “piece of data which is difficult (costly, time-consuming) to produce but easy for others to verify and which satisfies certain requirements” (source).  Bitcoin uses the Hashcash system. Ethereum uses Ethash, but it will soon switch to a different system.

A miner will take a block of transactions and a nonce (an arbitrary number), and perform a series of cryptographic operations. If the resulting hash fits the “certain requirements” as defined by that cryptocurrency (e.g. Bitcoin), the hash is accepted as proof of work, and that miner is rewarded for their efforts with cryptocurrency. If the hash doesn’t fit the requirements, the miner changes the nonce and tries again.

There is no way to find the correct hash other than brute force. Because of this, the correct hash shows “proof of work,” or “that someone invested a lot of computing power to find the correct nonce for this payload” (source).

However, it’s very easy for other nodes to check the miner’s work. Given the group of transactions (which everyone has) and the nonce, any node can quickly verify that a miner’s correct PoW is indeed correct. Only a block with a valid proof of work will be accepted as the new block in the blockchain.

What if there are bad transactions?

It is easy for all nodes to verify transactions.  When a new block is created, the other nodes in the network not only check the PoW; they also check the validity of the transactions included in the block. If the PoW checks out, but one of the transactions doesn’t, the block will be rejected by other nodes. More details on accepting transactions can be found here.

What’s the motivation for doing this work?

Whoever creates a block is rewarded with a nice transaction fee (in Bitcoin, 12.5 Bitcoins per block). Because only the first miner to find the correct hash is rewarded, miners often invest a lot of money into mining “rigs” with more processing power. A different way of looking at “mining” is competitive bookkeeping. Only the first person to finalize a group of transactions with PoW gets paid.

For Bitcoin, mining difficulty is adjusted (via the “certain requirements”) so that a new block is added roughly every 10 minutes. By contrast, Ethereum blocks are created roughly every 17 seconds.

If the winning miner gets money for their work, where does that money come from?

In the case of Bitcoin, there is a generation algorithm that creates new Bitcoins with each new block. The rate of Bitcoin generation halves every four years. Ethereum does something similar, and both cryptocurrencies have rules for capping their issuance. In this way, cryptocurrencies’ generation rules are similar to the Federal Reserve deciding how much money to print each year.

What if two miners create two different blocks at (nearly) the same time?

It’s entirely possible. Miner A could group together one set of transactions and find a valid hash for her block. At the same time, Miner B could group together a different set of transactions and find a valid hash for his block. Both miners share their block to the network.

Now, other miners assume that Miner A’s block is valid. They continue on with new transactions and mine “on top of” her block. Other miners mine “on top of” Miner B’s block. If the next valid block follows Miner A’s block, then her block and the new block form the longest chain. Thus, Miner A’s block is considered valid, and Miner B’s block is “orphaned.”

The transactions in Miner B’s block are put back into the pool of unconfirmed transactions. Those transactions will be accounted for in a future block, so no one has their money spent twice. By following the “longest chain” rule, discrepancies within the blockchain work themselves out.

Circling back to that Alice and Bob e-book example: Now we’ve seen that the transaction won’t go through immediately. It will take at least 10 minutes, and there’s a chance that the block could be orphaned.

In Bitcoin, six blocks (or 60 minutes) is the often-cited waiting period before a transaction is considered confirmed. Past this point, the chance of reversal is practically zero. It’s up to a merchant whether they want to wait that long (an hour is a long time to wait!). In Ethereum, confirmation takes 12 blocks, or roughly three minutes.

“Trustless” doesn’t seem like quite the right word to describe cryptocurrencies.

Cryptocurrencies remove the need for trust in intermediaries. Instead, you’re placing your trust in the algorithms, software, and a community that the cryptocurrency depends on.

What are some concerns with blockchains?

Because there’s no regulating body, cryptocurrencies can fluctuate wildly with no protection for consumers. Banks have FDIC-insured backing; blockchains offer no such protection.

You could also lose your “wallet,” meaning that you lose the cryptographic keys that prove ownership of your Bitcoins (or other currency), effectively meaning that you lose your Bitcoins.

Additionally, if a flaw is discovered in the algorithm of a cryptocurrency, it could be exploited. This happened in 2016 with Ethereum, after $50 million was stolen.

Ethereum allows–and even plans for–so-called “hard forks,” allowing the cryptocurrency to course-correct and fix the flaw.  Bitcoin, on the other hand, offers no such option. If a significant flaw is found, Bitcoin could completely lose all valuation.

Blockchains are susceptible to a “51% attack,” in which a group that controls over 51% of the blockchain network could manipulate the blockchain ledger. Such an attack is feasible, although pretty unlikely.

Additionally, as cryptocurrencies grow in popularity, they may encounter legal and regulatory issues.

From an environmental standpoint, Bitcoin consumes hundreds of megawatt-hours of electricity per day for mining.

I heard that Bitcoin is used to buy drugs.

Well, yes. The FBI’s shutdown of the Silk Road (and subsequent seizure of Bitcoins) brought Bitcoin into the spotlight, linking the cryptocurrency with illegal drug trades in the public’s mind. One advantage of cryptocurrencies (or disadvantage, if you are trying to enforce laws) is some degree of anonymity.

To open up a new bank account, you have to provide your name and other personal information. To send Bitcoin, you need to create a new Bitcoin address. This is done without providing any personal information, thus preserving anonymity. Transactions between addresses in the blockchain aren’t tied to users’ identities, either.

However, there are ways to lose your anonymity. One way is for your personal information to become linked with your Bitcoin address. This could happen if you deposit or withdraw money to or from a regulated exchange or wallet service. The hackers behind the “WannaCry” ransomware attacks find themselves in such a position. They have $70,000 USD sitting in their (publicly shared) Bitcoin address, but it will be very difficult for them to withdraw the funds without getting caught.

You mentioned Bitcoin and Ethereum—how many types of cryptocurrencies are there?

Right now, there are an estimated 900 cryptocurrencies. Bitcoin, Ethereum, Ripple, and Litecoin are the largest in terms of market value.

Where can I spend cryptocurrencies?

Right now, mostly online. Offline, there are companies that accept Bitcoin, but they are few and far between. Still, they appear to be growing in number. BitPay (a Bitcoin payment service provider) estimates that there are 100,000 merchants who accept it.

Can anyone mine for Bitcoin, Ethereum, etc.?

Yes, but a lot of computing power is required, and mining gets more competitive by the day.

What cool stuff can Ethereum do?

So far, we’ve only talked about one-time transactions between accounts. In addition to plain-old transactions, Ethereum’s blockchain also allows for “smart contracts.” Smart contracts are executable pieces of code stored on the blockchain that “run exactly as programmed without any possibility of downtime, censorship, fraud or third-party interference” (source).

A simple example of this is a smart contract that pays investors a certain percentage of money every quarter. When the conditions are met (it’s the end of the quarter, etc.), the smart contract will automatically transfer money to the investors. This happens with no outside involvement or interference.

Ethereum smart contracts can be written in either Solidity or Serpent, and are Turing complete. One reason for Ethereum’s growing popularity is the ability to write Dapps, or decentralized apps. These are applications that use smart contracts (stored in the blockchain) and a frontend.

  • Aktarus says:

    it is not totally true: “You could also lose your “wallet,” meaning that you lose the record of your Bitcoins or other currency.”

    Eventhough many wallet clients do store a local copy of the blockchain, wallets are also storing cryptographic keys on your computer and you need those keys to transact with your digital money. If you lose data on your hard disk, you don’t loose the records because they are still stored on the distributed blockchain but you loose your keys. It means, that you will still be able to see your balance on the blockchain but you won’t be able to do anything with it as long as you don’t find a way to recover your keys…

    • Jaime Lightfoot Jaime Lightfoot says:

      hey Aktarus, thanks for the comment/correction. I’ve updated the post accordingly. :)

  • Aktarus says:

    by the way, this is a very good reading, well done Jaime :-)

  • CJ says:

    This is an excellent pice — when someone asks about cryptocurrencies, I’ll make sure to forward them here. Please do write more on the topic!

  • Comments are closed.