What is blockchain: A basic primer

Bitcoins, Ethereum and other blockchain applications seem to be all the rage right now. So what the hell actually is it?

After I first learned of the Baader-Meinhof effect, I started noticing people mentioning it all the time.

Dumb jokes aside, it’s that thing that happens where you hear about something – an obscure band or a type of wood, or god knows what, and now you hear it all over the place. That can make it hard to tell whether you’re only just now hyper-attuned to any mention of a previously common term, or whether it’s actually becoming a thing.

Blockchain is one of them. If you’re anything like me (and if you are, congratulations) you’re hearing about blockchains all over the place. I started doing a little bit of work in that space lately, and it forced me to look into it.

What I discovered is a world of relatively simple principles, clouded by assumed knowledge and arcane terminology. Blockchain applications combine all the jargon of IT with the insider knowledge of the finance and trading industry. Add in some advanced cryptography and baby you got a stew going.

The point of this article is to penetrate some of that. This is written from a developer and interested party point of view. And actually, let’s make something very clear right up front.

This article is not about trading or buying Bitcoin

This article is actually about the underlying technology, the overlaying terminology, and its applications. It is intended to answer often unasked questions about what blockchain actually means and how it works.

Let’s start at the beginning. Fundamentally, a blockchain is no more or less than a ledger, a list of transactions. That list is agreed on by mechanisms to determine consensus, which makes it “official”.

You see, blockchain technologies are “distributed”. There’s no central list of transactions. There are a huge number of “ledger keepers” on the network, all of whom have equal access to the network and the transactions in it. That means everyone needs to agree on what are the correct transactions, and (most critically) in what order. With a distributed system, transactions can be put into the system in any order and retrieved in any order. This order very much matters.

If Joan sends $80 to Steven, and $70 to Chen, but she only has $100 then we have a problem. Whichever one she sent money to first gets paid. Whoever was sent the second doesn’t – that transaction is invalid. If one person says Jeff got paid first and another says Steven did, there is a conflict.

The way it works out is surprisingly simple. Every one of the ledger keepers has access to a pool of pending transactions. They grab whatever transactions they want out of that pool, and make them into a collection up to a certain amount of space and that’s called a Block. See where this is going?

From there, every ledger keeper tries to claim their block is the correct block. The official order. But there can be only one and they have to fight for it. The way they fight is where the crypto in cryptocurrencies comes from. (I’ll let you figure out what “currencies” means on your own time.)

Blockchain cryptography vastly oversimplified

Because there can be only one block officially chosen, each ledger keeper has to work for the right to be that one. As a result, they’re asked to do a puzzle. In actual fact they’re asked to solve elliptic curve cryptography, but that’s hard to explain for three reasons: I don’t understand it, I don’t care, you don’t care.

A good analog to the puzzles is something like Sudoku. Sudoku follows very simple rules. You can only have the numbers 1 – 9, and they can’t conflict among rows, columns, or 3x3 grid squares. Most critically, solving a Sudoku puzzle is difficult and time-consuming, but confirming that it is solved is a piece of cake. You just scan over it to confirm it didn’t break any rules and it should all be good.

Analogically, the ledger keepers don’t “solve” the sudoku by actually figuring it out like you or I would. There’s no puzzling or logic. They just slam numbers into it and hope it’s right. When it’s not, they try more numbers. Over and over until they get one right. With a lot of attempts, by design it takes about 10 minutes for someone to get one right somewhere in the world.

Our Sudoku grid here is not a 9x9 grid but something just over 150,000,000,000 x 150,000,000,000.

Solution attempts are being made at the rate of five million trillion tries a second. That is not a typo, it’s around 5,000,000 “terahashes” or unsuccessful attempts per second.

Coincidentally, I have the same success rate on Tinder.

When someone finally solves the puzzle they get the right to say their block is the real official block. They then broadcast out a notification with the details of the new block so that everyone can dump their own now-superceded block and start on a new one. That block now gets added to the ledger – the latest block in the block chain. If you’re wondering why they bother, they also get rewarded with shiny Bitcoins for playing their part — that lucky strike of gold after putting in a load of work is why it’s termed “mining”. Probably. Given there’s a serious cash value to Bitcoin, that’s is an obvious incentive.

In any case, everyone who gets that block acknowledges the new block, double-checks the numbers correctly solve the puzzle, and agrees that’s correct and gets on with it.

You may have noticed the potential for a conflict here. This is a distributed system, with messages going all around the world. If two people on different sides of the globe solve their mega-sudoku at even roughly the same time, there are two potential blocks that are right. There’s no clear consensus because half the world thinks one block was first, the other half think otherwise.

This seems like an issue but it’s not, the system is intended to work through it. This fork in the chain is short-lived. Though there is a split with two (or more) blocks and no clear consensus on which is the official, both groups of people simply go on mining on their preferred chain. One of the divergent factions will get a second block much faster than the other. With one block in one faction, and two in another, everyone immediately sides with the longer chain as the official. In theory they could keep getting them at the same rate but in practice this is impossible. The chain that loses support is dropped and never spoken of again like a Flash timeline.

You probably haven’t noticed another potential issue here. If the only requirement to be able to maliciously change the blockchain history is to make a longer chain with whatever you want in it, can’t someone just brute-force that?

