Part II: Mining and the Chain

Let’s delve further into the workings of blockchain. We learnt about blocks last time – but what about the chain?

The hashing concept is still all-important for the way blocks get added to the chain and then spread (‘distributed’) around the network. So here’s a recap on hashing:


Making a hash of it

A hash (or hash reference) is a random string of numbers. Hash functions are a method of creating an identifier for a set of data. You put something in, the function does its thing with the code, and it spits something out. That something is called a hash (or hash reference).

The hash spat out by the function is determined by whatever you put into it in the first place.

For example, when you input the sentence ‘Amanda loves blockchain’, the output might be ‘288ejald20038afljadl463283lqpppskw42839’. This is called the ‘hash’.

The hash of ‘Amanda loves blockchain’ will always be ‘288ejald20038afljadl463283lqpppskw42839 when that sentence is run through a hash function, because it is determined by the sentence I entered.

Hash references are usually irreversible, which means that given ‘288ejald20038afljadl463283lqpppskw42839’, I cannot work out that the input was ‘Amanda loves blockchain’.  I’ve just used random combinations of characters here, but usually hash references are set lengths depending on the function that produces them.

Hashing can therefore be used to prove the ‘identity’ or content of a particular set of data, without revealing the content itself.

Hash puzzles in Blockchain

If someone wanted to know my sentence, they cannot discover it from the hash ‘2884659200387546328342839’. However, they can guess the sentence input, make a hash of that and compare it to my hash to see if they match. If their hash is ‘2884659200387546328342839’, they will know they guessed correctly.

This is called a ‘hash puzzle’. Hash puzzles involve finding the solution to a problem by trial and error, which uses up computing power.

Hash puzzles are used in blockchain to provide security to the network.


The participants in a blockchain network are called ‘nodes’. Nodes are basically the different computers connected to the network.

The ‘miners’ in a blockchain network are specific nodes who use their own computing power and electricity to create and maintain the blockchain. This now requires specialised hardware to deal with the processing power required, but when Bitcoin first started it was possible to mine from a laptop.

Miners are set the task of solving hash puzzles in order to add blocks to the blockchain. They use their computing power to solve the puzzles. Once the puzzle is solved, the new block is attached to the end of the blockchain. The process is called ‘proof of work’ because the miners are proving their ‘work’ or effort by solving the hash puzzle.

Note – not all blockchains use proof of work and not all create cryptocurrency in the same way, but the Bitcoin blockchain is used here as an example of the first proof of work blockchain.


Currency creation

The process of mining in the Bitcoin blockchain serves the purpose of creating new Bitcoins. Miners receive a certain amount of Bitcoins that they have created, which is called the ‘block reward’. The amount of Bitcoins released into the Bitcoin blockchain is set for each block in the underlying code of Bitcoin.

Currently the block reward is set to 12.5 Bitcoins per block, which you can see here.  The first transaction in every block is the block reward plus the transaction fees. The amount of block reward halves every 210,000 blocks.

When Satoshi Nakamoto set up Bitcoin, he/she/they specified that only 21 million Bitcoins will ever be released. There is no constant amount of new coins, there are only the rules set to determine the supply over time through the mining process.  This was the beginning of the very interesting area called ‘crypto-economics’ which I will explore in a future post!

The miners therefore get paid for maintaining the blockchain network. It is in their interests to mine as efficiently as possible in order to beat competitor miners, solve the puzzle first and receive the compensation.

The compensation is the combination of the ‘block reward’, ie the newly mined currency, and a transaction fee that is charged for transactions being added to the blockchain. These things represent the ‘cost’ of the integrity of data in the system because the ‘reward’ of payment to miners ensures it is in their interests to act honestly.

Distributing the ledger

The miner distributes the new history of blocks with the new block attached to the end to the other nodes. It uses what is known as the ‘gossip protocol’, which is a set of rules that work by essentially spreading the word through the network.

Word spreads that there is a new block to attach to the chain.  As each node receives the new block, it appends it to the end of the blockchain and maintains the new record going forward.

It is possible that different miners solve hash puzzles almost simultaneously, producing more than one potential version of the blockchain ledger. Nodes do not keep the same version of the ledger at all times. Instead, the highest ‘rated’ version of the database that each node is aware of is stored by them.


Putting the ‘chain’ in blockchain

The way a ‘version’ or branch of the blockchain is rated is by being the longest chain. Nodes will therefore accept a version of the chain that is the same as their current version, but with a new block attached.



In the event they are distributed a version that conflicts with their own version, the chain with the highest amount of cumulative proof-of-work is accepted. This is because the probability that a block will be replaced decreases quickly as more blocks are added after it.

The correct ‘version’ of a blockchain ledger therefore is the longest chain of blocks in the system.  Some transactions might not be in the longest chain and are unconfirmed. They will be dropped from the mining process and still available for mining. They can now be added to future blocks in the chain.

Blockchains grow as more blocks are created and added to the chain. There are different types of blockchain out there and in future posts we’ll take a look at some of them.