SlideShare a Scribd company logo
Lecture Series by
Tharindu Weerasinghe
For the 3rd Year Undergrads of APIIT – Sri Lanka
www.tharinduweerasinghe.com
Basic Concepts
Of
Block Chain
Outline
• Basic information on Block Chain
• Sample Code in Python
• Output of the above code sample
• Mining
• About Cryptocurrencies!
• Other Business areas that user Block Chain apart from
Cryptocurrencies!
www.tharinduweerasinghe.com
The Concept
www.tharinduweerasinghe.com
A very smart set of secured digital records or journal that contains some “DATA”,
their integrity (or validity) information!
The name Blockchain comes as each record (block) has set of data attached to it!
This mechanism is very handsome not only in Cryptocurrency but also in various
other industries!
The very first block in the chain developed/created by an organization or
whoever the person, is called the “Genesis Block”. Literally it is impossible for you
and me to own a genesis block(unless we plan to create a new cryptocurrency)
• Ref: Blockchain explained and its application to payments | Paiementor
Basic information on Block Chain
www.tharinduweerasinghe.com
Ref: http://cs.unibo.it/~danilo.montesi/CBD/Articoli/2017Blockchain.pdf
Basic information on Block Chain
www.tharinduweerasinghe.com
import hashlib
import json
from time import time
class Blockchain(object):
def __init__(self):
self.chain = []
self.pending_transactions = []
self.new_block(previous_hash="The Times 03/Jan/2009 Chancellor on brink of second bailout for banks.", proof=100)
# Create a new block listing [key/value pairs) of block information in a JSON object.
# Reset the list of pending transactions & append the newest block to the chain.
def new_block(self, proof, previous_hash=None):
block = {
'index': len(self.chain) + 1,
'timestamp': time(),
'transactions': self.pending_transactions,
'proof': proof,
'previous_hash': previous_hash or self.hash(self.chain[-1]),
}
self.pending_transactions = []
self.chain.append(block)
return block
#Search the blockchain for the most recent block.
@property
def last_block(self):
return self.chain[-1]
# Add a transaction with relevant info to the 'blockpool' - list of pending tx's.
def new_transaction(self, sender, recipient, amount):
transaction = {
'sender': sender,
'recipient': recipient,
'amount': amount
}
self.pending_transactions.append(transaction)
return self.last_block['index'] + 1
# receive one block. Turn it into a string, turn that into Unicode (for hashing). Hash with SHA256 encryption, then translate the Unicode into a hexidecimal string.
def hash(self, block):
string_object = json.dumps(block, sort_keys=True)
block_string = string_object.encode()
raw_hash = hashlib.sha256(block_string)
hex_hash = raw_hash.hexdigest()
return hex_hash
blockchain = Blockchain()
t1 = blockchain.new_transaction("Satoshi", "Mike", '5 BTC')
t2 = blockchain.new_transaction("Mike", "Satoshi", '1 BTC')
t3 = blockchain.new_transaction("Satoshi", "Hal Finney", '5 BTC')
blockchain.new_block(12345)
t4 = blockchain.new_transaction("Mike", "Alice", '1 BTC')
t5 = blockchain.new_transaction("Alice", "Bob", '0.5 BTC')
t6 = blockchain.new_transaction("Bob", "Mike", '0.5 BTC')
blockchain.new_block(6789)
print("Genesis block: n", blockchain.chain)
Sample Code in Python to implement a simple
Blockchain and print a Genesis Block
Kudos:
https://github.com/mchrupcala/blockchain-walkthrough
www.tharinduweerasinghe.com
The output of the above code
Kudos:
https://github.com/mchrupcala/blockchain-walkthrough
Basic information on Block Chain
• The block header is a summary of the contents of the block itself. It
contains the following six components:
• The version of software the Bitcoin client is running
• The timestamp of the block
• The root of its containing transactions' Merkle tree
• The hash of the block before it
• A nonce [number only used once]
• The target
www.tharinduweerasinghe.com
• It is the process of creating new bitcoin by solving puzzles. It
comprises of complex computing systems equipped with specialized
chips competing to solve mathematical puzzles. The first bitcoin
miner (as these systems are called) to solve the puzzle is rewarded
with bitcoin. The mining process also confirms transactions on the
cryptocurrency's network and makes them trustworthy.
• For a little time after Bitcoin was launched, it was mined on desktop
computers with regular central processing units (CPUs). But the
process was extremely slow. Now the cryptocurrency is generated
using large mining pools spread across many geo locations.
www.tharinduweerasinghe.com
Mining related to Blockchain
• At a very high level, Bitcoin mining is a system in which all Bitcoin
transactions are sent to Bitcoin miners.
• Miners select one megabyte worth of transactions, bundle them as an
input into the SHA-256 function, and attempt to find a specific
output the network accepts.
• The first miner to find this output and publish the block to the
network receives a reward in the form of transaction fees and the
creation of new Bitcoin.
• Reference: https://www.freecodecamp.org/news/how-bitcoin-mining-really-
works-38563ec38c87/
www.tharinduweerasinghe.com
Mining related to Blockchain (Contd.)
www.tharinduweerasinghe.com
Kudos: https://vulcanpost.com/736388/what-is-bitcoin/
Cryptocurrency : Bitcoin
www.tharinduweerasinghe.com
Kudos: https://en.bitcoinwiki.org/wiki/Bitcoin_transaction
• Ether (ETH)
• Solana (SOL)
• Terra (LUNA)
• Binance Coin (BNB)
• Aave (AAVE)
• Uniswap (UNI)
• Reference:
https://money.usnews.com/investing/cryptocurrency/slideshows/whats-
the-best-cryptocurrency-to-buy
www.tharinduweerasinghe.com
Cryptocurrency : Others
Other Business areas that user Block Chain apart
from Cryptocurrencies!
• SMART CONTRACTS
• Smart contracts are programs stored on a particular blockchain that run when predetermined conditions are met.
• They’re operated by following simple “if/when…then…” statements that are written into code on a blockchain. A network of
computers executes the actions when predetermined conditions have been met and verified. These actions could include
releasing funds to the appropriate parties, registering a vehicle, sending notifications, or issuing a ticket.
• The relevant blockchain is updated when the transaction is completed. That means the transaction cannot be changed,
furthermore, only parties who have been granted permission can see the results.
• They typically are used to automate the execution of an agreement so that all participants can be immediately certain of the
outcome, without any mediator involvement or time loss.
Reference: https://www.ibm.com/topics/smart-contracts
www.tharinduweerasinghe.com
• In Supply Chains
• In Agriculture
• In Food Safety
• In Health Sector
• In Electricity/Power Generation and Distribution
• You need to read on your very own!
Ref: https://www.ibm.com/topics/blockchain-for-business
www.tharinduweerasinghe.com
Blockchain for Business beyond Crypto
References (Due kudos):
• Python coding related:
• https://medium.com/coinmonks/python-tutorial-build-a-blockchain-713c706f6531
• https://www.geeksforgeeks.org/create-simple-blockchain-using-python/
• Mining related:
• https://www.investopedia.com/tech/how-does-bitcoin-mining-work/
• https://www.freecodecamp.org/news/how-bitcoin-mining-really-works-38563ec38c87/
• Bitcoin related:
• https://medium.com/coinmonks/bitcoin-mempool-simply-explained-7f76be235e85
• https://en.bitcoinwiki.org/wiki/Bitcoin_transaction
• https://vulcanpost.com/736388/what-is-bitcoin/
• https://www.investopedia.com/terms/m/merkle-tree.asp
• Other business’s related:
• https://www.ibm.com/topics/blockchain-for-business
• Watch:
• How does a blockchain work - Simply Explained – YouTube
• Creating a blockchain with Javascript (Blockchain, part 1) - YouTube
www.tharinduweerasinghe.com

