Build your own Mini-Blockchain!
Lesson 1 of 1
  1. 1

    In this lesson, you’ll build a small blockchain of your own in Python! This lesson assumes a familiarity with Python syntax, functions, loops, importing libraries, and constructing classes, but the…

  2. 2

    Now let’s think of a way to represent a block in Python. We could create a bigger dictionary and store our data inside this dictionary. But since blocks can be represented as objects, let’s create …

  3. 3

    Before we create a more dynamic blockchain, let’s learn how to use a hash function in Python. Specifically, we will be using the SHA-256 hash function which can be easily imported in Python. We…

  4. 4

    Block hashes are used to uniquely identify and maintain the integrity of each block. The SHA-256 algorithm is used to generate the hash of the block using the timestamp, data, and previous hash — t…

  5. 5

    Each computer participant has their own copy of the blockchain. Ideally, each copy of the blockchain should have the same properties and functionality to add and validate blocks. We can represent…

  6. 6

    Now that we have everything in place, let’s begin adding blocks to the blockchain.

  7. 7

    Hashing helps to maintain the integrity of the blockchain. In this exercise, we will see this in action. Let’s write a […] method that checks to see if blocks are linked to each other properly….

  8. 8

    Now we can use the code in our previous exercise to spot a broken link. Let’s try tampering with the contents of the block and see how that creates a mismatch between hash values.

  9. 9

    Let’s review the concepts of nonce and proof of work. In this exercise, we will implement an example that demonstrates the difficulty of the math problem that helps protect the blockchain from pote…

  10. 10

    Now that we’ve seen a simple example of Proof-of-Work, let’s integrate it into our blockchain! Complete the […] method inside the Blockchain class.

  11. 11

    Now that we have implemented our Proof-of-Work method, we can now work on adding new blocks securely.

  12. 12

    Congratulations! You have completed all the steps required to build a basic blockchain! In this exercise, we will bring the key parts together to review what we have built so far. Note: The b…