The simple answer is yes. But each block back you have to replace out is an enormous increase in computational requirement. After all, you have to be calculating hashes faster than the entire rest of the network. The block just confirmed – newly mined – is not very reliable. Three blocks back is pretty strong though. And six back is considered unbreakable.

Note that it takes 10 minutes per block, so this means a transaction is set in stone after about an hour. This is why some sale transactions, etc, take an hour to settle. Trivial transactions like a cup of coffee might well be considered “near enough” after a single mining, with the seller taking on the risk that the transaction doesn’t get unmade.

It should be noted that if a transaction is mined and then lost it isn’t at all gone. It will just end up in a different block and join the chain next time.

All of the above is written specifically about Bitcoin. But it isn’t unique to Bitcoin. These processes and principles apply to all crypto-currencies and form the backbone of the technology. The important things to understand are that a “block” is a list of transactions, and when confirmed they’re added to a “blockchain” that forms a concrete ledger that firms up over an hour or so.

No now let’s ignore Bitcoin because it’s boring. Technology-wise, anyway.

Let’s talk Ethereum

Bitcoin was essentially the proof of concept, and a proof that has succeeded beyond the expectation of most. But Ethereum is the logical next step — Bitcoin 2.0. Or depending who you listen to, Bitcoin is the one true crypto-currency and Ethereum is a Ponzi scam. Tomato potato.

The Ethereum crypto-currency itself requires careful conversation. For example, Ethereum is not a crypto-currency. Ethereum is the protocol or network, the currency is called Ether. Ethereum needs to be discussed carefully because it does a lot more than Bitcoin, which means more scope for misunderstandings.

While Bitcoins can do little more than be traded as a currency, the Ethereum network is capable of a great deal more. Specifically, the transactions entered into the blockchain don’t necessarily just contain financial information, but can actually consist of executable code.

Ethereum applications are built in a language called Solidity. This is a relatively simple and limited language with syntax like JavaScript got busy with Go one fateful night. When deployed to the network these applications are called Smart Contracts. Which honestly probably tells you a decent amount about what they’re intended for.

Getting your head around Ethereum applications isn’t difficult from a syntax or technical point of view. It’s more about understanding what you would use it for. It’s much less about how do you add two numbers together or write a loop, and much more about understanding how and why the blockchain provides an option for specific cases.

A classic example of this is an “escrow” system, possibly used for something like selling on Ebay. This requires one person to put money in, and then another to get it out only if both parties agree. Ideally this is the buyer and the seller, product was received, all was well. The above is all achieved by the fact that the deployed app is essentially an account itself. Money can be sent directly to it, and then the internal balance of the contract queried, checked, confirmed. Functions of that contract can be executed to give the seller the money or return it to the buyer. (Guards are put around who can execute these functions, which are tied to the relevant accounts.)

Smart Contracts form a transparent and cost-effective way to store money and the state of the agreements around that money. Large financial institutions including the Australian Stock Exchange, Barclays and Citibank are investing vast sums of money into pilots of these technologies to replace existing slow and manual reconciliation processes.

For the record, Smart Contracts form the main area of my own interest as well. This is a huge market at the moment, with a lot of interest from a range of parties. If like me you’re looking for some side-gigs to supplement your full-time modelling career you can do worse than looking in this space.

Distributed Apps - DApps or *shudder* ÐApps

Distributed apps are apps that are… see if you can guess. Honestly this term is poorly defined at this point. What exactly the “dapp” part of an application consists of is not clear. Really only the Solidity contract is actually distributed, so by some definitions that’s the dapp.

Structurally, the dapp is just an app. The only thing that really changes is that the persistence layer used for some entities and elements is on the blockchain.

There is a fairly consistent misapprehension that the entire application operates on the blockchain, and as a result a common mistake for new developers is to throw lots of state and application logic into the blockchain. There are a lot of reasons this isn’t a good idea. The main one is that it’s expensive, and it’s slow.

Think of the smart contract more like a contract. Let’s say you have a system for handling tournaments. In a previous life in the games industry I saw more than a one company promote an esports tournament or competition with a cash prize, only to drag their feet once they had to reach into their pocket.

A smart contract could be created that stored prize money, transferring it when a winner was confirmed. This would have a number of advantages — the money is “gone”. From the organiser’s point of view there’s no incentive to keep it, and would be no mechanism to get it back. The smart contract could (and should) also have an unbiased third party arbiter, so if the funds weren’t released or finalized, they could simply be forced to after a given date, etc.

This smart contract wouldn’t be the whole application. You could have a whole leaderboard, competition application system, admin facilities, etc. But some of those admin tools could connect to the blockchain, the smart contract, and update its state. For example, creating a new tournament would make a new PrizeMoney smart contract. Setting a prize money amount would require that amount to be transferred to the smart contract. The contract’s address would be visible in the tournament page, and interested parties could look and confirm that everything was legit. The leaderboard could also connect to the smart contract. Once a winner is confirmed, the admin update would also trigger the transfer of payment to the winner automatically.

This is just a single artificial example of a use for blockchain, and nearly daily I hear clever ideas that are facilitated by the use of this technology.

I will write more about blockchain technologies soon, and in more depth than this. There is both a lot of potential and a lot of complexity to these tools, especially from a lowly web developer’s point of view.

Senior Web Developer based in Bangkok, Thailand. Javascript, Web and Blockchain Developer.