More Related Content

Similar to Basics of Block Chain

Blockchain - Presentacion Betabeers Galicia 10/12/2014
Blockchain - Presentacion Betabeers Galicia 10/12/2014Blockchain - Presentacion Betabeers Galicia 10/12/2014
Blockchain - Presentacion Betabeers Galicia 10/12/2014
WeKCo Coworking
 
Blockchain 101 - public, tokenized blockchains
Blockchain 101 - public, tokenized blockchainsBlockchain 101 - public, tokenized blockchains
Blockchain 101 - public, tokenized blockchains
Brett Colbert
 
Blockchain, Hyperledger, DeFi, Web 3.0 - understanding and concepts
Blockchain,  Hyperledger, DeFi, Web 3.0 - understanding and conceptsBlockchain,  Hyperledger, DeFi, Web 3.0 - understanding and concepts
Blockchain, Hyperledger, DeFi, Web 3.0 - understanding and concepts
keithfernandez19
 
Blockchain general presentation nov 2017 v eng
Blockchain general presentation nov 2017 v engBlockchain general presentation nov 2017 v eng
Blockchain general presentation nov 2017 v eng
David Vangulick
 
Blockchain Fundamental_KIPMI_2022.02.26.pdf
Blockchain Fundamental_KIPMI_2022.02.26.pdfBlockchain Fundamental_KIPMI_2022.02.26.pdf
Blockchain Fundamental_KIPMI_2022.02.26.pdf
adinugroho751867
 
