$30 off During Our Annual Pro Sale. View Details »

Blockchain - Hyperledger Fabric

Blockchain - Hyperledger Fabric

Understanding Blockchain Concepts
Asset Tokenizations
Non-Fungible Tokens (NFTs)
Central Bank Digital Currency
Stablecoin
Hyperledger Fabric
Write Smart Contracts
Case Studies

Araf Karsh Hamid

June 05, 2022
Tweet

More Decks by Araf Karsh Hamid

Other Decks in Technology

Transcript

  1. @arafkarsh arafkarsh
    8 Years
    Network &
    Security
    6+ Years
    Microservices
    Blockchain
    8 Years
    Cloud
    Computing
    8 Years
    Distributed
    Computing
    Architecting
    & Building Apps
    a tech presentorial
    Combination of
    presentation & tutorial
    ARAF KARSH HAMID
    Co-Founder / CTO
    MetaMagic Global Inc., NJ, USA
    @arafkarsh
    arafkarsh
    1
    Blockchain Technology
    1. CONCEPTS / FEATURES / USE CASES
    2. ASSETS / TOKENS / NFTS / CBDC
    3. CONSENSUS ALGORITHMS
    4. HYPERLEDGER FABRIC
    Part 1 of 2

    View Slide

  2. @arafkarsh arafkarsh
    Slides are color coded based on the topic colors.
    Blockchain
    Concepts
    Use Cases
    1
    Assets / Tokens
    NFT / Stablecoin
    CBDC
    2
    Consensus Algos
    BFT / PBFT
    PoW / PoS / PoA
    3
    Hyperledger Fabric
    Components
    Demo
    4
    2

    View Slide

  3. @arafkarsh arafkarsh
    Challenges with Centralized Systems
    3
    1. Centralized Power
    2. Lack of Trust & Integrity
    3. Lack of Traceability
    4. Lack of Visibility
    5. Data Integrity
    6. High Operating Cost
    7. Middlemen

    View Slide

  4. @arafkarsh arafkarsh
    Distributed Database Vs. Distributed Ledger
    4
    Source: https://gendal.me/2016/11/08/on-distributed-databases-and-distributed-ledgers/
    Distributed Database Distributed Ledger

    View Slide

  5. @arafkarsh arafkarsh
    Problem Statement
    5
    Customer A
    Records
    Insurer
    Records
    Bank
    Records
    Regulators
    Records
    Auditors
    Records
    Merchant A
    Records
    Expensive, Vulnerable & Inefficient
    Source: Building Blockchain Apps for Node.JS developers
    with HyperLedger Composer – Simon Stone IBM

    View Slide

  6. @arafkarsh arafkarsh
    How Blockchain Solves this Problem…
    6
    Customer A
    Records
    Insurer
    Records
    Bank
    Records
    Regulators
    Records
    Auditors
    Records
    Merchant A
    Records
    Blockchain Ledger
    A shared, replicated, permissioned ledger
    ü Consensus
    ü Immutability
    ü Provenance
    ü Finality
    Source: Building Blockchain Apps for
    Node.JS developers with HyperLedger
    Composer – Simon Stone IBM

    View Slide

  7. @arafkarsh arafkarsh
    Blockchain Properties
    7
    Distributed Ledger
    No central authority
    controlling the system
    like Bank, Govt, Corporate
    Trust & Transparent
    Transactions are final and
    trusted via
    Consensus protocol
    Permanent Immutable
    Safe & Guaranteed storage
    and transfer of
    Digital Value
    Smart Contracts
    Executable Business Contracts
    IFTTT –Smart Contracts
    Guaranteed Execution
    IFTTT – If This Then That

    View Slide

  8. @arafkarsh arafkarsh
    Business Requirements
    8
    Shared Ledger
    Append only
    immutable
    database shared
    across the
    business network.
    Business logic is
    embedded within
    the database and
    executed to
    validate and store
    the transactions.
    Smart Contract
    Transactions are
    secure,
    authenticated and
    access controls are
    enabled for
    granular access.
    Privacy Trust
    All the
    transactions are
    verified and
    endorsed by the
    trusted relevant
    parties

    View Slide

  9. @arafkarsh arafkarsh
    Properties of a Distributed Ledger
    9
    o Decentralized, replicated across many
    participants, each of whom collaborate in its
    maintenance.
    o Information recorded is append-only.
    Immutable.
    o Immutability makes it simple to determine
    the provenance of the information.
    o These properties makes it called as
    “Systems of Proof”
    1 - - - - - - - - - - - n

    View Slide

  10. @arafkarsh arafkarsh
    What is a Blockchain?
    10
    1. Shared Ledger
    2. Immutable Transactions in Append Only mode
    inside a Block
    3. Maintained by a Peer to Peer Distributed System
    4. Secured by Cryptographic Hashing
    5. Supported by Smart Contracts to Support
    Transaction Processing Across Organization.

    View Slide

  11. @arafkarsh arafkarsh
    How Blockchain Works?
    11
    Client
    sends
    request
    Transaction is
    Broadcasted to
    Blockchain Cluster
    Transactions will be
    validated by any node in
    the network using
    Consensus Algorithms &
    Smart Contract
    Multiples Nodes in the
    Cluster will verify the
    transaction and after
    the verification the new
    block is added to the
    chain and replicated
    across all the nodes.
    Client
    request
    completed

    View Slide

  12. @arafkarsh arafkarsh
    Public / Private Blockchains
    12
    # Features Public Blockchain - Ethereum Private Blockchain – Hyperledger Fabric
    1 Blockchain Generic Blockchain Platform Modular Blockchain Platform
    2 Network Public & Permissioned Private & Permissioned
    3 Consensus
    Mining based on Proof of Work (POW)
    – All participants need to agree.
    Ledger Level
    Selective Endorsement.
    Consensus can be even within a channel with
    select parties instead of everyone.
    Transaction Level
    4 Currency
    Ether / Tokens (Usage, Work)
    via Smart Contract
    None
    Currency and Tokens via Chaincode
    5 Smart Contract Solidity Go Lang, Java, Node JS
    6
    When to
    Choose
    If the transactions are public in nature
    If the transactions needs privacy,
    confidentiality and identity
    7 Governance
    Ethereum is developed by developers
    across the world
    Enterprise Ethereum Alliance
    IBM handed over the development and
    management of Hyperledger to
    Linux Foundation
    8 State Account Data
    Key-value Database
    Transaction Log, World State

    View Slide

  13. @arafkarsh arafkarsh
    How it differs from Bitcoin
    13
    HyperLedger Fabric Bitcoin
    Provides Identity Anonymity
    Selective Endorsement Proof of Work
    Assets Cryptocurrency
    Bitcoin is a specific implementation of Blockchain technology

    View Slide

  14. @arafkarsh arafkarsh
    Zero Knowledge Proof
    14
    zero-knowledge protocol is a method by which one party (the prover) can prove to another party (the verifier)
    that a given statement is true while the prover avoids conveying any additional information apart from the fact
    that the statement is indeed true.
    Source: https://www.geeksforgeeks.org/zero-knowledge-proof/
    Karishma randomly
    takes a path while
    Vivek waits outside
    Vivek Chooses
    an Exit Path
    Karishma reliably
    appears at the
    Exit Vivek
    decides

    View Slide

  15. @arafkarsh arafkarsh
    Types of Blockchain
    Public blockchain networks
    A public blockchain is one that anyone can join and participate in, such as Bitcoin
    Private blockchain networks
    A private blockchain network, similar to a public blockchain network, is a decentralized peer-to-peer
    network. However, one organization governs the network, controlling who is allowed to participate,
    execute a consensus protocol and maintain the shared ledger.
    Permissioned blockchain networks
    Businesses who set up a private blockchain will generally set up a permissioned blockchain network.
    It is important to note that public blockchain networks can also be permissioned.
    Consortium blockchains
    Multiple organizations can share the responsibilities of maintaining a blockchain. These pre-selected
    organizations determine who may submit transactions or access the data.
    Source: https://www.ibm.com/topics/what-is-blockchain
    15

    View Slide

  16. @arafkarsh arafkarsh
    Summary – Why do we need Blockchain?
    14/04/23 16
    Reconciliation Issues
    in a Multi Party
    environment.
    o Expensive
    o Vulnerable
    o Inefficient
    Problem Statement
    o Consensus among the Parties
    before a transaction is committed.
    o Provenance – Origin of the asset
    can be easily Tracked.
    o Immutable – Transactions are
    tamper proof
    o Finality – Single Source of Truth
    Solution

    View Slide

  17. @arafkarsh arafkarsh
    Summary – Benefits of Blockchain Technologies
    Saves Time
    Immutable
    transaction across
    parties done at the
    same time.
    Remove Cost
    Overheads on
    maintaining and
    synchronizing silos.
    Increases Trust
    Through shared process
    and unified Systems of
    Record. For end
    consumers it’s a System
    of Proof.
    Reduces Risk
    Tampering of data,
    fraud and cyber crime
    is avoided.
    17

    View Slide

  18. @arafkarsh arafkarsh
    Use Cases of Blockchain
    o Supply chain, Health Care
    o Finance, Insurance, Govt
    o Payment, Agriculture,
    o Internet of things, Media
    18

    View Slide

  19. @arafkarsh arafkarsh
    Blockchain Use Cases
    19
    1. High Value goods tracking
    2. Logistics and Supply
    3. Asset Management & Tracking
    4. Chain of Custody Tracking
    5. Anti Counterfeiting
    Supply Chain
    1. Patient Data Management
    2. Clinical Trials
    3. Medical Devices Management
    4. Pharmaceutical Tracking
    5. Patient Data Exchange
    Health Care
    1. Equity Trading
    2. Know your Customer
    3. Peer to Peer Lending
    4. Derivatives Trading
    5. Escrow
    Finance
    1. Voting
    2. Vehicle Registration
    3. Land Registration
    4. Copyrights
    5. Immigration Management
    Government
    1. Peer To Peer Insurance
    2. Automated Insurance Claim
    3. Car Insurance
    4. Health Insurance
    5. Fraud Detection
    Insurance
    1. Remittance
    2. Micro Finance
    3. Identify Verification
    4. Cross Border Payments
    5. Hedge Funds
    Payments

    View Slide

  20. @arafkarsh arafkarsh
    Blockchain Use Cases
    20
    1. Farmers Loan Process
    2. Smart Farming
    3. Fair Pricing
    4. Reduce Food Waste
    5. Animal Health & Food Safety
    Agriculture
    1. Autonomous Vehicle
    2. Health & Fitness
    3. Device to Device Payment
    4. Shipping & Logistics
    5. Asset Management
    IoT
    1. Royalty Payments
    2. Content Bypassing Aggregator
    3. Pricing for Paid Content
    4. Ad Networks & Exchanges
    5. Media Buying
    Media
    1. Real Estate
    2. Tourism
    3. Energy Trading
    4. Gaming
    5. Identity
    General

    View Slide

  21. @arafkarsh arafkarsh
    Content Bypassing the AggregatorsSource: Deloitte : Blockchain @ Media
    Content Producer
    / Artist Aggregator Consumer
    Current Scenario
    Content Producer
    / Artist
    Distributed
    Ledger Consumer
    After Introduction of Blockchain
    Benefits
    • Direct Customer Artist
    relationship.
    • Easy to measure marketing and
    performance.
    Challenges
    • Content Aggregators and
    Advertising networks to loose
    their dominant position.
    • Blockchain has the potential to
    make DRM systems obsolete or
    at least to reduce it’s complexity
    21

    View Slide

  22. @arafkarsh arafkarsh
    Distribution of Royalty Payments
    Artist Aggregator User
    Current Scenario
    Music
    Publisher Distributor
    Artist User
    After Introduction of Blockchain
    Distributed Ledger Distributor
    Source: Deloitte : Blockchain @ Media
    Benefits
    • Near Real-time distribution of
    Royalty payments based on
    Smart Contracts
    • Every usage and consumption is
    tracked in Blockchain
    Challenges
    • Handling large amount of Data
    • All the parties agreeing to
    common Blockchain Platform.
    22

    View Slide

  23. @arafkarsh arafkarsh
    Land Records Specs
    For any kind of a high value property (real estate, cars, art) it is important to have
    accurate records which identify the current owner and provide a proof that he is
    indeed the owner. These records can be used to
    • Protect owners' rights (e.g. in case of theft)
    • Resolve disputes
    • Make sure ownership is correctly transferred to a new owner after
    sale
    • Prevent sale fraud
    Source: https://chromaway.com/papers/A-blockchain-based-property-registry.pdf
    23

    View Slide

  24. @arafkarsh arafkarsh
    Land Registration
    District 1
    District n
    Bank
    Buyer
    Seller
    Property Tax
    Dept
    • Buyers and Seller are
    Cryptographically
    identified.
    • Ledger is distributed
    across all the districts
    in the state to ensure
    that forging the record
    is extremely difficult.
    Blockchain Ledger
    A shared, replicated,
    permissioned ledger
    24

    View Slide

  25. @arafkarsh arafkarsh
    Disrupting the Media Value Chain
    Introduction of
    Blockchain will
    result in
    deprecation of
    critical
    roles/operations
    played by some
    of the Business
    Entities.
    25

    View Slide

  26. @arafkarsh arafkarsh
    2
    Assets / Tokens
    o Assets – Fungible / Non Fungible
    o Tokens / NFTs
    o Stablecoin
    o Central Bank Digital Currency
    26

    View Slide

  27. @arafkarsh arafkarsh
    Blockchain Adoption & Growth
    Source: https://appinventiv.com/blog/top-blockchain-technology-trends/
    Blockchain as a
    Service become
    mainstream with
    BaaS provided by
    IBM, Oracle,
    Microsoft, Amazon
    and lot of start-ups.
    27

    View Slide

  28. @arafkarsh arafkarsh
    Assets
    Tangible Assets
    Anything in physical form that has a monetary value.
    Fungible Assets
    These are Assets that can be interchangeable with
    same kind. For Ex Currency, Gold, Financial Instruments
    like Commodities, Shares etc.
    Non Fungible Assets
    They are unique Assets that cant be interchanged.
    For Ex. Real Estate property, Painting, Diamond etc.
    28

    View Slide

  29. @arafkarsh arafkarsh
    Asset Tokenization
    Tradable Assets
    (Physical or
    Digital)
    represented as
    a Token in a
    Blockchain
    Platform
    Source: Top Tokenization Platforms in 2022
    29

    View Slide

  30. @arafkarsh arafkarsh
    What’s a Crypto Token?
    Real World Examples of Token
    o Representing Ownership of an
    Asset
    o Used as a Crypto Currency
    o Used by a Person or a Group
    o Use Smart Contract to Create
    Tokens
    30

    View Slide

  31. @arafkarsh arafkarsh
    Asset Tokenization Example
    Source: https://www.visualcapitalist.com/blockchain-applications-tokenization-of-real-assets/
    Liquidity
    Simplifying the buying
    and selling process by
    connecting the buyers
    and sellers.
    Entry Barrier Removed
    Easy to invest in
    Expensive Real Estate.
    Transparency & Security
    Blockchains are
    decentralized,
    immutable and secured
    31

    View Slide

  32. @arafkarsh arafkarsh
    Types of Tokens
    Currency Tokens / Crypto Currencies
    Behave like physical currencies like US Dollar, British Pound, Euros,
    Indian Rupee. Popular Currency token is Bitcoin.
    Asset Backed Tokens
    They are based on real world Assets like Real Estates, Gold, Diamonds
    etc. Stablecoin is an Asset backed Token.
    Reward Tokens
    Reward users based on their behaviour.
    Governance Tokens
    Allows users to vote on various subjects.
    32

    View Slide

  33. @arafkarsh arafkarsh
    Types of Tokens
    Utility Token
    Issued for a specific purpose and served as a payment option and also
    used as a Crowd Funding mechanism to buy coins during ICO (Initial
    Coin Offering).
    Security Tokens
    Used to invest in a Company and as these tokens as part of “Securities”
    trading these tokens will regulated by the Government. Values of these
    tokens will fluctuate similar to the Stocks.
    Equity Tokens
    These tokens represents a share of an Asset.
    33

    View Slide

  34. @arafkarsh arafkarsh
    Non-Fungible Tokens (NFTs)
    Non-Fungible Tokens
    NFT’s are the digital version
    of the Non-Fungible Assets.
    NFTs are unique cant be
    interchanged.
    It started with Digital Art,
    Music etc.
    Non-Fungible Assets
    They are unique
    Assets that cant be
    interchanged.
    For Ex. Real Estate
    property, Painting,
    Diamond etc.
    Americana’s chip turns Physical objects into NFTs
    Source:
    https://techcrunch.com/2022/05/03/americana-chip-
    turns-objects-nfts-funding-ohanian/
    34

    View Slide

  35. @arafkarsh arafkarsh
    Tokenization Advantages
    Source: https://appinventiv.com/blog/blockchain-assets-tokenization/
    Liquidity
    Simplifying the buying and
    selling process by connecting
    the buyers and sellers.
    Entry Barrier Removed
    Easy to invest in Expensive
    Real Estate.
    Transparency & Security
    Blockchains are
    decentralized, immutable
    and secured
    35

    View Slide

  36. @arafkarsh arafkarsh
    Industries for Tokenization
    Source: https://appinventiv.com/blog/blockchain-assets-tokenization/
    Artwork
    Finance
    Healthcare
    Real Estate
    Sports
    Enterprise
    36

    View Slide

  37. @arafkarsh arafkarsh
    Fiat Currency
    37
    Source: Fiat Currency https://101blockchains.com/what-is-fiat/
    o Fiat Currency is not backed by any physical asset like Gold, Silver, or
    any other precious metals.
    o Popular Fiat Currency includes US Dollar, Euro, Pound, Yen, and Indian
    Rupee.
    o Almost all the currency issued by the Govt fall under the Fiat Currency.
    o As it is not backed by any physical good or commodity, the Govt can
    print any number of currencies.
    o Fiat currency got introduced after the collapse of the Bretton Woods
    Agreement in the 1970s.
    o Bretton Wood Agreement is all about US Dollar backed by Gold (the
    US had the largest Gold reserve after World War 2) agreed after
    delegates from 44 countries met in Bretton Wood in New Hampshire
    in the USA.

    View Slide

  38. @arafkarsh arafkarsh
    Stablecoin
    Source: https://101blockchains.com/stablecoins/
    A Crypto Currency
    that holds a stable
    price is a Stablecoin.
    It’s critical for Crypto
    Investors and
    Exchanges.
    38

    View Slide

  39. @arafkarsh arafkarsh
    Central Bank Digital Currency
    o Wholesale CBDC
    o Retail CBDC
    39

    View Slide

  40. @arafkarsh arafkarsh
    Central Bank Digital Currency
    CBDC is the digital
    version of the Central
    Banks for Govts
    across the world.
    Instead of Printing
    Money, CBDC will
    issue Digital Tokens
    that represent Fiat
    Currency.
    Source: https://101blockchains.com/central-bank-digital-currency-on-corda/
    Types of
    CBDC
    Wholesale
    CBDC
    Retail
    CBDC
    40

    View Slide

  41. @arafkarsh arafkarsh
    Types of CBDC
    Wholesale CBDC
    Purpose is establishing
    digital payment system
    across Banks. This
    exchange happens based
    on Tokens without
    intermediaries.
    The transfer between
    Banks are atomic in
    nature.
    Retail CBDC
    These are General Purpose
    CBDC issued to the public as an
    alternative for Physical Currency.
    1. To promote Financial
    Inclusion
    2. Facilitating Monetary Policy
    3. Cash alternative
    4. Modernize Payments
    41

    View Slide

  42. @arafkarsh arafkarsh
    Source: https://101blockchains.com/central-bank-digital-currency-on-corda/
    42

    View Slide

  43. @arafkarsh arafkarsh
    Source: https://101blockchains.com/central-bank-digital-currency-on-corda/
    43

    View Slide

  44. @arafkarsh arafkarsh
    IMF – Policy Goals of CBDC Projects
    44
    Source: https://www.imf.org/-/media/Files/Publications/FTN063/2022/English/FTNEA2022004.ashx
    Behind the Scenes of Central Bank Digital Currency
    1. Financial Inclusion
    2. Access to Payments
    3. Making Payments more efficient
    4. Ensuring Resilience of Payments
    5. Reducing Illicit use of Money
    6. Monetary Sovereignty

    View Slide

  45. @arafkarsh arafkarsh
    India CBDC
    o Indian Digital Rupee & CBDC
    o RBI PPI
    o UPI
    45

    View Slide

  46. @arafkarsh arafkarsh
    Indian Digital Rupee & CBDC
    46
    1. Wholesale CBDC
    2. Retail CBDC
    18 Countries linked via UPI for Cross Border Payments
    RBI – PPI
    Prepaid Payment Instrument
    • Customer Wallet
    • Direct Transactions
    Types of PPI
    • Small PPI
    • Gift Card
    • Metro Transit Systems
    • Full KYC
    9 Banks linked to the
    Wholesale CBDC
    1. State Bank of India
    2. Bank of Baroda
    3. Union Bank of India
    4. HDFC Bank
    5. ICICI Bank
    6. Kotak Mahindra Bank
    7. Yes Bank
    8. IDFC First Bank
    9. HSBC
    RBI CBDC Concept Note

    View Slide

  47. @arafkarsh arafkarsh 47
    Prepaid
    Payment
    Instrument
    Reserve Bank of India

    View Slide

  48. @arafkarsh arafkarsh
    Project IceBreaker
    o Retail CBDC
    o Israel, Norway, Sweden
    48

    View Slide

  49. @arafkarsh arafkarsh
    Project IceBreaker: Retail CBDC
    49
    Source: https://www.youtube.com/watch?v=g4UaeWO_V6A

    View Slide

  50. @arafkarsh arafkarsh
    IceBreaker – Retail CBDC Architecture
    50
    Source: https://www.youtube.com/watch?v=g4UaeWO_V6A
    All the 3 CBDC
    can be on
    different
    technologies.

    View Slide

  51. @arafkarsh arafkarsh
    IceBreaker: Cross Border Tx
    51
    Source: https://www.youtube.com/watch?v=g4UaeWO_V6A

    View Slide

  52. @arafkarsh arafkarsh
    mBridge
    Multiple CBDC Bridge
    o 4 Central Banks (China, Hong Kong, Thailand & UAE)
    o 25 Banks
    52

    View Slide

  53. @arafkarsh arafkarsh
    mBridge: 4 Central Bank Digital Currency
    53
    Total Transactions among the 4 CBDC
    based on World Bank 2019 Data
    $730+Billion Dollars
    Source: https://www.youtube.com/watch?v=58_lJ-9oblc&t=1s

    View Slide

  54. @arafkarsh arafkarsh
    mBridge: 25 Banks / 4 CBDCs
    54
    Source: https://www.youtube.com/watch?v=58_lJ-9oblc&t=1s
    UAE CHINA Hong Kong THAILAND

    View Slide

  55. @arafkarsh arafkarsh
    mBridge: Pilot Project – 13 Use Cases
    55
    International Trade
    1. International Trade Settlement
    2. Programmable Trade Finance
    3. Supply Chain Financing
    4. Interoperability with Digital
    Finance Trade Platforms
    Capital Market Transactions
    1. Atomic Settlement of tokenized
    Corporate Bonds
    2. Securitized FX Spot, Futures and
    Derivatives
    3. Wealth Management Connect
    4. Digital Native Corporate Bond
    Issuance
    5. Dual Currency FX Derivative
    Other Use Cases
    1. Insurance Payments
    2. Commercial Payments
    3. Cross Border Low-Value
    Payments Aggregation Service
    4. Cross Border e-Commerce
    Billion Dollars
    $730+
    Pilot Program
    successfully
    conducted between
    Aug 15 – Sept 23,
    2022
    FX – Foreign Exchange
    Source: https://www.youtube.com/watch?v=58_lJ-9oblc&t=1s

    View Slide

  56. @arafkarsh arafkarsh
    mBridge: Transaction Types
    56
    Source: https://www.youtube.com/watch?v=58_lJ-9oblc&t=1s

    View Slide

  57. @arafkarsh arafkarsh
    mBridge: Pilot: Aug 15 – Sept 23, 2022
    57
    Source: https://www.youtube.com/watch?v=58_lJ-9oblc&t=1s

    View Slide

  58. @arafkarsh arafkarsh
    mBridge: Milestones
    58
    Source: https://www.youtube.com/watch?v=58_lJ-9oblc&t=1s

    View Slide

  59. @arafkarsh arafkarsh
    Other CBDC Projects around the World
    59
    1. Project Ubin: An initiative by the Monetary Authority of Singapore (MAS), Project
    Ubin explores the use of blockchain technology for the clearing and settlement of
    payments and securities. It focuses on the development of a tokenized version of the
    Singapore Dollar (SGD) to enable more efficient cross-border transactions.
    2. Project Stella: A joint research project by the European Central Bank (ECB) and the
    Bank of Japan (BOJ), Project Stella explores the potential of DLT for financial market
    infrastructures. The project has conducted several phases of research, including the
    evaluation of DLT for the settlement of securities and cross-border payments.
    3. Project Jasper: A collaborative research initiative by the Bank of Canada, Payments
    Canada, and several Canadian banks, Project Jasper aims to investigate the potential
    of DLT for the clearing and settlement of high-value interbank payments.
    4. Project Khokha: Led by the South African Reserve Bank (SARB), Project Khokha
    explores the use of DLT for the wholesale interbank payment system in South Africa. It
    aims to enhance the resilience and efficiency of the payment system while
    maintaining the necessary privacy and security requirements.

    View Slide

  60. @arafkarsh arafkarsh
    3
    Consensus Algorithms
    o Byzantine Fault Tolerance
    o Practical Byzantine Fault Tolerance
    o PoW, PoS, DPoS, PoET, PoA
    60

    View Slide

  61. @arafkarsh arafkarsh
    Consensus & its Applications
    61
    1 PoW Proof of work Bitcoin, LiteCoin, Ethereum,
    Bitcoin Cash, Zcash
    2 PoS Proof of Stake Peercoin, Ethereum 2.0, Quora, Nxt,
    Shadow Cash
    3 DPoS Delegated PoS BitShares, Steem, EOSIO, Steemit
    4 PoET Proof of Elapsed
    Time
    Hyperledger Sawtooth
    5 PBFT Practical BFT Hyperledger Fabric, Ziliqa
    6 PoA Proof of Authority Aura, Clique

    View Slide

  62. @arafkarsh arafkarsh
    Byzantine Fault Tolerance
    62
    Lieutenant 1
    Commander
    Lieutenant 2
    Source: Byzantine Generals Problem: Leslie Lamport, Robert Shostak & Marshall Pease 1982
    “attack”
    “attack”
    He said
    “retreat”
    Lieutenant 2 is a traitor
    Lieutenant 1
    Commander
    Lieutenant 2
    “retreat”
    “attack”
    He said
    “retreat”
    Commander is a traitor
    Byzantine Generals Problem
    • By Lamport, Shostak, & Pease in 1982
    • Commander defines the correct action
    • Lieutenant Follows & Relays information

    View Slide

  63. @arafkarsh arafkarsh
    Practical Byzantine Fault Tolerance
    63
    Lieutenant 1
    Commander
    Lieutenant 2
    “attack”
    “attack”
    He said
    “retreat”
    Lieutenant 2 is a traitor
    Lieutenant 1
    Commander
    Lieutenant 2
    “retreat”
    “attack”
    He said
    “retreat”
    Commander is a traitor
    • By Miguel Castro & Barbara Liskov in 1999
    • Fast
    • Handles f Byzantine faults in a system with 3f + 1
    Node

    View Slide

  64. @arafkarsh arafkarsh
    Practical Byzantine Fault Tolerance
    Client
    Node 1
    Node 2
    Node 3
    Node 4
    Request Pre-Prepare Prepare Commit Reply
    X
    • By Miguel Castro &
    Barbara Liskov in
    1999
    • Fast
    • Handles f Byzantine
    faults in a system
    with 3f + 1 Node
    64

    View Slide

  65. @arafkarsh arafkarsh
    Byzantine Fault Tolerance
    65
    Byzantine Generals Blockchain
    1 Geographic Distance Distributed Network
    2 Generals Nodes
    3 Traitor Generals Faulty or Malicious Nodes
    4 Unreliable Messengers
    Unreliable network
    Messages between nodes
    are dropped or corrupted.
    5 Attack or Retreat Consensus on Transactions

    View Slide

  66. @arafkarsh arafkarsh
    Proof of Work
    66
    • Blockchain validators must take data from a block header as an
    input &
    • Continuously run it through a cryptographic hash function.
    • Validators hash slight variations of the input data by including
    an arbitrary number called a nonce every time the input data
    is run through the cryptographic hash function.
    • PoW needs high levels of electricity of processing power to
    decide what data gets added to the next block in a blockchain.
    Source: https://analyticsindiamag.com/blockchain-consensus-algorithms/

    View Slide

  67. @arafkarsh arafkarsh
    Proof of Stake
    67
    The PoS consensus algorithm was created in 2011 as an alternative to
    PoW.
    • Validators stake resources primarily in the form of digital money or
    tokens.
    • The validator of every block is then randomly selected from the
    stakeholders based on the amount of computational power
    allocated.
    Source: https://analyticsindiamag.com/blockchain-consensus-algorithms/

    View Slide

  68. @arafkarsh arafkarsh
    Delegated Proof of Stake
    Conceptualized by Daniel Larimer, delegated Proof-of-Stake (DPoS), which is based
    on voting systems where “delegates” vote for their favorite validators to help in the
    consensus state of new blocks.
    • Delegates votes for Favorite Validators
    • These validators will also be responsible for validating transactions, maintaining
    the blockchain network, and will get rewarded in return in doing so with
    transaction fees.
    • Each voter’s power is proportional to the size of the stake in the network.
    • A Democratic version of the Proof of Stake Algorithm
    Source: https://analyticsindiamag.com/blockchain-consensus-algorithms/
    68

    View Slide

  69. @arafkarsh arafkarsh
    Proof of Elapsed Time
    PoET consensus system was developed by Intel to solve the computing challenge of
    “random leader election.” It was released as part of the Software Guard Extensions
    (SGX) programming reference manual. PoET is now utilized by many private
    blockchains, including Hyperledger Sawtooth.
    • It relies on randomized timer system for network participants rather than using
    mining hardware as in the case of Proof of Work (PoW).
    • Each participating blockchain node in the network is needed to wait for a
    randomly chosen period, and
    • whoever with finished time wins the new block and validates it.
    Source: https://analyticsindiamag.com/blockchain-consensus-algorithms/
    69

    View Slide

  70. @arafkarsh arafkarsh
    Proof of Authority
    PoA is based on the reputation of trusted parties in a blockchain network. An efficient mechanism for private
    blockchains and created by Ethereum co-founder and former CTO Gavin Wood in 2017.
    • PoA consensus algorithm is based on the value of identities within a network-
    and in a system block,
    • validators do not stake resources but their own identities and reputation.
    • So, PoA blockchain networks are secured by the validating nodes that are
    arbitrarily chosen as trustworthy parties.
    • The Proof of Authority model works on a fixed number of block validators,
    making it an easily scalable blockchain system because transactions are checked
    by already-approved network participants.
    • PoA consensus algorithm can be utilized in applications such as supply chains or
    trade networks because the real identities of nodes are known and trusted.
    Source: https://analyticsindiamag.com/blockchain-consensus-algorithms/
    70

    View Slide

  71. @arafkarsh arafkarsh
    4
    Hyperledger Fabric
    o Features
    o Architecture
    o Components
    71

    View Slide

  72. @arafkarsh arafkarsh
    HyperLedger Fabric Key Features
    72
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/
    o It is private and permission based
    o Members of HyperLedger Fabric enrolls
    thru MSP - Membership Service
    Provider
    o Different MSPs are supported
    o Ledger data can be stored in multiple
    formats.
    o Consensus mechanisms can be
    switched in and out
    o Ability to create channels - Allowing a
    group of participants to create a
    separate ledger of transactions.
    o Provides Membership Identity
    Service that manages User IDs
    and authenticates all
    participants on the network.
    o Access control lists can be used
    to Provide additional layers of
    permission.
    o A Specific user ID could be
    permitted to invoke a Chaincode
    application but blocked from
    deploying a Chaincode.
    Identity Management

    View Slide

  73. @arafkarsh arafkarsh
    HyperLedger Fabric Key Features
    73
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/
    o Transaction execution is
    separated from
    transaction ordering and
    commitment.
    o Division of labor un
    burdens ordering nodes
    from the demands of
    transaction execution and
    ledger maintenance,
    o while peer nodes are
    freed from ordering
    (consensus) workloads.
    Efficient Processing
    o Chaincode
    Applications encode
    logic that is invoked by
    specific types of
    transactions on the
    channel.
    o System Chaincode is
    distinguish as
    Chaincode that defines
    operating params for
    the entire channel.
    Chaincode Functionality
    o Private channels are
    restricted messaging paths
    that can be used to provide
    transaction privacy and
    confidentiality for specific
    subset of network members.
    o All data including
    transaction, member and
    channel information, on a
    channel are invisible and
    inaccessible to any network
    members not explicitly
    access to that channel.
    Privacy & Confidentiality

    View Slide

  74. @arafkarsh arafkarsh
    Hyperledger Architecture
    o Certificate Authority / Membership Service Provider
    o Peer
    o Orderer
    74

    View Slide

  75. @arafkarsh arafkarsh
    Hyperledger Fabric Architecture
    75
    Orderer
    • Consensus
    verification
    • Creates Blocks
    CA
    • Registration
    of identities
    • Manage
    Certificates
    Peer
    • Endorses Tx
    • Simulates Tx
    • Commits Tx
    All these components can be clustered for scalability and to avoid Single Point of Failure
    3 Components of Fabric
    Ledger
    Blockchain & World State
    Smart Contract
    • createCar
    • queryAllCars
    • queryCarProperties
    • changeCarColor
    • changeCarOwner
    Other Concepts
    • Endorsement Policies
    • Tokens
    • Assets : Anything that’s valuable for
    the Organization
    • Transactions (State changes of
    Assets)
    • Gossip Protocol : The glue that
    keeps the peers in healthy state.
    Channels
    • Private subnet for
    a set of parties
    based on Smart
    contract
    • Ledger / Channel
    • Peers can have
    multiple Channels
    • Private Data
    1
    2

    View Slide

  76. @arafkarsh arafkarsh
    76
    Fabric
    Deployment
    Model in every
    Enterprise Customer A Merchant B Bank Insurer
    RESTful Services
    Two Roles = Endorser & Committer
    Smart Contracts (Chaincode) – Programmable Ledger
    Persistence Layer - Ledger
    Get
    Put
    Blockchain
    Events
    Block
    Peer
    Gossip Protocol for P2P Communication
    Orderer
    • Consensus
    Verification
    • Creates Blocks
    CA
    • Registration
    of identities.
    • Certificate
    Management
    Blockchain & World State
    Multiple Channels
    Blockchain & World State
    76

    View Slide

  77. @arafkarsh arafkarsh
    77
    Monolithic vs. Microservices Example
    Traditional Monolithic App using
    Single Technology Stack
    Micro Services with Multiple Technology Stack
    This 3-tier model is obsolete now.
    Source: Gartner Market Guide for Application
    Platforms. Nov 23, 2016
    Event Stream / Queues / Pub-Sub / Storage
    UI Layer
    Web Services
    Business Logic
    Database Layer
    Micro
    Service
    4
    EE 7
    Inventory
    UI Layer
    Web Services
    Business Logic
    Database Layer
    Micro
    Service
    1
    Customer
    SE 8
    UI Layer
    Web Services
    Business Logic
    Database Layer
    Micro
    Service
    3
    Shopping Cart
    UI Layer
    Web Services
    Business Logic
    Database Layer
    Micro
    Service
    2
    Order
    UI Layer
    WS
    BL
    DL
    Database
    Shopping Cart
    Order
    Customer
    Inventory
    API Gateway (Zuul Edge Server)
    Load Balancer
    (Ribbon)
    Circuit Breaker
    (Hystrix)
    Service Discovery (Eureka)
    Load Balancer
    (Ribbon)
    Circuit Breaker
    (Hystrix)
    Load Balancer
    (Ribbon)
    Circuit Breaker
    (Hystrix)
    Load Balancer
    (Ribbon)
    Circuit Breaker
    (Hystrix)
    77

    View Slide

  78. @arafkarsh arafkarsh
    HyperLedger Fabric – Ledger
    78
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/fabric_model.html
    There is one ledger
    per channel.
    Couch DB
    As well as a state database to
    maintain current fabric state.
    This is auto derived by the Peers.
    Each transaction results in a set of asset key-
    value pairs that are committed to the ledger
    as creates, updates, or deletes.
    o The ledger is the
    sequenced, tamper-
    resistant record of all state
    transitions in the fabric.
    o State transitions are a result
    of Chaincode invocations
    (‘transactions’) submitted
    by participating parties.
    Blockchain
    Tx Tx Tx Tx
    Blocks
    Tx
    Ledger

    View Slide

  79. @arafkarsh arafkarsh
    HyperLedger Fabric : 3 Components
    79
    o Registration of identities, or
    connects to LDAP as the
    user registry
    o Issuance of Enrollment
    Certificates (ECerts)
    o Certificate renewal and
    revocation
    o Every Single operation
    MUST be signed with a
    Certificate.
    o Certificates are per user.
    Certificate Authority
    o Before anything is committed to
    the Ledger it must pass thru
    Orderer Service.
    o Provides Order of
    Transactions.
    o It creates the Blocks for the
    Blockchain.
    o Block size can be based on no.
    of transactions and / or timeout
    value.
    o Orderer in two modes - Solo for
    the Dev environment and Raft
    for the Production environment.
    Orderer
    o Can update or Query the
    ledger.
    o One Peer can be part of
    multiple channels.
    o Peer Endorse the
    transaction.
    o All the Peers find each other
    and synchronizes
    automatically.
    o Peer manages the Ledger
    which consists of the
    Transaction Log (Blockchain)
    and World State.
    o Peer has two roles
    Endorser and Committer.
    Peer
    Source: https://hyperledger-
    fabric.readthedocs.io/en/release-2.2/blockchain.html

    View Slide

  80. @arafkarsh arafkarsh
    Hyperledger Fabric – Certificate Authority (CA)
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/identity/identity.html
    80

    View Slide

  81. @arafkarsh arafkarsh
    HyperLedger Fabric – CA
    81
    http://www.haproxy.org/
    CA
    HA
    Proxy
    Peer Network
    Cluster
    REST API
    CA Cluster with HA Proxy Load balancer
    Fabric CA Server can
    be connected using
    1. Fabric CA Client
    2. Fabric CA SDK
    (REST API Calls)
    Fabric CA servers in a cluster share the same database for
    keeping track of identities and certificates. If LDAP is configured,
    the identity information is kept in LDAP rather than the database.
    This ensures that there is NO Single Point of Failure for CA.
    No Single Point of
    Failure for Peers.

    View Slide

  82. @arafkarsh arafkarsh
    Hyperledger Fabric MSP Membership Service Provider
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/membership/membership.html
    82

    View Slide

  83. @arafkarsh arafkarsh
    Hyperledger Fabric - Peers
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/peers/peers.html
    83

    View Slide

  84. @arafkarsh arafkarsh
    Hyperledger Peer - Ledgers
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/peers/peers.html
    84

    View Slide

  85. @arafkarsh arafkarsh
    Hyperledger Fabric Peer – Multiple Smart Contracts
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/peers/peers.html
    85

    View Slide

  86. @arafkarsh arafkarsh
    Hyperledger Fabric Peer – Channels
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/peers/peers.html
    86

    View Slide

  87. @arafkarsh arafkarsh
    Hyperledger Fabric Peer & Organizations
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/peers/peers.html
    87

    View Slide

  88. @arafkarsh arafkarsh
    Hyperledger Fabric Peer – Identity
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/peers/peers.html
    88

    View Slide

  89. @arafkarsh arafkarsh
    HyperLedger Fabric – Peer
    89
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/peers/peers.html
    Blockchain
    Tx Tx Tx Tx
    Block
    Peer
    Query ledger
    history for a key,
    enabling data
    provenance
    scenarios.
    Peer
    CouchDB
    Read-only queries
    using a rich query
    language (if using
    CouchDB as state
    database)
    Transactions contain
    signatures of every
    endorsing peer and
    are submitted to
    ordering service.
    Peer
    Tx
    Peer
    Peers validate transactions
    against endorsement policies and
    enforce the policies.
    Endorsement
    Policies
    Peer
    Peers can have multiple Channels
    Peer
    Prior to appending a block, a
    versioning check is performed to
    ensure that states for assets that
    were read have not changed
    since Chaincode execution time.
    Tx
    $ docker run -it hyperledger/fabric-peer bash
    # peer chaincode --help

    View Slide

  90. @arafkarsh arafkarsh
    Hyperledger Fabric Peer – App Communication
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/peers/peers.html
    90

    View Slide

  91. @arafkarsh arafkarsh
    HyperLedger Fabric - Orderer
    91
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/orderer/ordering_service.html
    Node 2
    Orderer
    Zookeeper
    Node 1
    Node 2
    Node 3
    Broker 1
    Broker 2
    Broker n
    Broker ..
    Kafka Zookeeper
    Node 1
    Orderer
    Node 3
    Orderer
    Node 4
    Orderer
    Ordering
    Service Client
    Defining Consensus is
    3 Phase Process
    1. Endorsement
    2. Ordering
    3. Validation
    ZooKeeper nodes 3,5,7
    Service Type
    1. Solo (Dev) - Deprecated
    2. Kafka (Prod) - Deprecated
    3. Raft - Recommended
    No Single Point of Failure for Orderer.
    Source: Raft protocol

    View Slide

  92. @arafkarsh arafkarsh
    HyperLedger Fabric Model – Assets / Chaincode
    92
    o The exchange of almost anything with monetary value over the network, from whole foods
    to antique cars to currency futures.
    o Represented as a collection of key-value pairs, with state changes recorded as transactions
    on a Channel ledger.
    o Assets can be represented in binary and/or JSON form.
    Assets
    o It defines an asset or assets, and the transaction instructions for modifying the asset(s). Its the
    business logic.
    o It enforces the rules for reading or altering key value pairs or other state database information.
    o It execute against the ledger’s current state database & are initiated through a transaction proposal.
    o It’s execution results in a set of key value writes (write set) that can be submitted to the network
    and applied to the ledger on all peers.
    Chaincode / Smart Contract

    View Slide

  93. @arafkarsh arafkarsh
    HyperLedger Fabric Channels
    93
    o A Hyperledger Fabric channel is a private “subnet” of communication between two or
    more specific network members, for the purpose of conducting private and confidential
    transactions.
    o Channel is a completely separate instance of HyperLedger Fabric. Every Channel is
    completely isolated and will never talk to each other.
    o To create a new channel, the client SDK calls configuration system Chaincode and
    references properties such as anchor peer**s, and members (organizations). This
    request creates a **genesis block for the channel ledger, which stores configuration
    information about the channel policies, members and anchor peers.
    o The consensus service orders transactions and delivers them, in a block, to each
    leading peer, which then distributes the block to its member peers, and across the
    channel, using the gossip protocol.
    Why Channel is unique to Fabric?
    Source: http://hyperledger-fabric.readthedocs.io/en/release-1.0/channels.html

    View Slide

  94. @arafkarsh arafkarsh
    Gossip Protocol
    94
    o Manages peer discovery and channel membership, by continually
    identifying available member peers, and eventually detecting peers
    that have gone offline.
    o Disseminates ledger data across all peers on a channel. Any peer
    with data that is out of sync with the rest of the channel identifies
    the missing blocks and syncs itself by copying the correct data. A
    state reconciliation process synchronizes world state across peers
    on each channel. Each peer continually pulls blocks from other
    peers on the channel, in order to repair its own state if
    discrepancies are identified
    o Bring newly connected peers up to speed by allowing peer-to-peer
    state transfer update of ledger data.
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/gossip.html

    View Slide

  95. @arafkarsh arafkarsh
    Summary – HyperLedger Fabric Architecture
    95
    Orderer
    • Consensus
    verification
    • Creates Blocks
    CA
    • Registration
    of identities
    • Manage
    Certificates
    Peer
    • Endorses Tx
    • Simulates Tx
    • Commits Tx
    All these components can be clustered for scalability and to avoid Single Point of Failure
    3 Components of Fabric
    Ledger
    Blockchain & World State
    Smart Contract
    • createCar
    • queryAllCars
    • queryCarProperties
    • changeCarColor
    • changeCarOwner
    Other Concepts
    • Endorsement Policies
    • Tokens
    • Assets : Anything that’s valuable for
    the Organization
    • Transactions (State changes of
    Assets)
    • Gossip Protocol : The glue that
    keeps the peers in healthy state.
    Channels
    • Private subnet for
    a set of parties
    based on Smart
    contract
    • Ledger / Channel
    • Peers can have
    multiple Channels
    • Private Data
    1
    2

    View Slide

  96. @arafkarsh arafkarsh
    Fabric : Ledger Data Structure
    14/04/23 96

    View Slide

  97. @arafkarsh arafkarsh
    Ledger
    97
    • Ledger L comprises blockchain B and World State W.
    • Blockchain B determines World State W.
    • Also expressed as: World state W is derived from blockchain B.
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/ledger/ledger.html

    View Slide

  98. @arafkarsh arafkarsh
    Blockchain Structure
    98
    In the above diagram, we can see that block B2 has a block data D2 which contains all its transactions: T5, T6, T7.
    Most importantly, B2 has a block header H2, which contains a cryptographic hash of all the transactions in D2 as well
    as with the equivalent hash from the previous block B1. In this way, blocks are inextricably and immutably linked to
    each other, which the term blockchain so neatly captures!
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/ledger/ledger.html

    View Slide

  99. @arafkarsh arafkarsh
    Blockchain Blocks
    99
    Block Header
    This section comprises three fields, written when a block is created.
    • Block number: An integer starting at 0 (the genesis block), and increased by 1 for every new
    block appended to the blockchain.
    • Current Block Hash: The hash of all the transactions contained in the current block.
    • Previous Block Hash: A copy of the hash from the previous block in the blockchain.
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/ledger/ledger.html

    View Slide

  100. @arafkarsh arafkarsh
    Transactions
    100
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/ledger/ledger.html

    View Slide

  101. @arafkarsh arafkarsh
    Ledger Example
    101
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/ledger/ledger.html

    View Slide

  102. @arafkarsh arafkarsh
    World State
    102
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/ledger/ledger.html

    View Slide

  103. @arafkarsh arafkarsh
    Namespace
    103

    View Slide

  104. @arafkarsh arafkarsh
    Hyperledger Fabric – Chain Code
    o How to write Smart Contract
    o Deploying the Smart Contract
    104

    View Slide

  105. @arafkarsh arafkarsh
    Chain code / Smart Contract
    105
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/chaincode_lifecycle.html
    o Chaincode handles the Business Logic agreed by the Members of the
    Network.
    o Chaincode can be written in Java, Go & Node.js
    o Chaincode runs in a secured Docker Container isolated from the endorsing
    Peer process.
    o Chaincode initializes and manages the Ledger State through transactions
    submitted by the Applications.
    o Chaincodes are scoped exclusively for a specific Ledger.
    o However, a Chaincode can invoke another Chaincode to query a ledger with
    appropriate permissions.

    View Slide

  106. @arafkarsh arafkarsh
    Chaincode API
    106
    Source: https://hyperledger-fabric.readthedocs.io/en/latest/smartcontract/smartcontract.html
    o A get typically represents a query to retrieve information about the current
    state of a business object.
    o A put typically creates a new business object or modifies an existing one in the
    ledger world state.
    o A delete typically represents the removal of a business object from the current
    state of the ledger, but not its history.
    A smart contract programmatically accesses two distinct pieces of the
    ledger – a blockchain, which immutably records the history of all
    transactions, and a world state that holds a cache of the current value
    of these states.
    Smart contracts primarily put, get and delete states in the world state,
    and can also query the immutable blockchain record of transactions.

    View Slide

  107. @arafkarsh arafkarsh
    Chaincode / Smart Contract
    107
    Source: https://hyperledger-fabric.readthedocs.io/en/latest/smartcontract/smartcontract.html
    Business Contracts contains
    1. Concept Definition
    2. Data Models
    3. Business Rules
    4. Processes
    Chaincode generate transactions that’s recorded
    in the ledger (Blockchain & World State).
    Smart Contract contains
    business rules between 2 or
    more organizations and is
    converted into a machine-
    readable code aka Chaincode.

    View Slide

  108. @arafkarsh arafkarsh
    Chaincode – Endorsement Policy
    108
    Source: https://hyperledger-fabric.readthedocs.io/en/latest/smartcontract/smartcontract.html
    This endorsement policy identifies which
    organizations must approve transactions
    generated by the smart contract before those
    transactions can be identified as valid.
    Endorsement policies are what make Hyperledger Fabric different to other blockchains like Ethereum or
    Bitcoin. In these systems valid transactions can be generated by any node in the network. Hyperledger Fabric
    more realistically models the real world; transactions must be validated by trusted organizations in a
    network.
    Every smart
    contract has an
    endorsement
    policy associated
    with it.

    View Slide

  109. @arafkarsh arafkarsh
    Chaincode – Valid Transactions
    Source: https://hyperledger-fabric.readthedocs.io/en/latest/smartcontract/smartcontract.html
    When a smart contract executes, it
    1. runs on a peer node owned by an
    organization in the blockchain
    network.
    2. It takes a set of input parameters
    called the transaction proposal
    3. and uses them in combination with
    its program logic to read and write
    the ledger.
    4. Changes to the world state are
    captured as a transaction proposal
    response (or just transaction
    response) which contains a read-
    write set with both the states that
    have been read, and the new states
    that are to be written if the
    transaction is valid.
    Notice that the world state is not updated when the smart contract is
    executed!
    All transactions have an identifier, a proposal, and a response signed by
    a set of organizations. All transactions are recorded on the blockchain,
    whether valid or invalid, but only valid transactions contribute to the
    world state.
    109

    View Slide

  110. @arafkarsh arafkarsh
    Chaincode & Channels
    Source: https://hyperledger-
    fabric.readthedocs.io/en/latest/smartcontract/smartcontract.h
    tml
    Hyperledger Fabric allows an organization
    1. to simultaneously participate in
    multiple, separate blockchain networks
    via channels.
    2. By joining multiple channels, an
    organization can participate in a so-
    called network of networks.
    3. Channels provide an efficient sharing of
    infrastructure while maintaining data
    and communications privacy.
    4. The smart contract code is installed
    inside a chaincode package on an
    organization's peers, channel members
    can only execute a smart contract after
    the chaincode has been defined on a
    channel.
    o The chaincode definition is a struct that contains the parameters
    that govern how a chaincode operates. These parameters include
    the chaincode name, version, and the endorsement policy.
    o Each channel member agrees to the parameters of a chaincode by
    approving a chaincode definition for their organization.
    o When a sufficient number of organizations (a majority by default)
    have approved to the same chaincode definition, the definition
    can be committed to the channel.
    110

    View Slide

  111. @arafkarsh arafkarsh
    Fabric - Endorsement Policy
    111
    • Peer uses Endorsement policies to decide if the
    transaction is properly Endorsed.
    • Peer invokes VSCC (Validation System Chaincode)
    associated with transaction’s Chaincode
    • VSCC is tasked to do the following
    • All Endorsements are valid (Valid signatures from
    Valid Certificates)
    • There is an appropriate number of Endorsements.
    • Endorsement came from expected Source(s)
    Source: http://hyperledger-fabric.readthedocs.io/en/release-1.0/endorsement-policies.html
    Examples
    • Org1.admin
    • Org2.member
    • Org3.peer
    Roles (of the
    Signer) are
    supported
    1. Member
    2. Admin
    3. Client
    4. Peer
    4
    14 April 2023

    View Slide

  112. @arafkarsh arafkarsh
    Fabric – Endorsement Policy Design
    112
    Source: http://hyperledger-fabric.readthedocs.io/en/release-1.0/endorsement-policies.html
    Endorsement Policy has two Components
    P A Principal (P) identifies the entity
    whose signature is expected
    T A Threshold Gate takes two inputs:
    • an integer : threshold
    • [n] a list of: principals or gates
    This Gate
    essentially
    captures the
    expectation that:
    • out of those
    [n] principals
    or gates,
    • are
    requested to
    be satisfied
    T(2, ‘A’, ‘B’, ‘C’)
    Requests a signature from any
    2 Principals out of A,B,C
    T(1, ‘A’, T(1, ‘B’, ‘C’))
    Requests 1 signature from A or
    1 from Principal B and C each.
    14 April 2023

    View Slide

  113. @arafkarsh arafkarsh
    Fabric - Endorsement Policy
    113
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/endorsement-policies.html
    Principals are described as MSP.ROLE
    Examples
    • Org1.admin
    • Org2.member
    • Org3.peer
    EXPR(E[, E...])
    where EXPR is either AND or OR, representing the two Boolean expressions and E is
    either a principal (with the syntax described above) or another nested call to EXPR.
    For example:
    • AND ('Org1.member', 'Org2.member', 'Org3.member') requests 1 signature from
    each of the three principals
    • OR ('Org1.member', 'Org2.member') requests 1 signature from either one of the
    two principals
    • OR ('Org1.member', AND('Org2.member', 'Org3.member')) requests either one
    signature from a member of the Org1 MSP or 1 signature from a member of
    the Org2 MSP and 1 signature from a member of the Org3 MSP.
    Roles (of the
    Signer) are
    supported
    1. Member
    2. Admin
    3. Client
    4. Peer
    4
    The policy can be specified at instantiate time using the -P switch, followed by
    the policy. For example:
    $ peer chaincode instantiate -C -n mycc -P "AND('Org1.member', 'Org2.member')"

    View Slide

  114. @arafkarsh arafkarsh
    Fabric - Endorsement Policy – ImplicitMeta
    114
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/access_control.html
    ImplicitMeta Policies
    • They aggregate the result of policies deeper in the
    configuration hierarchy that are ultimately defined
    by Signature policies.
    • They support default rules like “A majority of the
    organization admins”.
    • These policies use a different but still very simple syntax
    as compared to Signature Policies:

    Signature policies
    These policies identify specific users who must sign in
    order for a policy to be satisfied.
    Policies:
    MyPolicy:
    Type: Signature
    Rule: "OR('Org1.peer', 'Org2.peer')"

    View Slide

  115. @arafkarsh arafkarsh
    Fabric - Endorsement Policy – Signature
    115
    Source: https://github.com/hyperledger/fabric/blob/release-2.0/sampleconfig/configtx.yaml

    View Slide

  116. @arafkarsh arafkarsh
    Chaincode Lifecycle
    Develop
    Package
    Install
    Approve
    Commit 1
    2
    3
    4
    116

    View Slide

  117. @arafkarsh arafkarsh
    Lifecycle: Step 1 – Package Chaincode
    117
    Source: https://hyperledger-fabric.readthedocs.io/en/latest/chaincode_lifecycle.html
    o The chaincode needs to be packaged in
    a tar file, ending with a .tar.gz extn.
    o The tar file needs to contain two files
    (no directory):
    o a metadata file “metadata.json”
    o “code.tar.gz” containing the
    chaincode files.
    “metadata.json” contains JSON that specifies the chaincode language, code path, and
    package label. You can see an example of a metadata file below:
    It is not necessary for
    organizations to use
    the same package
    label.
    $ peer lifecycle chaincode package pkg.tar.gz - -lang java - -path src - -label p0

    View Slide

  118. @arafkarsh arafkarsh
    Lifecycle: Step 2 – Install Chaincode in Peers
    118
    Source: https://hyperledger-fabric.readthedocs.io/en/latest/chaincode_lifecycle.html
    You need to install the chaincode package on every peer that will execute and
    endorse transactions.
    A peer administrator from Org1 and Org2 installs the chaincode package MYCC_1
    on the peers joined to the channel. Installing the chaincode package builds the
    chaincode and creates a package identifier of MYCC_1:hash.
    $ peer lifecycle chaincode install pkg.tar.gz

    View Slide

  119. @arafkarsh arafkarsh
    Lifecycle: Step 3 – Approve the Chaincode
    119
    Source: https://hyperledger-fabric.readthedocs.io/en/latest/chaincode_lifecycle.html
    An organization administrator from Org1 and Org2 approve the chaincode
    definition of MYCC for their organization. The chaincode definition includes the
    chaincode name, version, and the endorsement policy, among other fields.
    Since both organizations will use the chaincode to endorse transactions, the
    approved definitions for both organizations need to include the packageID.
    $ peer lifecycle chaincode queryinstalled
    $ peer lifecycle chaincode approveformyorg - -orderer host:port …. - -package-id $PKG-ID
    Returns Package ID

    View Slide

  120. @arafkarsh arafkarsh
    Lifecycle: Step 4 – Commit Chaincode to channel
    120
    Source: https://hyperledger-fabric.readthedocs.io/en/latest/chaincode_lifecycle.html
    $ peer lifecycle chaincode commit –o host:port ……

    View Slide

  121. @arafkarsh arafkarsh
    Lifecycle: Step 4 – Commit Chaincode to channel
    121
    Source: https://hyperledger-fabric.readthedocs.io/en/latest/chaincode_lifecycle.html

    View Slide

  122. @arafkarsh arafkarsh
    Adding New Org
    122
    Source: https://hyperledger-fabric.readthedocs.io/en/latest/chaincode_lifecycle.html

    View Slide

  123. @arafkarsh arafkarsh
    Organization with different Chaincode Pkgs
    123
    Source: https://hyperledger-fabric.readthedocs.io/en/latest/chaincode_lifecycle.html

    View Slide

  124. @arafkarsh arafkarsh
    Fabric Gateway 2.4.x
    o Simplified client API to Fabric Blockchain Network
    o Available in Go, Java, TypeScript
    124

    View Slide

  125. @arafkarsh arafkarsh
    Fabric Gateway SDK Structure
    Smart
    Contract
    Blockchain Network
    CA
    Orderer
    Peer
    CRUD
    Execute Smart
    Contracts
    Get Ledger Updates
    Ledger
    Application
    Users
    Gateway
    Network
    Config Path
    Wallet
    Network Smart
    Contract
    1. Evaluate Transaction
    2. Submit Transaction
    Client Code Fabric Gateway Implementation
    Application
    Channel
    Name
    Chaincode
    Name
    Set Set
    Get Network By Get Contract By
    • Compare to previous SDK calls a single SubmitTransaction()
    function is required to submit a transaction.
    • Advanced Apps can leverage the gateway’s individual
    Endorse, Submit, and CommitStatus services for transaction
    submission, and the Evaluate service for queries.
    • You can delegate transaction endorsement entirely to the
    gateway, or if needed, specify the endorsing organizations
    and the gateway will utilize a peer from each organization.
    125

    View Slide

  126. @arafkarsh arafkarsh
    Fabric Gateway Client SDK 2.4.x onwards
    126
    Source: https://hyperledger-fabric.readthedocs.io/en/latest/gateway.html
    Evaluate Tx Proposal
    1. By invoking chaincode in Clients Org Peer & return the result to client
    2. Gateway chooses the Peer with Highest Ledger Block Height.
    3. If No Peer available, then choose from another Org.
    Endorse Tx Proposal
    1. Gather enough Endorsement responses to satisfy combined Signature Policies
    2. Return a prepared transaction to client for Signing.
    Submit a Tx
    1. Send a signed Tx envelope to Ordering Service to commit to Ledger.
    Commit Status
    1. Wait for Commit Status events like valid or invalid transaction.
    Chaincode Events
    1. Allow client Apps to respond to events that are emitted by Smart Contracts Functions

    View Slide

  127. @arafkarsh arafkarsh
    Fabric Gateway Service
    Fabric Gateway is a new service running on peer nodes that manages transaction
    submission and processing for client applications, with the following benefits:
    • Simplifies client applications and SDKs - Your client application can simply
    delegate transaction submission to a trusted peer. There is no need for your
    application to open connections to peer nodes and ordering service nodes from
    other organizations.
    • Fabric Gateway manages the collection of transaction endorsements from other
    organizations and submission to the ordering service on behalf of client
    applications.
    • Fabric Gateway has intelligence to determine what endorsements are required for
    a given transaction, even if your solution utilizes a combination of chaincode-level
    endorsement policies, private data collection endorsement policies, and state-
    based endorsement policies.
    Source: https://hyperledger-fabric.readthedocs.io/en/latest/whatsnew.html#what-s-new-in-hyperledger-fabric-v2-4
    127

    View Slide

  128. @arafkarsh arafkarsh
    Fabric : Transaction Flow
    128

    View Slide

  129. @arafkarsh arafkarsh
    Fabric: Transaction Flow
    129
    Source:
    http://hyperledger-fabric.readthedocs.io/en/release-1.0/txflow.html
    1
    2
    Customer wants to order Red Roses
    from Merchant for a new price.
    Scenario
    Customer Merchant
    Customer
    Peer B
    Peer A
    Tx Proposal
    • Endorsement Policy in the Chaincode states
    proposal must be accepted by all parties.
    • Proposal includes the function of the Chaincode
    that needs to be triggered and other params.
    • The SDK packages the transaction proposal into
    the properly architected format (protocol buffer
    over gRPC) and takes the user’s cryptographic
    credentials to produce a unique signature for this
    transaction proposal.
    Endorsing Peers
    2.1 The Endorsing Peers : Verification
    1. The transaction Proposal is well formed
    2. It has not been submitted already in the past (replay attack protection)
    3. The signature is valid using (MSP) and the
    4. Submitter (Customer) is properly authorized to perform the proposed operation on the Channel.
    14 April 2023

    View Slide

  130. @arafkarsh arafkarsh
    Fabric: Transaction Flow
    130
    Source:
    http://hyperledger-fabric.readthedocs.io/en/release-1.0/txflow.html
    2
    2.2 The Endorsing Peers : Execute
    1. The endorsing peers take the transaction proposal
    inputs as arguments to the invoked chaincode’s
    function It has not been submitted already in the
    past (replay attack protection)
    2. The chaincode is then executed against the current
    state database to produce transaction results
    including a response value, read set, and write set.
    • No updates are made to the ledger at this point. Signed Proposal
    3
    Proposal Responses are inspected
    1. App verifies the endorsing peer signatures.
    2. Checks if the Endorsement policy is fulfilled (ie.
    Customer and the Merchant Peer both endorse the
    proposal).
    14 April 2023

    View Slide

  131. @arafkarsh arafkarsh
    14 April 2023 131
    Fabric: Transaction Flow
    Convert Endorsement to transaction
    1. The App “broadcasts” the transaction proposal and
    response within a “transaction message” to the
    Ordering Service
    2. The transaction will contain the read/write sets. The
    endorsement signatures and Channel ID.
    3. The ordering service doesn't need to inspect the
    content of the transaction.
    4. It receives transactions from all the channels from
    the network and orders them chronologically by the
    Channel and
    5. Creates blocks of transactions per channel.
    4
    Ordering
    Service
    Channels

    View Slide

  132. @arafkarsh arafkarsh
    14 April 2023 132
    Fabric: Transaction Flow
    Transaction Validated and Committed
    1. The blocks of transactions are delivered to all Peers
    in the network based on the Channel ID.
    2. Validate the transaction based on Endorsement
    policy.
    3. Ensure that no change in the Ledger state based on
    the Read-set variables since the read-set was
    generated by the transaction execution.
    4. Transactions in the block are tagged as being Valid
    or Invalid.
    5
    Ordering
    Service
    Peers

    View Slide

  133. @arafkarsh arafkarsh
    14 April 2023 133
    Fabric: Transaction Flow
    6
    Ledger Updated
    1. Each Peer appends the Block to the
    Channels chain.
    2. For Each VALID transactions the write-set is
    committed to the World State Database.
    3. An Event is emitted to Notify the Client
    Application.
    4. Transactions in the block are tagged as being
    Valid or Invalid.
    Block
    appended
    to Tx Chain
    Sends Notification

    View Slide

  134. @arafkarsh arafkarsh
    14 April 2023 134
    Fabric: Transaction Flow Summary
    Source: https://hyperledger-fabric.readthedocs.io/en/release-1.3/peers/peers.html

    View Slide

  135. @arafkarsh arafkarsh
    Fabric : Private Data
    • HyperLedger Fabric v1.2 onwards
    135

    View Slide

  136. @arafkarsh arafkarsh
    Private Data
    136
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/private-data/private-data.html

    View Slide

  137. @arafkarsh arafkarsh
    Private Data – Use Case
    137
    • A Farmer selling his goods
    abroad
    • A Distributor moving goods
    abroad
    • A Shipper moving goods
    between parties
    • A Wholesaler purchasing
    goods from distributors
    • A Retailer purchasing goods
    from shippers and
    wholesalers
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/private-data/private-data.html

    View Slide

  138. @arafkarsh arafkarsh
    Private Data – Transaction Flow
    138
    1. The client application submits a proposal request to invoke a chaincode.
    2. The endorsing peers simulate the transaction and store the private data in a transient data store (a
    temporary storage local to the peer). They distribute the private data, based on the collection policy,
    to authorized peers via gossip protocol.
    3. The endorsing peer sends the proposal response back to the client with public data, including a hash
    of the private data key and value. No private data is sent back to the client.
    4. The client application submits the transaction to the ordering service (with hashes of the private
    data) which gets distributed into blocks as normal. The block with the hashed values is distributed to
    all the peers.
    5. At block-committal time, authorized peers use the collection policy to determine if they are
    authorized to have access to the private data. If they do, they will first check their
    local transient data store to determine if they have already received the private data at chaincode
    endorsement time. If not, they will attempt to pull the private data from another peer. Then they will
    validate the private data against the hashes in the public block and commit the transaction and the
    block. Upon validation/commit, the private data is moved to their copy of the private state database
    and private writeset storage.
    Source: https://hyperledger-fabric.readthedocs.io/en/release-2.2/private-data/private-data.html

    View Slide

  139. @arafkarsh arafkarsh
    Fabric : Getting Started
    • Prerequisites
    • Install Fabric Docker Components
    • Install Network with 2 Peers, 1 Orderer and 3 CA’s
    • Install the Decentralized App.
    139

    View Slide

  140. @arafkarsh arafkarsh
    Monitoring
    Fabric
    140

    View Slide

  141. @arafkarsh arafkarsh
    Pre-requisites – Mac
    141
    $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)“
    $ brew –version
    homebrew 2.5.2
    Homebrew
    $ brew install git
    $ git –version
    git version 2.23.0
    Git cURL
    $ brew install curl
    $ curl --version
    curl 7.64.1 (x86_64-apple-darwin19.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3
    zlib/1.2.11 nghttp2/1.39.2
    Release-Date: 2019-03-2
    Source: https://hyperledger-fabric.readthedocs.io/en/latest/prereqs.html
    $ brew cask install --appdir="/Applications" docker
    Docker
    $ brew install jq
    JQ
    $ brew install go
    Go
    Dev Environment Source:
    https://hyperledger-fabric.readthedocs.io/en/latest/dev-setup/devenv.html

    View Slide

  142. @arafkarsh arafkarsh
    Pre-requisites – Linux
    $ sudo apt-get install git
    Git
    $ sudo apt-get install curl
    cURL
    $ sudo apt-get -y install docker-compose
    Docker
    Pre-requisites – Windows
    Install Docker Desktop
    Docker
    Install WSL2 & Ubuntu (on WSL2) from Microsoft
    Store
    Windows Sub System for Linux (WSL2)
    Install Microsoft Visual Studio Code
    Microsoft Visual Studio Code
    Install Git for Windows
    Git
    Source: https://hyperledger-fabric.readthedocs.io/en/latest/prereqs.html
    $ sudo apt install build-essential
    Build Essentials
    142

    View Slide

  143. @arafkarsh arafkarsh
    Setting up Hyperledger Fabric
    $ ./install-fabric.sh docker samples
    $ curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/bootstrap.sh| bash -s
    $ curl -sSLO https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh
    $ chmod +x install-fabric.sh
    To Get the Fabric Install Script
    Source: https://hyperledger-fabric.readthedocs.io/en/latest/install.html
    Install Fabric Docker Containers
    Clone Fabric Examples Repository
    143

    View Slide

  144. @arafkarsh arafkarsh
    Setting up the Examples
    $ cd fabric-samples/test-network
    $ ./network.sh up createChannel –c mychannel –ca
    Channel 'mychannel' joined
    $ ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-java -ccl java
    Source: https://hyperledger-fabric.readthedocs.io/en/latest/install.html
    Setup the Blockchain Network with 2 Orgs (1 Peer each) 1 Orderer and 3 CA’s and Default Channel
    Deploy Java Chaincode
    For the “peer” cli to communicate with the Server – set the Env variables
    export PATH=${PWD}/../bin:$PATH
    export FABRIC_CFG_PATH=$PWD/../config/
    # Environment variables for Org1
    export CORE_PEER_TLS_ENABLED=true
    export CORE_PEER_LOCALMSPID="Org1MSP"
    Export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
    export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/[email protected]/msp
    export CORE_PEER_ADDRESS=localhost:7051/
    144

    View Slide

  145. @arafkarsh arafkarsh
    Testing the Cluster
    $ peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile
    "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.c
    om-cert.pem" -C mychannel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles
    "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses
    localhost:9051 --tlsRootCertFiles
    "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c
    '{"function":"InitLedger","Args":[]}'
    -> INFO 001 Chaincode invoke successful. result: status:200-> INFO 001 Chaincode invoke successful. result: status:200
    $ peer chaincode query -C mychannel -n basic -c '{"Args":["GetAllAssets"]}’
    [
    {"ID": "asset1", "color": "blue", "size": 5, "owner": "Tomoko", "appraisedValue": 300},
    {"ID": "asset2", "color": "red", "size": 5, "owner": "Brad", "appraisedValue": 400},
    {"ID": "asset3", "color": "green", "size": 10, "owner": "Jin Soo", "appraisedValue": 500},
    {"ID": "asset4", "color": "yellow", "size": 10, "owner": "Max", "appraisedValue": 600},
    {"ID": "asset5", "color": "black", "size": 15, "owner": "Adriana", "appraisedValue": 700},
    {"ID": "asset6", "color": "white", "size": 15, "owner": "Michel", "appraisedValue": 800}
    ]
    Initialize the Ledger
    Query the Ledger
    145

    View Slide

  146. @arafkarsh arafkarsh
    Testing the Cluster
    $ peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile
    "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C
    mychannel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles
    "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" --peerAddresses localhost:9051 --
    tlsRootCertFiles "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" -c
    '{"function":"TransferAsset","Args":["asset6","Christopher"]}'
    2019-12-04 17:38:21.048 EST [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
    $ peer chaincode query -C mychannel -n basic -c '{"Args":["ReadAsset","asset6"]}'
    {"ID": "asset6", "color": "white", "size": 15, "owner": " Christopher ", "appraisedValue": 800}
    Transfer Asset (Asset6) from Michel to Christopher
    Query the Ledger for a Specific Asset > Asset6
    $ peer chaincode query -C mychannel -n basic -c '{"Args":["ReadAsset","asset6"]}'
    {"ID": "asset6", "color": "white", "size": 15, "owner": " Michel ", "appraisedValue": 800}
    Query the Ledger for a Specific Asset > Asset6
    146

    View Slide

  147. @arafkarsh arafkarsh
    Fabric Example : Writing your First App
    14 April 2023 147
    Source: http://hyperledger-fabric.readthedocs.io/en/latest/write_first_app.html
    We will show the process for interacting with a Certificate
    Authority and generating enrollment certificates, after which
    we will leverage these generated identities (user objects) to
    query and update a ledger.
    1. Set up the Development Environment
    2. Learn the parameters of Smart
    Contract
    3. Develop Apps that can Query and
    Update the Ledger
    Smart
    Contract
    Blockchain Network
    CA
    Orderer
    Query
    Execute Smart Contracts
    Get Ledger Updates
    Ledger

    View Slide

  148. @arafkarsh arafkarsh
    Fabric Gateway Client API 2.4.x onwards
    148
    1. A session for a given client identity is
    established by building and connecting
    to a Fabric Gateway using a gRPC
    connection to the Gateway endpoint,
    client identity, and client signing
    implementation.
    2. The returned Gateway enables
    interaction with any of the
    blockchain Networks (channels)
    accessible through the Fabric Gateway.
    3. This in turn provides access to
    Smart Contracts within chaincode
    deployed to that blockchain network,
    and to which transactions can be
    submitted or queries can be evaluated.
    Source: https://hyperledger.github.io/fabric-gateway/main/api/java/

    View Slide

  149. @arafkarsh arafkarsh
    Asset Definition
    149

    View Slide

  150. @arafkarsh arafkarsh
    Fabric 2.x Example : Smart Contract Functions
    14 April 2023 150
    Smart Contract
    Chaincode (Java / Go / NodeJS)
    Blockchain Network
    CA
    Orderer
    Ledger
    • GetAllAssets
    • ReadAsset
    • CreateAsset
    • UpdateAsset
    • DeleteAsset
    App
    Peer

    View Slide

  151. @arafkarsh arafkarsh
    Smart Contract: Create Asset
    151

    View Slide

  152. @arafkarsh arafkarsh
    Smart Contract: Retrieve Asset
    152

    View Slide

  153. @arafkarsh arafkarsh
    Smart Contract: Update Asset
    153

    View Slide

  154. @arafkarsh arafkarsh
    Smart Contract: Delete Asset
    154

    View Slide

  155. @arafkarsh arafkarsh
    Smart Contract: Transfer Asset
    155

    View Slide

  156. @arafkarsh arafkarsh
    Smart Contract: Get All Assets
    156

    View Slide

  157. @arafkarsh arafkarsh
    Fabric Example : Writing your First App
    14 April 2023 157
    Source: http://hyperledger-fabric.readthedocs.io/en/latest/write_first_app.html
    We will show the process for interacting with a Certificate
    Authority and generating enrollment certificates, after which
    we will leverage these generated identities (user objects) to
    query and update a ledger.
    1. Set up the Development Environment
    2. Learn the parameters of Smart
    Contract
    3. Develop Apps that can Query and
    Update the Ledger
    Smart
    Contract
    Blockchain Network
    CA
    Orderer
    Query
    Execute Smart Contracts
    Get Ledger Updates
    Ledger

    View Slide

  158. @arafkarsh arafkarsh
    Fabric 1.x Example : Install the Fabcar Example
    158
    $ cd fabric-samples/fabcar && ls *.js
    enrollAdmin. js Invoke.js query.js registerUser.js
    You will see for Node JS Programs as follows
    Do a cleanup before u start installing the Sample App in the Ledger
    $ docker rm -f $(docker ps -aq)
    $ docker network prune
    $ docker rmi dev-peer0.org1.example.com-fabcar-1.0-5c906e402ed29f20260ae42283216aa75549c571e2e380f3615826365d8269ba
    $ npm install
    $ ./startFabric.sh
    Source: http://hyperledger-fabric.readthedocs.io/en/latest/write_first_app.html
    14 April 2023

    View Slide

  159. @arafkarsh arafkarsh
    Fabric 1.x Example : Enroll User
    14 April 2023 159
    Source: http://hyperledger-fabric.readthedocs.io/en/latest/write_first_app.html
    $ node enrollAdmin.js
    An admin user - admin - was registered with our Certificate Authority. Now we need to send an
    enroll call to the CA server and retrieve the enrollment certificate (eCert) for this user.
    This program will invoke a certificate signing request (CSR) and ultimately output an eCert and key
    material into a newly created folder - hfc-key-store - at the root of this project.
    $ node registerUser.js
    Newly generated admin eCert, we will now communicate with the CA server once more to register
    and enroll a new user. This user - user1 - will be the identity we use when querying and updating the
    ledger.
    Similar to the admin enrollment, this program invokes a CSR and outputs the keys and eCert into
    the hfc-key-store subdirectory. So now we have identity material for two separate users -
    admin & user1

    View Slide

  160. @arafkarsh arafkarsh
    Fabric 1.x Example : Smart Contract Functions
    14 April 2023 160
    Smart Contract
    Chaincode (Java / Go / NodeJS)
    Blockchain Network
    CA
    Orderer
    Ledger
    • createCar
    • queryAllCars
    • queryCarProperties
    • changeCarColor
    • changeCarOwner

    View Slide

  161. @arafkarsh arafkarsh
    14 April 2023 161
    Chaincode Constructor
    Invoke(stub) method is called as result
    of an application request to the
    Chaincode
    Ledger Persistence Calls – Commands
    createCar(stub, args)
    changeCarOwner(stub, args)

    View Slide

  162. @arafkarsh arafkarsh
    14 April 2023 162
    queryCar(stub, args)
    Ledger Persistence Calls – Queries
    queryAllCars(stub, args)

    View Slide

  163. @arafkarsh arafkarsh
    Fabric 1.x Example : Query The Ledger
    14 April 2023 163
    $ node query.js
    Similar to the admin enrollment, this program invokes a CSR and outputs the keys and eCert into
    the hfc-key-store subdirectory. So now we have identity material for two separate users -
    admin & user1
    Source: http://hyperledger-fabric.readthedocs.io/en/latest/write_first_app.html
    Smart
    Contract
    Blockchain Network
    CA
    Orderer
    Query
    Run the query
    Return Query Results
    Queries are how you read data from the ledger. This data is stored as a
    series of key-value pairs, and you can query for the value of a single key,
    multiple keys, or – if the ledger is written in a rich data storage format like
    JSON – perform complex searches against it (looking for all assets that
    contain certain keywords, for example)
    fabric_client.getUserContext('user1', true);
    Ledger

    View Slide

  164. @arafkarsh arafkarsh
    Fabric 1.x Example – Node.JS Client API
    164
    Source: http://hyperledger-fabric.readthedocs.io/en/release-1.0/write_first_app.html
    1. Initialize the Client API
    2. Create a Channel
    3. Create a Peer
    4. Add Peer to the Channel
    Query ChainCode: fabcar
    Query Function: queryAllCars
    $ node query.js
    GetHistoryForKey()
    GetHistoryForKey()
    14 April 2023

    View Slide

  165. @arafkarsh arafkarsh
    Fabric 1.x Example – Node.JS Client API
    14 April 2023 165
    1. Get a Transaction ID based on the
    user assigned to the client.
    2. Send Transaction Proposal for
    3. createCar() function in the
    Chaincode creates a new transaction
    4. changeCarOwner() function in the
    Chaincode updates the owner.
    Update function doesn't update the Blockchain instead it will have a new record with the latest status of the Asset.
    $ node invoke.js

    View Slide

  166. @arafkarsh arafkarsh
    Summary – Why do we need Blockchain?
    14 April 2023 166
    Reconciliation Issues
    in a Multi Party
    environment.
    o Expensive
    o Vulnerable
    o Inefficient
    Problem Statement
    o Consensus among the Parties
    before a transaction is committed.
    o Provenance – Origin of the asset
    can be easily Tracked.
    o Immutable – Transactions are
    tamper proof
    o Finality – Single Source of Truth
    Solution

    View Slide

  167. @arafkarsh arafkarsh
    Summary – Benefits of Blockchain Technologies
    Saves Time
    Immutable
    transaction across
    parties done at the
    same time.
    Remove Cost
    Overheads on
    maintaining and
    synchronizing silos.
    Increases Trust
    Through shared process
    and unified Systems of
    Record. For end
    consumers it’s a System
    of Proof.
    Reduces Risk
    Tampering of data,
    fraud and cyber crime
    is avoided.
    167

    View Slide

  168. @arafkarsh arafkarsh
    Ethereum Vs. HyperLedger Fabric Vs. R3 Corda
    168
    Characteristics Ethereum HyperLedger Fabric R3 Corda
    Description of
    the Platform
    Generic Blockchain Platform Modular Blockchain Platform
    Specialized distributed ledger
    platform for Financial Industry
    Release History December 2021 v2.2.5 January 28, 2022 v4.8 April 21, 2021
    Crypto Currency
    Ether / Tokens (Usage, Work) via
    Smart Contract
    None
    Currency and Tokens via Chaincode
    None
    Governance
    Ethereum Developers
    Enterprise Ethereum Alliance
    Linux Foundation
    IBM
    R3
    Consensus
    Mining based on Proof of Work
    (POW) – All participants need to
    agree.
    Ledger Level
    Selective Endorsement. Consensus
    can be even within a channel with
    select parties instead of everyone.
    Transaction Level
    Specific understanding of
    Consensus. (Validity, Uniqueness)
    Transaction Level
    Network Permissionless, Public or Private Permissioned, Private Permissioned, Private
    State Account Data
    Key-value Database
    Transaction Log, World State
    Vault contains States
    Historic & Current State
    Smart Contracts Solidity Chaincode (GoLang, Node.JS, Java) Smart Contract (Kotlin, Java)
    Development
    Languages
    GoLang, C++, Python Java, Node.JS, Python (Post 1.0) Java, Kotlin
    14 April 2023

    View Slide

  169. @arafkarsh arafkarsh 169
    DREAM | AUTOMATE | EMPOWER
    Araf Karsh Hamid :
    India: +91.999.545.8627
    http://www.slideshare.net/arafkarsh
    https://www.linkedin.com/in/arafkarsh/
    https://www.youtube.com/user/arafkarsh/playlists
    http://www.arafkarsh.com/
    @arafkarsh
    arafkarsh

    View Slide

  170. @arafkarsh arafkarsh 170
    Source Code: https://github.com/MetaArivu Web Site: https://metarivu.com/ https://pyxida.cloud/

    View Slide

  171. @arafkarsh arafkarsh 171
    http://www.slideshare.net/arafkarsh

    View Slide

  172. @arafkarsh arafkarsh
    References - Blockchain Video Tutorials
    • https://www.ibm.com/topics/what-is-blockchain
    • https://www.geeksforgeeks.org/features-of-blockchain/
    • https://101blockchains.com/introduction-to-blockchain-features/
    • Blockchain Use Cases: https://wiki.hyperledger.org/groups/requirements/use-case-inventory
    • Hyperledger Fabric Explainer: https://www.youtube.com/watch?v=js3Zjxbo8TM
    • Blockchain Technology : https://www.youtube.com/watch?v=qOVAbKKSH10
    • Smart Contracts : https://www.youtube.com/watch?v=ZE2HxTmxfrI
    • Hyperledger Fabric v1.1 Node.JS Chaincode : https://www.youtube.com/watch?v=dzwR0dwzXNs
    • Hyperledger Fabric v1.0 : https://www.youtube.com/watch?v=6nGIptzBZis
    • Hyperledger Fabric for Beginners : https://www.youtube.com/watch?v=Y177TCUc4g0
    • Fabric Composer : https://www.youtube.com/watch?v=fdFUsrsv5iw
    • Hyperledger Composer : https://www.youtube.com/watch?v=iRlm4uY_9pA
    • How does it works: Blockchain : https://www.youtube.com/watch?v=lD9KAnkZUjU
    • How does Blockchain work: https://www.youtube.com/watch?v=LZEHOlZY2To
    • 19 Industries The Blockchain will disrupt : https://www.youtube.com/watch?v=G3psxs3gyf8
    • What is the difference between Bitcoin & Blockchain? : https://www.youtube.com/watch?v=MKwa-BqnJDg
    • Bitcoin: What Bill Gates, Buffet, Elon Mush & Richard Branson has to say about Bitcoin?
    172

    View Slide

  173. @arafkarsh arafkarsh
    1. HyperLedger Architecture Volume 1
    2. Creating Tokens in Hyperledger Fabric : https://github.com/Kunstmaan/hyperleder-fabric-kuma-token-example/
    3. Karame, Androulaki, & Capkun. (2012). Double spending fast payments in bitcoin. ACM Conference on Computer and
    communications security, (pp. 906-917).
    4. King, N. (2012). PPCoin: Peer to peer cryptocurrency with proof of stake.
    5. Kwon. (2014). Tendermint: Consensus without Mining. Cornell Edu.
    6. Mazieres, D. (2015). The Stellar Consensus Protocol: Federated Model for Internet level consensus. Stellar Development
    Foundation.
    7. Narayanan, B. F. (2016). Bitcoin and cryptocurrency technologies. Princeton: Princeton University Press.
    8. O'Dwyer, & Malone. (2014). Bitcoin mining and its energy footprint. Irish Signals and Systems Conference, pp. 280-285
    9. Byzantine Fault Tolerance : https://en.wikipedia.org/wiki/Byzantine_fault_tolerance
    10. Building Blockchain Apps for Node.JS developers with HyperLedger Composer – Simon Stone IBM
    References
    173

    View Slide