SlideShare a Scribd company logo
How to develop a custom blockchain?
Define the block
Libraries required
• Datetime (This module supplies classes for
manipulating dates and times.)
• Hashlib (Secure hashes and message digests)
Import these libraries
Step 1: Define the structure of a block
• Define the structure for the block as a class:
class Block:
def __init__(self, previous_block_hash, data, timestamp):
self.previous_block_hash = previous_block_hash
self.data = data
self.timestamp = timestamp
self.hash = self.get_hash()
• #function to create our own hash this hash will be take all the data in the block header and run
SHA 256 two time (inner and outer encryption)
• #Only considered the previous block hash, data and timestamp to be part of block for simplicity.
Step 1: Define the structure of a block
• Define a class:
Step 2: Define the function to perform
the hashing of block components
def get_hash(self): #will take only object self as it has all we need for this function
#generating binary representation of the header
header_bin = (str(self.previous_block_hash) +
str(self.data) +
str(self.timestamp)).encode() #encode function
#we convert all the data in strings to feed it as input for hash function SHA256 (in this function two-level
hashing is illustrated in the from of inner hash and outer hash)
#encode() is used to encode the code into unicode
inner_hash = hashlib.sha256(header_bin.encode()).hexdigest().encode()
#hexdigest() convert the data in hexadecimal format
#hashlib.sha256 is used for hashing using SHA256 from library hashlib
outer_hash = hashlib.sha256(inner_hash).hexdigest()
return outer_hash
Step 2: Define the function to perform
the hashing of block components
Step 3: Creating a genesis block (Static
Coding Method)
def create_genesis_block():
return Block("0", "0", datetime.datetime.now())
A static method is bound to a class rather than the objects for that class. This means that a static
method can be called without an object for that class. This also means that static methods cannot
modify the state of an object as they are not bound to it.
Step 3: Creating a genesis block (Static
Coding Method)
Resultant of Step1, 2 and 3 (block.py)
• save this as block.py
Create a Blockchain
Creating Blockchain
• Create a file named Blockchain.py
• Import the structure of block defined in block.py file
from block import Block
Creating Blockchain
• Generate the Genesis block and print its hash on screen
b1 = Block.create_genesis_block()
Print(b1.hash)
Creating Blockchain
• Generate the Genesis block and print its hash on screen
Creating Blockchain
• Lets add some elements to our blockchain
• For simplicity, lets fix the number of blocks
num_blocks_to_add = 10
Creating Blockchain
• Lets add some elements to our blockchain
• Initialize the loop and append the blocks
for i in range(1, num_blocks_to_add):
block_chain.append(Block(block_chain[i-1].hash,
"Block number %d" % i,
datetime.datetime.now()))
Creating Blockchain
• Lets add some elements to our blockchain
• Initialize the loop and append the blocks
Adding more blocks to Blockchain
Specifying the number of blocks to add into blockchain
Adding more blocks to Blockchain
Creating the genesis block
and adding into blockchain
Adding more blocks to Blockchain
Printing the value of
hashed genesis block
Adding more blocks to Blockchain
Running a loop to generate
the given number of blocks
Adding more blocks to Blockchain
Appending new blocks
Adding more blocks to Blockchain
Printing the hash of
the generated block
Adding more blocks to Blockchain
A single file

More Related Content

Similar to Lecture 17 (Blockchain Implementation using Python).pptx

Introduction to bit coin
Introduction to bit coinIntroduction to bit coin
Introduction to bit coin
Vivian S. Zhang
 
Python packages for blockchain
Python packages for blockchainPython packages for blockchain
Python packages for blockchain
Celine George
 
Build and save your own Gutenberg Block Patterns
Build and save your own Gutenberg Block PatternsBuild and save your own Gutenberg Block Patterns
Build and save your own Gutenberg Block Patterns
Plasterdog Web Design
 
Let's build a blockchain.... in 40 minutes!
Let's build a blockchain.... in 40 minutes!Let's build a blockchain.... in 40 minutes!
Let's build a blockchain.... in 40 minutes!
Michel Schudel
 
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Codemotion
 
Creating Custom Gutenberg Blocks for WordPress
Creating Custom Gutenberg Blocks for WordPressCreating Custom Gutenberg Blocks for WordPress
Creating Custom Gutenberg Blocks for WordPress
Paul Stonier
 
Building your first Gutenberg block
Building your first Gutenberg blockBuilding your first Gutenberg block
Building your first Gutenberg block
Cory Webb
 
Day 1.pptx
Day 1.pptxDay 1.pptx
Day 1.pptx
MansiRaj26
 