Blockchain Technology | Bitcoin | Ethereum Coin | Cryptocurrency
Blockchain Technology | Bitcoin | Ethereum Coin | CryptocurrencyBlockchain Technology | Bitcoin | Ethereum Coin | Cryptocurrency
Blockchain Technology | Bitcoin | Ethereum Coin | Cryptocurrency
Unbiased Technolab
 
Introduction to Blockchain and Smart Contracts
Introduction to Blockchain and Smart ContractsIntroduction to Blockchain and Smart Contracts
Introduction to Blockchain and Smart Contracts
Saad Zaher
 
Blockchain fundamentals
Blockchain fundamentalsBlockchain fundamentals
Blockchain fundamentals
Ahmed Mekawy
 
Blockchain, Finance & Regulatory Development
Blockchain, Finance & Regulatory DevelopmentBlockchain, Finance & Regulatory Development
Blockchain, Finance & Regulatory Development
Alex Makosz
 
Introduction to Blockchain Technology
Introduction to Blockchain TechnologyIntroduction to Blockchain Technology
Introduction to Blockchain Technology
Md. Hasan Basri (Angel)
 
blockchain class 3.pdf
blockchain class 3.pdfblockchain class 3.pdf
blockchain class 3.pdf
GopalSB
 
Blockchain and BPM - Reflections on Four Years of Research and Applications
Blockchain and BPM - Reflections on Four Years of Research and ApplicationsBlockchain and BPM - Reflections on Four Years of Research and Applications
Blockchain and BPM - Reflections on Four Years of Research and Applications
Ingo Weber
 
14 Jan17- Nullmeets -Blockchain concept decoded by Ninad Sarang
14 Jan17- Nullmeets -Blockchain concept decoded by Ninad Sarang14 Jan17- Nullmeets -Blockchain concept decoded by Ninad Sarang
14 Jan17- Nullmeets -Blockchain concept decoded by Ninad Sarang
Ninad Sarang
 
BlockchainConf.tech - Build a private blockchain workshop
BlockchainConf.tech - Build a private blockchain workshopBlockchainConf.tech - Build a private blockchain workshop
BlockchainConf.tech - Build a private blockchain workshop
Pad Kankipati
 
BITCOIN EXPLAINED
BITCOIN EXPLAINEDBITCOIN EXPLAINED
BITCOIN EXPLAINED
Murlidhar Sarda
 
Bitcoin 2.0
Bitcoin 2.0 Bitcoin 2.0
Blockchain Technology And Cryptocurrency
Blockchain Technology And CryptocurrencyBlockchain Technology And Cryptocurrency
Blockchain Technology And Cryptocurrency
Eno Bassey
 
