Skip to main content

 

As an additional, optional and ungraded resource for you to be able to dive more deeply into the material, we have developed a series of interactive labs with Jupyter Notebooks that will take you through the process of building a basic blockchain. Each hands-on lab will be based on a demo session from section 3.2: Analyzing a Blockchain.

The labs will be made available in three formats: HTML for browser viewing, IPYNB (Jupyter) to download and run the files locally, and a lab environment with each relevant unit.

 

Cryptographic Hashes (Module 3.2.1) 

HTML | IPYNBLAB ENVIRONMENT

The first lab demonstrates the concept of hashing as it applies to the blockchain. It allows you to explore the one-way SHA-256 hashing function that is used on the Bitcoin blockchain by evaluating various inputs.

Ultimately, you will learn how hashing drastically facilitates the concept of immutability on the blockchain and prepare to build the individual blocks on a blockchain. 

 

Blocks (Module 3.2.2)

HTML | IPYNBLAB ENVIRONMENT

Understanding the concept of hashing allows us to analyze the key elements that form a block in a blockchain — namely, the block number, nonce and data fields.

We'll understand what makes a block valid and introduce mining as the process of solving a puzzle, or finding a hash that meets an established set of criteria.

 

Assembling Blocks into a Blockchain (Module 3.2.3)

HTML | IPYNBLAB ENVIRONMENT

Understanding what makes up an individual block will allow us to see how blocks are linked together in a blockchain (or chain of blocks). We will package the code from the previous hands-on sessions into a neat Python class called "Block" that will have all the required data and helper methods.

Furthermore, we'll define a "Blockchain" class to wrap its core functionalities as a glorified list and provide the means to easily test for its validity.

 

Distributed Blockchains (Module 3.2.4)

HTML | IPYNBLAB ENVIRONMENT

Lastly, we will be ready to take what we'll have learned about hashing, blocks and blockchains to dive into the concept of a distributed blockchain, which consists of an unbounded number of copies of single-server blockchains.

We'll define a "DistributedBlockchain" class to associate each copy of the blockchain to a single peer, or owner in the network. Then, we'll see what happens when one peer's copy is modified but the rest of the network's aren't.