Demystifying Blockchains

Published: 2021-11-18 18:30 / Reading Time: 8 min

In this Blog, we want to give insight into the basics of blockchain technology. After reading this post, you will hopefully understand how blockchains came to life and how they are working.





There are too many projects to keep track of all, lots of abbreviations like DEX, DAO, DeFi, NFT, and Dapp, and on top of that nebulous terms such as Hard Fork, Soft Fork, Cross-Chain and Sharding, to name just a few.
What they all have in common: they are referring to technology linked to blockchains. And there are some basic principles which you'll find are part of every blockchain. With those basics well sorted, you'll be able to understand the workings of other projects as well, even if they are built around somewhat more advanced concepts.

So, without further ado, let's get into how blockchains work.


Ideas behind the first Blockchain


It all started with the well-known whitepaper written by a certain Satoshi Nakamoto: Bitcoin: A Peer-to-Peer Electronic Cash System. The paper was published in 2008, and Bitcoin came to life in 2009. Until today, no one knows who is behind the whitepaper. Bitcoin, however, still exists and has become the most known cryptocurrency.


The basic idea behind Bitcoin is the following: eliminate any intermediary and have a currency owned by the people, such that they can exchange it freely between them. This wasn't a brand new idea (even in 2008), but the implementation is what made it special.


The problem with taking away the middleman is that you lose control over some parts of the system. And until then, no one figured out how to solve all of those problems that arose. For example, instead of the bank storing all account information, everyone has to hold everyone's information. If all participants agree upon the account balances, the network has reached a consensus.


So how do you reach consensus in a network like Bitcoin, where anyone can send transactions? Let's start with establishing a consensus on transactions and build it up to a consensus on the network.



Transactions


Now, this might sound far-fetched, but Bitcoin does not offer any coins. The Bitcoin blockchain is instead a ledger with all the transaction history. To avoid problems like Replay Attacks, you have to give a specific number to each transaction.

This means that if you send someone Bitcoin, you effectively send the whole history of the 'coin'. This ensures that whoever sends a transaction owns what they want to send, i.e. received it at some point in the past.



Public Announcements


Another important concept of Bitcoin is, you guessed it, public announcements. Telling everyone that you want a specific transaction to take place solves another problem which is referred to as double-spending. You could (without public announcements) tell one part of the network that you want to send 1 coin to Bob and the other part that you want to send 1 coin to Alice (assuming you only own 1 coin). Both transactions are valid, but the network would not be able to decide which one to execute first since the second one would be invalid given that you do not own the necessary funds. And that would lead to a problem with finding consensus among all participants.
But, since you publicly announced the transaction to Alice first, that one will be executed first, and Bob will receive nothing as the transaction will be rejected.



Work


Now we get to the heart of it: the Blocks of the Blockchain. One of the peers in the network will be able to collect pending transactions, bundle them into a Block, and add them to the public record: the blockchain.


It seems pretty straightforward, but there is a twist.


First off, if you would select the participants one after each other or randomly, someone could create a thousand copies of themselves (their connections to the network) and decide which transactions are to be added. This is usually referred to as a Sybil Attack. The way the Bitcoin protocol solves this is known as Proof of Work (PoW). Sounds like a fancy new idea? Surprisingly, it was invented in the 80s. Back then, the idea was to force someone to do some (computational) work before sending an email to prevent spam. So sending an email to your friend would, for example, require 10s of work. But sending 100,000 emails would be incredibly costly in time (and usually computing power), which would refrain from doing it.


The PoW principle is being used by Bitcoin now: solve a 'puzzle' first to prevent spamming the network with new blocks.



Puzzling?


Well, if you are puzzled just now, read on. In reality, what all miners (the nodes trying to add new blocks) are computing is not that much of a puzzle. It's rather nonsense. They take the header of the most recent block (which contains a timestamp and some hashes that can be used to verify that everything in the block is correct), add a number called a nonce, compute a hash (a one-way function that returns a unique output for a random input) and try to match it to a target value.


Deep breath, here's a graphic to shed some light onto this dark place of an explanation:



The target value is what determines how difficult it is to find the correct nonce. It's easy for large values to find a smaller one (there are at least more possibilities). But since there is not a smart way to solve this 'puzzle', you have to use brute force on it.