A Quick Start To Blockchain by Seval Capraz
A Quick Start To Blockchain by Seval CaprazA Quick Start To Blockchain by Seval Capraz
A Quick Start To Blockchain by Seval Capraz
Seval Çapraz
 
chapter 4 Selected Topics in computer.pptx
chapter 4 Selected Topics in computer.pptxchapter 4 Selected Topics in computer.pptx
chapter 4 Selected Topics in computer.pptx
AschalewAyele2
 
chapter 4 Selected Topics in computer.pptx
chapter 4 Selected Topics in computer.pptxchapter 4 Selected Topics in computer.pptx
chapter 4 Selected Topics in computer.pptx
AschalewAyele2
 

Similar to Basics of Block Chain (20)

Blockchain - Presentacion Betabeers Galicia 10/12/2014
Blockchain - Presentacion Betabeers Galicia 10/12/2014Blockchain - Presentacion Betabeers Galicia 10/12/2014
Blockchain - Presentacion Betabeers Galicia 10/12/2014
 
Blockchain 101 - public, tokenized blockchains
Blockchain 101 - public, tokenized blockchainsBlockchain 101 - public, tokenized blockchains
Blockchain 101 - public, tokenized blockchains
 
Blockchain, Hyperledger, DeFi, Web 3.0 - understanding and concepts
Blockchain,  Hyperledger, DeFi, Web 3.0 - understanding and conceptsBlockchain,  Hyperledger, DeFi, Web 3.0 - understanding and concepts
Blockchain, Hyperledger, DeFi, Web 3.0 - understanding and concepts
 
Blockchain general presentation nov 2017 v eng
Blockchain general presentation nov 2017 v engBlockchain general presentation nov 2017 v eng
Blockchain general presentation nov 2017 v eng
 
Blockchain Fundamental_KIPMI_2022.02.26.pdf
Blockchain Fundamental_KIPMI_2022.02.26.pdfBlockchain Fundamental_KIPMI_2022.02.26.pdf
Blockchain Fundamental_KIPMI_2022.02.26.pdf
 
Blockchain Technology | Bitcoin | Ethereum Coin | Cryptocurrency
Blockchain Technology | Bitcoin | Ethereum Coin | CryptocurrencyBlockchain Technology | Bitcoin | Ethereum Coin | Cryptocurrency
Blockchain Technology | Bitcoin | Ethereum Coin | Cryptocurrency
 
Introduction to Blockchain and Smart Contracts
Introduction to Blockchain and Smart ContractsIntroduction to Blockchain and Smart Contracts
Introduction to Blockchain and Smart Contracts
 
Blockchain fundamentals
Blockchain fundamentalsBlockchain fundamentals
Blockchain fundamentals
 
Blockchain, Finance & Regulatory Development
Blockchain, Finance & Regulatory DevelopmentBlockchain, Finance & Regulatory Development
Blockchain, Finance & Regulatory Development
 
Introduction to Blockchain Technology
Introduction to Blockchain TechnologyIntroduction to Blockchain Technology
Introduction to Blockchain Technology
 
blockchain class 3.pdf
blockchain class 3.pdfblockchain class 3.pdf
blockchain class 3.pdf
 
Blockchain and BPM - Reflections on Four Years of Research and Applications
Blockchain and BPM - Reflections on Four Years of Research and ApplicationsBlockchain and BPM - Reflections on Four Years of Research and Applications
Blockchain and BPM - Reflections on Four Years of Research and Applications
 
14 Jan17- Nullmeets -Blockchain concept decoded by Ninad Sarang
14 Jan17- Nullmeets -Blockchain concept decoded by Ninad Sarang14 Jan17- Nullmeets -Blockchain concept decoded by Ninad Sarang
14 Jan17- Nullmeets -Blockchain concept decoded by Ninad Sarang
 
BlockchainConf.tech - Build a private blockchain workshop
BlockchainConf.tech - Build a private blockchain workshopBlockchainConf.tech - Build a private blockchain workshop
BlockchainConf.tech - Build a private blockchain workshop
 