Write this in C language. This project will require students to si.pdf
Write this in C language. This project will require students to si.pdfWrite this in C language. This project will require students to si.pdf
Write this in C language. This project will require students to si.pdf
albert20021
 
Python multithreading
Python multithreadingPython multithreading
Classes, Inheritance ,Packages & Interfaces.pptx
Classes, Inheritance ,Packages & Interfaces.pptxClasses, Inheritance ,Packages & Interfaces.pptx
Classes, Inheritance ,Packages & Interfaces.pptx
DivyaKS18
 
BlockChain implementation by python
BlockChain implementation by pythonBlockChain implementation by python
BlockChain implementation by python
wonyong hwang
 
Extending Studio - Piotr Nalepa & Kamil Musiał - Presentation at eZ Conferenc...
Extending Studio - Piotr Nalepa & Kamil Musiał - Presentation at eZ Conferenc...Extending Studio - Piotr Nalepa & Kamil Musiał - Presentation at eZ Conferenc...
Extending Studio - Piotr Nalepa & Kamil Musiał - Presentation at eZ Conferenc...
eZ Systems
 
Accelerating Data Ingestion with Databricks Autoloader
Accelerating Data Ingestion with Databricks AutoloaderAccelerating Data Ingestion with Databricks Autoloader
Accelerating Data Ingestion with Databricks Autoloader
Databricks
 
The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84
Mahmoud Samir Fayed
 
spring-ioc.pptx
spring-ioc.pptxspring-ioc.pptx
spring-ioc.pptx
AshokGupta647838
 
Introduction to Python - Part Three
Introduction to Python - Part ThreeIntroduction to Python - Part Three
Introduction to Python - Part Three
amiable_indian
 
Chapter iii(oop)
Chapter iii(oop)Chapter iii(oop)
Chapter iii(oop)
Chhom Karath
 
[OOP - Lec 13,14,15] Constructors / Destructor and its Types
[OOP - Lec 13,14,15] Constructors / Destructor and its Types[OOP - Lec 13,14,15] Constructors / Destructor and its Types
[OOP - Lec 13,14,15] Constructors / Destructor and its Types
Muhammad Hammad Waseem
 
Five Steps to Get Facebook Engagement Indicators
Five Steps to Get Facebook Engagement IndicatorsFive Steps to Get Facebook Engagement Indicators
Five Steps to Get Facebook Engagement Indicators
Weiai Wayne Xu
 

Similar to Lecture 17 (Blockchain Implementation using Python).pptx (20)

Introduction to bit coin
Introduction to bit coinIntroduction to bit coin
Introduction to bit coin
 
Python packages for blockchain
Python packages for blockchainPython packages for blockchain
Python packages for blockchain
 
Build and save your own Gutenberg Block Patterns
Build and save your own Gutenberg Block PatternsBuild and save your own Gutenberg Block Patterns
Build and save your own Gutenberg Block Patterns
 
Let's build a blockchain.... in 40 minutes!
Let's build a blockchain.... in 40 minutes!Let's build a blockchain.... in 40 minutes!
Let's build a blockchain.... in 40 minutes!
 
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
 
Creating Custom Gutenberg Blocks for WordPress
Creating Custom Gutenberg Blocks for WordPressCreating Custom Gutenberg Blocks for WordPress
Creating Custom Gutenberg Blocks for WordPress
 
Building your first Gutenberg block
Building your first Gutenberg blockBuilding your first Gutenberg block
Building your first Gutenberg block
 
Day 1.pptx
Day 1.pptxDay 1.pptx
Day 1.pptx
 
Write this in C language. This project will require students to si.pdf
Write this in C language. This project will require students to si.pdfWrite this in C language. This project will require students to si.pdf
Write this in C language. This project will require students to si.pdf
 
Python multithreading
Python multithreadingPython multithreading
Python multithreading
 
Classes, Inheritance ,Packages & Interfaces.pptx
Classes, Inheritance ,Packages & Interfaces.pptxClasses, Inheritance ,Packages & Interfaces.pptx
Classes, Inheritance ,Packages & Interfaces.pptx
 
BlockChain implementation by python
BlockChain implementation by pythonBlockChain implementation by python
BlockChain implementation by python
 
Extending Studio - Piotr Nalepa & Kamil Musiał - Presentation at eZ Conferenc...
Extending Studio - Piotr Nalepa & Kamil Musiał - Presentation at eZ Conferenc...Extending Studio - Piotr Nalepa & Kamil Musiał - Presentation at eZ Conferenc...
Extending Studio - Piotr Nalepa & Kamil Musiał - Presentation at eZ Conferenc...
 
