Blockchain: It’s Just Chains Of Blocks
19 June 2017 |
About a 4 minute read
Blockchain seems to be everywhere these days including at AND Digital where we have been working on a blockchain product and blogging our findings over the last few weeks. The last post in our series looked at the types of problems blockchain technology could help solve, but how does blockchain work?
This post is the first in a miniseries that will aim to explain the core concepts underpinning blockchain in more detail. We’ll start by looking at the components of a blockchain, before looking at how the blockchain network works in the next instalment.
To explain blockchain in more detail we’re going to imagine that AND Digital has it’s own cryptocurrency; AND Dollars! We’ll imagine that this currency is used by ANDis (what we call our people) to buy and sell the coveted new AND Digital merchandise. I hear the branded socks are very popular! To manage transactions we’re going to build an imaginary distributed ledger using blockchain, containing some of the key elements of the distributed ledgers used by major cryptocurrencies like Bitcoin and Ether.
Chains of blocks
So what exactly are we referring to when we use the term blockchain? It turns out this name is literal! Blockchain is made of up blocks which are chained together.
So the AND Dollar trading platform has been launched and the distributed ledger blockchain is being generated – but what inside these blocks?
Again, it’s surprisingly simple! A block is a collection of data. Because the AND Dollar is a currency, the data on the AND Dollar blockchain is made up of exchanges of currency between different users; transactions. Every time an ANDi sells a mug or pair of socks and receives AND Dollars in return, a transaction is created which includes the unique identity references for the original and new owners of the AND Dollars, the date and time of the transaction and the amount transferred.
Blocks are created constantly so each block will contain a subset of transactions. In fact, a block doesn’t have to contain anything at all.
We’ve now established that blockchain is literally a chain of blocks, those blocks contain data, and in the case of AND Dollars the data is made up of transactions. And the data could be left in this raw form, however in most blockchain solutions data inside blocks is hashed.
Hashing is a clever mathematical algorithm which takes in any piece of data and returns an alphanumeric string. The returned strings have the property of being collision free. This means that it’s highly unlikely to have two different pieces of data with the same hash value. So we can be confident that if two pieces of data have the same hash then they are exactly the same.
Imagine you hold a block with a lot of transactions in it, (bitcoin blocks have ~2000 transactions/block currently) and want to compare this block with a block I hold to see if they are the same. Instead of comparing each of the 2000 lines individually, we can instead ‘hash’ each of the blocks and compare the returned alphanumeric strings.
For our imaginary network we’ll use the standard 256 bit hashing, which means that the data in every block, no matter how complex, is represented by a 64 character alphanumeric string.
Throughout this post we’ve talked about blocks being ‘chained’ together, but what does this mean? In our solution hashing forms an essential part of chaining. We’ve established that data inside a block is hashed. When a new block is generated, it takes a copy of the previous block’s hash and saves it as a link to the chain. This is the simplest method of chaining blocks together.
In a chain of 10 blocks, if someone changes the data contained in block 5 in their copy of the chain this will also change the hash for that block. This will then no longer match the reference to block 5 held by block 6, and the chain copy will be invalidated.
We’ve got the beginnings of a solution for keeping track of all transactions made in AND Dollars using blockchain. But there are some things missing from this solution. The distributed ledger will be stored on multiple machines, but how are new transactions added to the ledger? And how do we make sure only valid transactions are accepted onto to the blockchain?
You might have heard of some other concepts like ‘proof of work’, ‘consensus’ and ‘mining’, we’ll be exploring these ideas in the next post in the series to see how they could improve our AND Dollar trading platform.
Squad Lead (Reading)
Lead and inspire a squad to succeed, bringing your passion for managing and developing people through career coaching and mentoring.I'm Interested
Graduate Developer (Halifax)
Kickstart your career in tech, building innovative web applications and software solutions with the latest technology and Agile development methodologies.I'm Interested
Digital Transformation People Consultant (London)
Empower clients with the right operating models, organisation structures, ways of working and cultural transition.I'm Interested