BITCOIN EXPLAINED
BITCOIN EXPLAINEDBITCOIN EXPLAINED
BITCOIN EXPLAINED
 
Bitcoin 2.0
Bitcoin 2.0 Bitcoin 2.0
Bitcoin 2.0
 
Blockchain Technology And Cryptocurrency
Blockchain Technology And CryptocurrencyBlockchain Technology And Cryptocurrency
Blockchain Technology And Cryptocurrency
 
A Quick Start To Blockchain by Seval Capraz
A Quick Start To Blockchain by Seval CaprazA Quick Start To Blockchain by Seval Capraz
A Quick Start To Blockchain by Seval Capraz
 
chapter 4 Selected Topics in computer.pptx
chapter 4 Selected Topics in computer.pptxchapter 4 Selected Topics in computer.pptx
chapter 4 Selected Topics in computer.pptx
 
chapter 4 Selected Topics in computer.pptx
chapter 4 Selected Topics in computer.pptxchapter 4 Selected Topics in computer.pptx
chapter 4 Selected Topics in computer.pptx
 

More from Tharindu Weerasinghe

C Propgramming.pdf
C Propgramming.pdfC Propgramming.pdf
C Propgramming.pdf
Tharindu Weerasinghe
 
Basics of Computer Networks in Sinhala
Basics of Computer Networks in SinhalaBasics of Computer Networks in Sinhala
Basics of Computer Networks in Sinhala
Tharindu Weerasinghe
 
Data Structures & Algorithms in Sinhala
Data Structures & Algorithms in SinhalaData Structures & Algorithms in Sinhala
Data Structures & Algorithms in Sinhala
Tharindu Weerasinghe
 
Object Oriended Programming in Sinhala
Object Oriended Programming in Sinhala Object Oriended Programming in Sinhala
Object Oriended Programming in Sinhala
Tharindu Weerasinghe
 
Tips For A Better Undergraduate Research
Tips For A Better Undergraduate ResearchTips For A Better Undergraduate Research
Tips For A Better Undergraduate Research
Tharindu Weerasinghe
 
Basics of IoT
Basics of IoTBasics of IoT
Basics of IoT
Tharindu Weerasinghe
 
REST API Basics
REST API BasicsREST API Basics
REST API Basics
Tharindu Weerasinghe
 
Cloud Conputing Basics and some Related Research Topics
Cloud Conputing Basics and some Related Research TopicsCloud Conputing Basics and some Related Research Topics
Cloud Conputing Basics and some Related Research Topics
Tharindu Weerasinghe
 
Basic Concepts and Trends in Emerging Technologies
Basic Concepts and Trends in Emerging TechnologiesBasic Concepts and Trends in Emerging Technologies
Basic Concepts and Trends in Emerging Technologies
Tharindu Weerasinghe
 
Introcution to EJB
Introcution to EJBIntrocution to EJB
Introcution to EJB
Tharindu Weerasinghe
 
Introduction to Enterprise Applications and Tools
Introduction to Enterprise Applications and ToolsIntroduction to Enterprise Applications and Tools
Introduction to Enterprise Applications and Tools
Tharindu Weerasinghe
 
Introduction to Agile Software Development & Python
Introduction to Agile Software Development & PythonIntroduction to Agile Software Development & Python
Introduction to Agile Software Development & Python
Tharindu Weerasinghe
 
Agile Languages for Rapid Prototyping
Agile Languages for Rapid PrototypingAgile Languages for Rapid Prototyping
Agile Languages for Rapid Prototyping
Tharindu Weerasinghe
 
Things to ponder before you start building [cooperate] software
Things to ponder before you start building [cooperate] softwareThings to ponder before you start building [cooperate] software
Things to ponder before you start building [cooperate] software
Tharindu Weerasinghe
 
How to make screens and the internet safe for Children
How to make screens and the internet safe for Children How to make screens and the internet safe for Children
How to make screens and the internet safe for Children
Tharindu Weerasinghe
 
