
What is a blockchain?
I’ve been on a journey of discovery for the last few months, learning about the cryptocurrencies and the blockchain in general. Having seen articles like this pop up it only seemed right to explore things a bit more and possibly see if I could build something like the Bitcoin blockchain from scratch in Go.
What is a blockchain?
For me, a good analogy would be a linked list that once we’ve written to it can be verified by others as to it’s state. Simply, we can guarantee that everything in the chain hasn’t been changed from the point it was written.
To achieve this, each block that is created is linked back to the previous block in a way that enables an outside observer to confirm that each block in the chain is in the right place and should actually be there. We’ll cover this in a bit more detail in the future.
This doesn’t sound like a form of currency right?
The crypto coin part of a blockchain stems from the above properties. Value is derived from the fact that coins can be mined — with a set difficulty — and those coins, once created can be used in transactions. This is all verifiable once in the chain and therefore any movement of those coins again is verifiable in the chain. The change in value of those coins is simply caused by supply and demand. Lots of people want them, and it’s not trivial to create them.
The security of the blockchain comes from the fact that many different parties all have a copy of the chain, and as the chain is verifiably correct from the first block, everyone can know the true state of the chain. In a currency this is the state of all the movements of value — transactions. This is why it’s commonly called a ledger. It’s a distributable list of the movements of currency over time that is known to verifiably true.
Proof of work
For a currency to be worth anything, it has to be somewhat scarce. You can’t just create money when you want to buy something. In crypto currencies something called proof of work (other algorithms are appearing, proof of stake for example) is used to make sure that coins can’t just be produced out of this air. This is simply an algorithm that takes a certain amount of processing power to complete in a way that others can see that you have completed the tasks you say you have. In the example of bitcoin, once this proof of work algorithm has been completed by a miner, they are compensated by a set amount of bitcoins. This is the first transaction of any block — a payment to the miner who found it.
A very simple example of a proof of work algorithm.
for {
n = Rand(0, 1000000) if n % 10 {
return
}}
We’re basically using a random number generator and checking to see if the remainder when divided by 10 equals zero.
The actual proof of work algorithm is far more complex and uses a fair amount of processing power to complete.
Round up
So there it is, a fairly simple intro to what a Blockchain is. Next time we’ll look at how we can create one in Go. Stay tuned.
If you enjoyed this, then let me know on Twitter — @matzhouse
You can also hit the green heart below!
