SlideShare una empresa de Scribd logo
1 de 16
Descargar para leer sin conexión
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

Más contenido relacionado

Similar a 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/2014WeKCo Coworking
 
Blockchain 101 - public, tokenized blockchains
Blockchain 101 - public, tokenized blockchainsBlockchain 101 - public, tokenized blockchains
Blockchain 101 - public, tokenized blockchainsBrett 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 conceptskeithfernandez19
 
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 engDavid 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.pdfadinugroho751867
 
Blockchain Technology | Bitcoin | Ethereum Coin | Cryptocurrency
Blockchain Technology | Bitcoin | Ethereum Coin | CryptocurrencyBlockchain Technology | Bitcoin | Ethereum Coin | Cryptocurrency
Blockchain Technology | Bitcoin | Ethereum Coin | CryptocurrencyUnbiased Technolab
 
Introduction to Blockchain and Smart Contracts
Introduction to Blockchain and Smart ContractsIntroduction to Blockchain and Smart Contracts
Introduction to Blockchain and Smart ContractsSaad Zaher
 
Blockchain fundamentals
Blockchain fundamentalsBlockchain fundamentals
Blockchain fundamentalsAhmed Mekawy
 
Blockchain, Finance & Regulatory Development
Blockchain, Finance & Regulatory DevelopmentBlockchain, Finance & Regulatory Development
Blockchain, Finance & Regulatory DevelopmentAlex Makosz
 
blockchain class 3.pdf
blockchain class 3.pdfblockchain class 3.pdf
blockchain class 3.pdfGopalSB
 
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 ApplicationsIngo 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 SarangNinad 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 workshopPad Kankipati
 
Blockchain Technology And Cryptocurrency
Blockchain Technology And CryptocurrencyBlockchain Technology And Cryptocurrency
Blockchain Technology And CryptocurrencyEno 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 CaprazSeval Ç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.pptxAschalewAyele2
 
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.pptxAschalewAyele2
 

Similar a 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
 

Más de Tharindu Weerasinghe

Basics of Computer Networks in Sinhala
Basics of Computer Networks in SinhalaBasics of Computer Networks in Sinhala
Basics of Computer Networks in SinhalaTharindu Weerasinghe
 
Data Structures & Algorithms in Sinhala
Data Structures & Algorithms in SinhalaData Structures & Algorithms in Sinhala
Data Structures & Algorithms in SinhalaTharindu 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 ResearchTharindu 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 TopicsTharindu 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 TechnologiesTharindu Weerasinghe
 
Introduction to Enterprise Applications and Tools
Introduction to Enterprise Applications and ToolsIntroduction to Enterprise Applications and Tools
Introduction to Enterprise Applications and ToolsTharindu Weerasinghe
 
Introduction to Agile Software Development & Python
Introduction to Agile Software Development & PythonIntroduction to Agile Software Development & Python
Introduction to Agile Software Development & PythonTharindu Weerasinghe
 
Agile Languages for Rapid Prototyping
Agile Languages for Rapid PrototypingAgile Languages for Rapid Prototyping
Agile Languages for Rapid PrototypingTharindu 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] softwareTharindu 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
 
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 ProfessionalsTharindu 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
 

Más de 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
 

Último

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 

Último (20)

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 

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