Different Concepts on Databases
Different Concepts on DatabasesDifferent Concepts on Databases
Different Concepts on Databases
Tharindu Weerasinghe
 
A Survey Study on Higher Education Trends among Sri Lankan IT Professionals
A Survey Study on Higher Education Trends among Sri Lankan IT ProfessionalsA Survey Study on Higher Education Trends among Sri Lankan IT Professionals
A Survey Study on Higher Education Trends among Sri Lankan IT Professionals
Tharindu Weerasinghe
 
A Survey Study on Higher Education Trends among Information Technology Prof...
A Survey Study  on  Higher Education Trends among Information Technology Prof...A Survey Study  on  Higher Education Trends among Information Technology Prof...
A Survey Study on Higher Education Trends among Information Technology Prof...
Tharindu Weerasinghe
 
Professionalism and Industry Expectations related to IT industry
Professionalism and Industry Expectations related to IT industry  Professionalism and Industry Expectations related to IT industry
Professionalism and Industry Expectations related to IT industry
Tharindu Weerasinghe
 
Triggers and Stored Procedures
Triggers and Stored ProceduresTriggers and Stored Procedures
Triggers and Stored Procedures
Tharindu Weerasinghe
 

More from Tharindu Weerasinghe (20)

C Propgramming.pdf
C Propgramming.pdfC Propgramming.pdf
C Propgramming.pdf
 
Basics of Computer Networks in Sinhala
Basics of Computer Networks in SinhalaBasics of Computer Networks in Sinhala
Basics of Computer Networks in Sinhala
 
Data Structures & Algorithms in Sinhala
Data Structures & Algorithms in SinhalaData Structures & Algorithms in Sinhala
Data Structures & Algorithms in Sinhala
 
Object Oriended Programming in Sinhala
Object Oriended Programming in Sinhala Object Oriended Programming in Sinhala
Object Oriended Programming in Sinhala
 
Tips For A Better Undergraduate Research
Tips For A Better Undergraduate ResearchTips For A Better Undergraduate Research
Tips For A Better Undergraduate Research
 
Basics of IoT
Basics of IoTBasics of IoT
Basics of IoT
 
REST API Basics
REST API BasicsREST API Basics
REST API Basics
 
Cloud Conputing Basics and some Related Research Topics
Cloud Conputing Basics and some Related Research TopicsCloud Conputing Basics and some Related Research Topics
Cloud Conputing Basics and some Related Research Topics
 
Basic Concepts and Trends in Emerging Technologies
Basic Concepts and Trends in Emerging TechnologiesBasic Concepts and Trends in Emerging Technologies
Basic Concepts and Trends in Emerging Technologies
 
Introcution to EJB
Introcution to EJBIntrocution to EJB
Introcution to EJB
 
Introduction to Enterprise Applications and Tools
Introduction to Enterprise Applications and ToolsIntroduction to Enterprise Applications and Tools
Introduction to Enterprise Applications and Tools
 
Introduction to Agile Software Development & Python
Introduction to Agile Software Development & PythonIntroduction to Agile Software Development & Python
Introduction to Agile Software Development & Python
 
Agile Languages for Rapid Prototyping
Agile Languages for Rapid PrototypingAgile Languages for Rapid Prototyping
Agile Languages for Rapid Prototyping
 
Things to ponder before you start building [cooperate] software
Things to ponder before you start building [cooperate] softwareThings to ponder before you start building [cooperate] software
Things to ponder before you start building [cooperate] software
 
How to make screens and the internet safe for Children
How to make screens and the internet safe for Children How to make screens and the internet safe for Children
How to make screens and the internet safe for Children
 
Different Concepts on Databases
Different Concepts on DatabasesDifferent Concepts on Databases
Different Concepts on Databases
 
A Survey Study on Higher Education Trends among Sri Lankan IT Professionals
A Survey Study on Higher Education Trends among Sri Lankan IT ProfessionalsA Survey Study on Higher Education Trends among Sri Lankan IT Professionals
A Survey Study on Higher Education Trends among Sri Lankan IT Professionals
 
