Become an NFT Developer with Best Practice Way Part 2: Implement How Blockchain works using Python

image from Unsplash

in the previous chapter, we discuss the fundamental of blockchain, so in this chapter, we will discuss how to implement Blockchain Works using Python, so let’s see the table of content

  • Creating Blockchain Class and Constructor
  • Creating Method to get Transaction
  • Creating Sample Transaction

Creating Blockchain Class and Constructor

in first step creating blockchain class and the constructor

in this constructor, we have a previous hash property and transaction list parameter, and we join all the transaction list with the previous hash and separate them with -

after separating the string we created a hash with the sha256 method from the hashlib module on python.

Creating a method to get Transaction

after creating the constructor, we need to get transaction result so creating a method for it

in this method, we print the result of the transaction

Creating Sample Transaction

now creating simple transactions to see how blockchain works

and we see if we changed data the hash is changed differently

if data changed the token is changed frequently

Conclusion

In this simple program, we explain how blockchains work and create the unique token using hash, so we can easily understand it, thanks for reading, source code available on Github, see you in the next chapter

--

--

--

Make Indonesia World #1 Remote Worker Provider

Recommended from Medium

Hop Protocol Airdrop

We are incredibly excited about #NFT and this post is a great gift for our community where we…

what is X Swap Protocol?

Composable SDK: The Silver Bullet for Developers.

UniLend Project Updates — April 2022

Ever seen Blockchain in Supply Chain? I have seen it

Sasha Ivanova, NEM BDM: “Catapult is the hybrid development engine that combines advantages of…

Introducing IDChain

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Feri Lukmansyah

Feri Lukmansyah

Interesting with Blockchain and Opensource Project my journal: https://www.perykun.xyz/

More from Medium

How to Install and Run the Crypto-Telegram Bot

Telegram message fetching Bitcoins price and metrics

How to create your computer-generated art for your KCC NFT using Python?

Know How Blockchain Intensifies The Power of IoT

Building your first Smart Contract with Vyper