The target value gets adapted according to the number of miners and their hashing power (how many hashes per second they are able to try) to keep the network balanced. Balanced means that the average time between two blocks stays the same. For Bitcoin, that's somewhere around 10 minutes.


A small extra bit of information: that's why people use Gaming GPUs for mining instead so they can try a lot of hashes in parallel.



Staying honest


If I find the right nonce and can add a new block, you might ask yourself why I should be an honest miner. Good question; that's the last element of why Bitcoin works. The magic word is incentives.


By rewarding miners for new blocks with coins (the first transaction in a block creates a new coin that goes directly into the miners' wallet), it is made sure that they behave. Since it would hurt themselves if the network failed, they are happy to keep it running and collect rewards.



Privacy


One common misconception is that the Bitcoin blockchain is anonymous. It is correct that your transactions do not have a name tag with your name on them, but they are publicly recorded. Feel free to head over to a block explorer and check out all transactions that ever happened on the Bitcoin blockchain.


The privacy concept is based on the fact that your address does not reveal your name. But if someone gets to link different transactions to the same actor, they might be able to deduct whose address it is. That's why authorities are actually able to track someone on the Bitcoin network (with enough information at hand).

There are, however, projects which evolve around strong privacy, such as Monero and ZCash.



Smart Contracts


Here is where we leave Bitcoin behind us. It was designed as a decentralised payment system. There were (and are) teams that tried to add some more power to the Bitcoin protocol by making it able to execute small programs, for example.


In the early Bitcoin days, a now well-known Vitalik Buterin proposed the Mastercoin team (one of those teams working on Bitcoin extensions) to enhance the protocol to allow any financial contract to be run on it.


Since the team decided to not go for the idea, he went for his own Blockchain project instead, now known as Ethereum. The whitepaper for Ethereum was published in 2013 and the blockchain was launched in 2015.



Ethereum


To emphasise it: the main difference to Bitcoin is that Ethereum can execute any program. It kind of acts like a computer that's distributed over the network. Sounds insane? Well, it is!



What? And how?


Right, a computer that's everywhere, how is that supposed to work? First things first: every computer has a state that's referring to what's currently stored in the memory and registers of the computer. In Ethereum, the state is stored on the blockchain. Executing a program changes this state. Programs in this context are usually referred to as Smart Contracts. The code being executed is transparent, meaning anyone can read a program deployed to the network.
While in theory, that means that we can verify that everything is correct, one often needs quite a lot of experience working with the programming language in which those programs are written to understand what is going on. So be careful; even transparent programs may have harmful, insecure or fraudulent code.



Gas


One crucial concept introduced on the Ethereum blockchain is gas. Every operation the 'computer' executes costs a small amount of ETH in Gas. This makes sure that you don't run an infinite program to block everyone else from using the resources. You have to send gas with a transaction that executes a function. A transaction can be a smart contract call, which triggers some program to run. If all your gas has been used, but the program has not finished running, the machine's state (blockchain) will be reverted to before your call (you won't get back the gas, though).


There is, however, one exception: if you only read data from the chain (call a function which reads data) as an external participant, you don't have to pay fees (gas).


Storage operations are the most expensive. Meaning if you want to leave some data on the blockchain, you'll have to pay for every Bit you use. Which makes sense because all participants (nodes) will have to copy that data when synchronising with the network.



Smart Contract Use Cases


Now the question is, what can one get from all this incredible distributed network computer? The answer is Decentralised Exchanges (DEX) or your own tokens, for example (this is, of course, a non-exhaustive list, the possibilities are infinite).



Ethereum 2.0


Today, Ethereum is using a Proof of Work algorithm, just like Bitcoin (the principle is the same, the actual mining algorithm is slightly different). But in the foreseeable future, Ethereum wants to change to Proof-of-Stake. At the same time, Proof of Work is becoming increasingly unpopular for consuming a lot of energy for, as you read above, not really useful computing.


We hope that's teasing enough to stay tuned. We will explore Proof of Stake in a future post where we examine a Blockchain which is based on Proof of Stake: Elrond.


We are thrilled to announce that we are building on the Elrond Network. In the next post, we will share why we believe Elrond is a disruptive technology leaving a positive impact on the planet.


If you have any questions, feel free to contact us!

Back to Overview