A Survey Study on Higher Education Trends among Information Technology Prof...
A Survey Study  on  Higher Education Trends among Information Technology Prof...A Survey Study  on  Higher Education Trends among Information Technology Prof...
A Survey Study on Higher Education Trends among Information Technology Prof...
 
Professionalism and Industry Expectations related to IT industry
Professionalism and Industry Expectations related to IT industry  Professionalism and Industry Expectations related to IT industry
Professionalism and Industry Expectations related to IT industry
 
Triggers and Stored Procedures
Triggers and Stored ProceduresTriggers and Stored Procedures
Triggers and Stored Procedures
 

Recently uploaded

GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Why React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdfWhy React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdf
ayushiqss
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
Jelle | Nordend
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
Peter Caitens
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 

Recently uploaded (20)

GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Why React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdfWhy React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdf
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 

Basics of Block Chain

  • 1. Lecture Series by Tharindu Weerasinghe For the 3rd Year Undergrads of APIIT – Sri Lanka www.tharinduweerasinghe.com Basic Concepts Of Block Chain
  • 2. Outline • Basic information on Block Chain • Sample Code in Python • Output of the above code sample • Mining • About Cryptocurrencies! • Other Business areas that user Block Chain apart from Cryptocurrencies! www.tharinduweerasinghe.com
  • 3. The Concept www.tharinduweerasinghe.com A very smart set of secured digital records or journal that contains some “DATA”, their integrity (or validity) information! The name Blockchain comes as each record (block) has set of data attached to it! This mechanism is very handsome not only in Cryptocurrency but also in various other industries! The very first block in the chain developed/created by an organization or whoever the person, is called the “Genesis Block”. Literally it is impossible for you and me to own a genesis block(unless we plan to create a new cryptocurrency)
  • 4. • Ref: Blockchain explained and its application to payments | Paiementor Basic information on Block Chain
  • 6. www.tharinduweerasinghe.com import hashlib import json from time import time class Blockchain(object): def __init__(self): self.chain = [] self.pending_transactions = [] self.new_block(previous_hash="The Times 03/Jan/2009 Chancellor on brink of second bailout for banks.", proof=100) # Create a new block listing [key/value pairs) of block information in a JSON object. # Reset the list of pending transactions & append the newest block to the chain. def new_block(self, proof, previous_hash=None): block = { 'index': len(self.chain) + 1, 'timestamp': time(), 'transactions': self.pending_transactions, 'proof': proof, 'previous_hash': previous_hash or self.hash(self.chain[-1]), } self.pending_transactions = [] self.chain.append(block) return block #Search the blockchain for the most recent block. @property def last_block(self): return self.chain[-1] # Add a transaction with relevant info to the 'blockpool' - list of pending tx's. def new_transaction(self, sender, recipient, amount): transaction = { 'sender': sender, 'recipient': recipient, 'amount': amount } self.pending_transactions.append(transaction) return self.last_block['index'] + 1 # receive one block. Turn it into a string, turn that into Unicode (for hashing). Hash with SHA256 encryption, then translate the Unicode into a hexidecimal string. def hash(self, block): string_object = json.dumps(block, sort_keys=True) block_string = string_object.encode() raw_hash = hashlib.sha256(block_string) hex_hash = raw_hash.hexdigest() return hex_hash blockchain = Blockchain() t1 = blockchain.new_transaction("Satoshi", "Mike", '5 BTC') t2 = blockchain.new_transaction("Mike", "Satoshi", '1 BTC') t3 = blockchain.new_transaction("Satoshi", "Hal Finney", '5 BTC') blockchain.new_block(12345) t4 = blockchain.new_transaction("Mike", "Alice", '1 BTC') t5 = blockchain.new_transaction("Alice", "Bob", '0.5 BTC') t6 = blockchain.new_transaction("Bob", "Mike", '0.5 BTC') blockchain.new_block(6789) print("Genesis block: n", blockchain.chain) Sample Code in Python to implement a simple Blockchain and print a Genesis Block Kudos: https://github.com/mchrupcala/blockchain-walkthrough
  • 7. www.tharinduweerasinghe.com The output of the above code Kudos: https://github.com/mchrupcala/blockchain-walkthrough
  • 8. Basic information on Block Chain • The block header is a summary of the contents of the block itself. It contains the following six components: • The version of software the Bitcoin client is running • The timestamp of the block • The root of its containing transactions' Merkle tree • The hash of the block before it • A nonce [number only used once] • The target www.tharinduweerasinghe.com
  • 9. • It is the process of creating new bitcoin by solving puzzles. It comprises of complex computing systems equipped with specialized chips competing to solve mathematical puzzles. The first bitcoin miner (as these systems are called) to solve the puzzle is rewarded with bitcoin. The mining process also confirms transactions on the cryptocurrency's network and makes them trustworthy. • For a little time after Bitcoin was launched, it was mined on desktop computers with regular central processing units (CPUs). But the process was extremely slow. Now the cryptocurrency is generated using large mining pools spread across many geo locations. www.tharinduweerasinghe.com Mining related to Blockchain
  • 10. • At a very high level, Bitcoin mining is a system in which all Bitcoin transactions are sent to Bitcoin miners. • Miners select one megabyte worth of transactions, bundle them as an input into the SHA-256 function, and attempt to find a specific output the network accepts. • The first miner to find this output and publish the block to the network receives a reward in the form of transaction fees and the creation of new Bitcoin. • Reference: https://www.freecodecamp.org/news/how-bitcoin-mining-really- works-38563ec38c87/ www.tharinduweerasinghe.com Mining related to Blockchain (Contd.)
  • 13. • Ether (ETH) • Solana (SOL) • Terra (LUNA) • Binance Coin (BNB) • Aave (AAVE) • Uniswap (UNI) • Reference: https://money.usnews.com/investing/cryptocurrency/slideshows/whats- the-best-cryptocurrency-to-buy www.tharinduweerasinghe.com Cryptocurrency : Others
  • 14. Other Business areas that user Block Chain apart from Cryptocurrencies! • SMART CONTRACTS • Smart contracts are programs stored on a particular blockchain that run when predetermined conditions are met. • They’re operated by following simple “if/when…then…” statements that are written into code on a blockchain. A network of computers executes the actions when predetermined conditions have been met and verified. These actions could include releasing funds to the appropriate parties, registering a vehicle, sending notifications, or issuing a ticket. • The relevant blockchain is updated when the transaction is completed. That means the transaction cannot be changed, furthermore, only parties who have been granted permission can see the results. • They typically are used to automate the execution of an agreement so that all participants can be immediately certain of the outcome, without any mediator involvement or time loss. Reference: https://www.ibm.com/topics/smart-contracts www.tharinduweerasinghe.com
  • 15. • In Supply Chains • In Agriculture • In Food Safety • In Health Sector • In Electricity/Power Generation and Distribution • You need to read on your very own! Ref: https://www.ibm.com/topics/blockchain-for-business www.tharinduweerasinghe.com Blockchain for Business beyond Crypto
  • 16. References (Due kudos): • Python coding related: • https://medium.com/coinmonks/python-tutorial-build-a-blockchain-713c706f6531 • https://www.geeksforgeeks.org/create-simple-blockchain-using-python/ • Mining related: • https://www.investopedia.com/tech/how-does-bitcoin-mining-work/ • https://www.freecodecamp.org/news/how-bitcoin-mining-really-works-38563ec38c87/ • Bitcoin related: • https://medium.com/coinmonks/bitcoin-mempool-simply-explained-7f76be235e85 • https://en.bitcoinwiki.org/wiki/Bitcoin_transaction • https://vulcanpost.com/736388/what-is-bitcoin/ • https://www.investopedia.com/terms/m/merkle-tree.asp • Other business’s related: • https://www.ibm.com/topics/blockchain-for-business • Watch: • How does a blockchain work - Simply Explained – YouTube • Creating a blockchain with Javascript (Blockchain, part 1) - YouTube www.tharinduweerasinghe.com