Introduction

A blockchain is a distributed ledger that is completely open to anyone. They have an interesting property: once some data has been recorded inside a blockchain, it becomes very difficult to change it.  
Each block contains some data, the hash of the block and the hash of the previous block.  The data that is stored inside a block depends on the type of blockchain. 
The Bitcoin blockchain, for example, stores the details about a transaction in here, such as the sender, receiver and amount of coins.  A block also has a hash. You can compare a hash to a fingerprint. It identifies a block and all of its contents and it's always unique, just as a fingerprint. Once a block is created, it’s hash is being calculated.  Changing something inside the block will cause the hash to change.
So in other words: hashes are very useful when you want to detect changes to blocks. If the fingerprint of a block changes, it no longer is the same block. The third element inside each block is the hash of the previous block. This effectively creates a chain of blocks and it’s this technique that makes a blockchain so secure.
The following source code provides an oversimplistic implementation of Blockchain to illustrate many of the features seen in the lecture.