Accelerating Data Ingestion with Databricks Autoloader
Accelerating Data Ingestion with Databricks AutoloaderAccelerating Data Ingestion with Databricks Autoloader
Accelerating Data Ingestion with Databricks Autoloader
 
The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84
 
spring-ioc.pptx
spring-ioc.pptxspring-ioc.pptx
spring-ioc.pptx
 
Introduction to Python - Part Three
Introduction to Python - Part ThreeIntroduction to Python - Part Three
Introduction to Python - Part Three
 
Chapter iii(oop)
Chapter iii(oop)Chapter iii(oop)
Chapter iii(oop)
 
[OOP - Lec 13,14,15] Constructors / Destructor and its Types
[OOP - Lec 13,14,15] Constructors / Destructor and its Types[OOP - Lec 13,14,15] Constructors / Destructor and its Types
[OOP - Lec 13,14,15] Constructors / Destructor and its Types
 
Five Steps to Get Facebook Engagement Indicators
Five Steps to Get Facebook Engagement IndicatorsFive Steps to Get Facebook Engagement Indicators
Five Steps to Get Facebook Engagement Indicators
 

Recently uploaded

Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
jpupo2018
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 

Recently uploaded (20)

Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 

Lecture 17 (Blockchain Implementation using Python).pptx

  • 1. How to develop a custom blockchain?
  • 3. Libraries required • Datetime (This module supplies classes for manipulating dates and times.) • Hashlib (Secure hashes and message digests) Import these libraries
  • 4. Step 1: Define the structure of a block • Define the structure for the block as a class: class Block: def __init__(self, previous_block_hash, data, timestamp): self.previous_block_hash = previous_block_hash self.data = data self.timestamp = timestamp self.hash = self.get_hash() • #function to create our own hash this hash will be take all the data in the block header and run SHA 256 two time (inner and outer encryption) • #Only considered the previous block hash, data and timestamp to be part of block for simplicity.
  • 5. Step 1: Define the structure of a block • Define a class:
  • 6. Step 2: Define the function to perform the hashing of block components def get_hash(self): #will take only object self as it has all we need for this function #generating binary representation of the header header_bin = (str(self.previous_block_hash) + str(self.data) + str(self.timestamp)).encode() #encode function #we convert all the data in strings to feed it as input for hash function SHA256 (in this function two-level hashing is illustrated in the from of inner hash and outer hash) #encode() is used to encode the code into unicode inner_hash = hashlib.sha256(header_bin.encode()).hexdigest().encode() #hexdigest() convert the data in hexadecimal format #hashlib.sha256 is used for hashing using SHA256 from library hashlib outer_hash = hashlib.sha256(inner_hash).hexdigest() return outer_hash
  • 7. Step 2: Define the function to perform the hashing of block components
  • 8. Step 3: Creating a genesis block (Static Coding Method) def create_genesis_block(): return Block("0", "0", datetime.datetime.now()) A static method is bound to a class rather than the objects for that class. This means that a static method can be called without an object for that class. This also means that static methods cannot modify the state of an object as they are not bound to it.
  • 9. Step 3: Creating a genesis block (Static Coding Method)
  • 10. Resultant of Step1, 2 and 3 (block.py) • save this as block.py
  • 12. Creating Blockchain • Create a file named Blockchain.py • Import the structure of block defined in block.py file from block import Block
  • 13. Creating Blockchain • Generate the Genesis block and print its hash on screen b1 = Block.create_genesis_block() Print(b1.hash)
  • 14. Creating Blockchain • Generate the Genesis block and print its hash on screen
  • 15. Creating Blockchain • Lets add some elements to our blockchain • For simplicity, lets fix the number of blocks num_blocks_to_add = 10
  • 16. Creating Blockchain • Lets add some elements to our blockchain • Initialize the loop and append the blocks for i in range(1, num_blocks_to_add): block_chain.append(Block(block_chain[i-1].hash, "Block number %d" % i, datetime.datetime.now()))
  • 17. Creating Blockchain • Lets add some elements to our blockchain • Initialize the loop and append the blocks
  • 18. Adding more blocks to Blockchain Specifying the number of blocks to add into blockchain
  • 19. Adding more blocks to Blockchain Creating the genesis block and adding into blockchain
  • 20. Adding more blocks to Blockchain Printing the value of hashed genesis block
  • 21. Adding more blocks to Blockchain Running a loop to generate the given number of blocks
  • 22. Adding more blocks to Blockchain Appending new blocks
  • 23. Adding more blocks to Blockchain Printing the hash of the generated block
  • 24. Adding more blocks to Blockchain