Hands-On Blockchain with Hyperledger

Book description

Leverage the power of Hyperledger Fabric to develop Blockchain-based distributed ledgers with ease

Key Features

  • Write your own chaincode/smart contracts using Golang on hyperledger network
  • Build and deploy decentralized applications (DApps)
  • Dive into real world blockchain challenges such as integration and scalability

Book Description

BBlockchain and Hyperledger technologiesare hot topics today. Hyperledger Fabric and Hyperledger Composer are open source projects that help organizations create private, permissioned blockchain networks. These find application in finance, banking, supply chain, and IoT among several other sectors. This book will be an easy reference to explore and build blockchain networks using Hyperledger technologies.

The book starts by outlining the evolution of blockchain, including an overview of relevant blockchain technologies. You will learn how to configure Hyperledger Fabric and become familiar with its architectural components. Using these components, you will learn to build private blockchain networks, along with the applications that connect to them. Starting from principles first, you'll learn to design and launch a network, implement smart contracts in chaincode and much more.

By the end of this book, you will be able to build and deploy your own decentralized applications, handling the key pain points encountered in the blockchain life cycle.

What you will learn

  • Discover why blockchain is a game changer in the technology landscape
  • Set up blockchain networks using basic Hyperledger Fabric deployment
  • Understand the considerations for creating decentralized applications
  • Learn to integrate business networks with existing systems
  • Write Smart Contracts quickly with Hyperledger Composer
  • Design transaction model and chaincode with Golang
  • Deploy Composer REST Gateway to access the Composer transactions
  • Maintain, monitor, and govern your blockchain solutions

Who this book is for

The book benefits business leaders as it provides a comprehensive view on blockchain business models, governance structure, and business design considerations of blockchain solutions. Technology leaders stand to gain a lot from the detailed discussion around the technology landscape, technology design, and architecture considerations in the book. With model-driven application development, this guide will speed up understanding and concept development for blockchain application developers. The simple and well organized content will put novices at ease with blockchain concepts and constructs.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Hands-On Blockchain with Hyperledger
  3. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  4. Foreword
  5. Contributors
    1. About the authors
    2. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Conventions used
    4. Get in touch
      1. Reviews
  7. Blockchain - Enterprise and Industry Perspective
    1. Defining the terms – what is a blockchain?
    2. Four core building blocks of blockchain framworks
      1. Additional capabilities to consider
    3. Fundamentals of the secure transaction processing protocol
    4. Where blockchain technology has been and where it's going
      1. The great divide
      2. An economic model for blockchain delivery
      3. Learning as we go
      4. The promise of trust and accountability
    5. Industries putting blockchain technology to work
    6. Blockchain in the enterprise
      1. What applications are a good fit?
      2. How does the enterprise view blockchain?
      3. Litmus testing to justify the application of blockchain technology
      4. Integrating a blockchain infrastructure for the whole enterprise
    7. Enterprise design principles
      1. Business drivers and evolution
      2. Ensuring sustainability
      3. The principles that drive blockchain adoption
    8. Business considerations for choosing a blockchain framework
    9. Technology considerations for choosing a blockchain framework
      1. Identity management
      2. Scalability
      3. Enterprise security
      4. Development tooling
      5. Crypto-economic models
      6. Decentralization with systemic governance
      7. Enterprise support
      8. Use case-driven pluggability choices
        1. Shared ledger technology
        2. Consensus
        3. Crypto algorithms and encryption technology
        4. Use case-driven pluggable choices
    10. Enterprise integration and designing for extensibility
    11. Other considerations
      1. Consensus, ACID property, and CAP
        1. CAP
        2. ACID
      2. Attestation – SSCs are signed and encrypted
      3. Use of HSMs
    12. Summary
  8. Exploring Hyperledger Fabric
    1. Building on the foundations of open computing
      1. Fundamentals of the Hyperledger project
        1. The Linux Foundation 
        2. Hyperledger
        3. Open source and open standards
    2. Hyperledger frameworks, tools, and building blocks
      1. Hyperledger frameworks
      2. Hyperledger tools
      3. The building blocks of blockchain solutions
    3. Hyperledger Fabric component design
      1. Principles of Hyperledger design
      2. CAP Theorem
      3. Hyperledger Fabric reference architecture
      4. Hyperledger Fabric runtime architecture
      5. Strengths and advantages of componentized design
    4. Hyperledger Fabric – the journey of a sample transaction
    5. Hyperledger Fabric explored
      1. Components in a blockchain network
      2. Developer interaction
    6. Understanding governance in business networks powered by blockchain
      1. Governance structure and landscape
      2. Information technology governance
      3. Blockchain network governance
      4. Business network governance
    7. Summary
  9. Setting the Stage with a Business Scenario
    1. Trading and letter of credit
      1. The importance of trust in facilitating trade
      2. The letter of credit process today
    2. Business scenario and use case
      1. Overview
      2. Real-world processes
      3. Simplified and modified processes
      4. Terms used in trade finance and logistics
      5. Shared process workflow
      6. Shared assets and data
      7. Participants' roles and capabilities
      8. Benefits of blockchain applications over current real-world processes
    3. Setting up the development environment
      1. Designing a network
      2. Installing prerequisites
      3. Forking and cloning the trade-finance-logistics repository
      4. Creating and running a network configuration 
        1. Preparing the network
        2. Generating network cryptographic material
        3. Generating channel artifacts
        4. Generating the configuration in one operation
        5. Composing a sample trade network
    4. Network components' configuration files
    5. Launching a sample trade network
    6. Summary
  10. Designing a Data and Transaction Model with Golang
    1. Starting the chaincode development
      1. Compiling and running chaincode
      2. Installing and instantiating chaincode
      3. Invoking chaincode
    2. Creating a chaincode
      1. The chaincode interface
      2. Setting up the chaincode file
        1. The Invoke method
    3. Access control
      1. ABAC
        1. Registering a user
        2. Enrolling a user
        3. Retrieving user identities and attributes in chaincode
    4. Implementing chaincode functions
      1. Defining chaincode assets
      2. Coding chaincode functions
      3. Creating an asset
      4. Reading and modifying an asset
      5. Main function
    5. Testing chaincode
      1. SHIM mocking
        1. Testing the Init method
        2. Testing the Invoke method
        3. Running tests
    6. Chaincode design topics
      1. Composite keys
      2. Range queries
      3. State queries and CouchDB
      4. Indexes
      5. ReadSet and WriteSet
      6. Multiversion concurrency control
    7. Logging output
      1. Configuration
      2. Logging API
      3. SHIM logging levels
      4. Stdout and stderr
      5. Additional SHIM API functions
    8. Summary
  11. Exposing Network Assets and Transactions
    1. Building a complete application
      1. The nature of a Hyperledger Fabric application
        1. Application and transaction stages
        2. Application model and architecture
      2. Building the application
      3. Middleware – wrapping and driving the chaincode
        1. Installation of tools and dependencies
          1. Prerequisites for creating and running the middleware
          2. Installation of dependencies
        2. Creating and running the middleware
          1. Network configuration
          2. Endorsement policy
          3. User records
          4. Client registration and enrollment
          5. Creating a channel
          6. Joining a channel
          7. Installation of chaincode
          8. Instantiation of chaincode
          9. Invoking the chaincode
          10. Querying the chaincode
          11. Completing the loop – subscribing to blockchain events
          12. Putting it all together
      4. User application – exporting the service and API
        1. Applications
        2. User and session management
        3. Designing an API
        4. Creating and launching a service
          1. User and session management
          2. Network administration
          3. Exercising the application
          4. User/client interaction modes
        5. Testing the Middleware and Application
    2. Integration with existing systems and processes
      1. Design considerations
      2. Decentralization
      3. Process alignment
        1. Message affinity
      4. Service discovery
      5. Identity mapping
      6. Integration design pattern
        1. Enterprise system integration
        2. Integrating with an existing system of record
        3. Integrating with an operational data store
        4. Microservice and event-driven architecture
      7. Considering reliability, availability, and serviceability
        1. Reliability
        2. Availability
        3. Serviceability
    3. Summary
  12. Business Networks
    1. A busy world of purposeful activity
      1. Why a language for business networks?
    2. Defining business networks
      1. A deeper idea
    3. Introducing participants
      1. Types of participant
        1. Individual participants
        2. Organizational participants
        3. System or device participants
      2. Participants are agents
      3. Participants and identity
    4. Introducing assets
      1. Assets flow between participants
      2. Tangible and intangible assets
      3. The structure of assets
      4. Ownership is a special relationship
      5. Asset life cycles
      6. Describing asset's life cycles in detail with transactions
    5. Introducing transactions
      1. Change as a fundamental concept
      2. Transaction definition and instance
      3. Implicit and explicit transactions
      4. The importance of contracts
      5. Signatures
      6. Smart contracts for multi-party transaction processing
      7. Digital transaction processing
      8. Initiating transactions
      9. Transaction history
      10. Transaction streams
      11. Separating transactions into different business networks
      12. Transaction history and asset states
      13. A business network as a history of transactions
      14. Regulators and business networks
    6. Discussing events from the perspective of designing a business network using Composer
      1. A universal concept
      2. Messages carry event notifications
      3. An example to illustrate event structure
      4. Events and transactions
      5. External versus explicit events
      6. Events cause participants to act
      7. Loosely coupled design
      8. The utility of events
    7. Implementing a business network
      1. The importance of de-materialization
      2. Blockchain benefits for B2B and EDI
      3. Participants that interact with the blockchain
      4. Accessing the business network with APIs
      5. A 3-tier systems architecture
      6. Hyperledger Fabric and Hyperledger Composer
    8. Summary
  13. A Business Network Example
    1. The letter of credit sample
      1. Installing the sample
      2. Running the sample
        1. Step 1 – preparing to request a letter of credit
        2. Step 2 – requesting a letter of credit
        3. Step 3 – importing bank approval
        4. Step 4 – exporting bank approval
        5. Step 5 – letter received by exporter
        6. Step 6 – shipment
        7. Step 7 – goods received
        8. Step 8 – payment
        9. Step 9 – closing the letter
        10. Step 10 – Bob receives payment
      3. Recapping the process
    2. Analyzing the letter of credit process
      1. The Playground
      2. Viewing the business network
    3. A description of the business network
      1. The participant descriptions
      2. The asset descriptions
      3. The transaction descriptions
      4. The event descriptions
    4. A model of the business network
      1. Namespaces
      2. Enumerations
      3. Asset definitions
      4. Participant definitions
      5. Concept definitions
      6. Transaction definitions
      7. Event definitions
    5. Examining the live network
      1. Examining a letter of credit instance
      2. Examining participant instances
      3. Examining transaction instances
      4. Submitting a new transaction to the network
      5. Understanding how transactions are implemented
    6. Creating business network APIs
      1. SWAGGER API definitions
      2. Querying the network using SWAGGER
      3. Testing the network from the command line
      4. Creating a new letter using SWAGGER
      5. Network cards and wallets
      6. Access-control lists
    7. Summary
  14. Agility in a Blockchain Network
    1. Defining the promotion process
      1. Smart contract considerations
      2. Integration layer considerations
      3. Promotion process overview
    2. Configuring a continuous integration pipeline
      1. Customizing the pipeline process
        1. Local build
        2. Configuring Travis CI
        3. Customizing the pipeline using .travis.yml
      2. Publishing our smart contract package
    3. Configuring your Git repository
      1. Setting the code owners of our smart contract
        1. Sample content of the CODEOWNERS
      2. Protecting the master branch
      3. Configuring Git for commit signing and validation
        1. Configuring GPG on your local workstation
    4. Testing the end-to-end process
      1. Creating a new transaction
        1. Pushing a commit to the master branch directly
        2. Submitting a pull request with an unsigned commit
      2. Adding test cases
        1. Submitting a pull request with a signed commit
        2. Adding the mergeAssets unit test
      3. Releasing the new version
    5. Updating the network
      1. Notifying the consortium
      2. Upgrading the business network
        1. Downloading a new version
        2. Updating the business network
    6. Summary
  15. Life in a Blockchain Network
    1. Modifying or upgrading a Hyperledger Fabric application
      1. Fabric blockchain and application life cycle
      2. Channel configuration updates
        1. Prerequisites for adding a new organization to the network
        2. Generating network cryptographic material
        3. Generating channel artifacts
        4. Generating the configuration and network components in one operation
        5. Launching the network components for the new organization
        6. Updating the channel configuration
        7. Adding the new organization to the network
      3. Smart contract and policy updates
        1. Modification in chaincode logic
        2. Dependency upgrades in chaincode
        3. Ledger resetting
        4. Endorsement policy update
        5. Upgrading chaincode and endorsement policy on the trade channel
      4. Platform upgrades
    2. System monitoring and performance
      1. Measurement and analytics
      2. What should we measure or understand in a Fabric application
        1. Blockchain applications vis-à-vis traditional transaction processing applications
        2. Metrics for performance analysis
      3. Measurement and data collection in a Fabric application
        1. Collecting health and capacity information
        2. Profiling containers and applications
        3. Measuring application performance
      4. Fabric engineering guidelines for performance
        1. Platform performance characteristics
        2. System bottlenecks
        3. Configuration and tuning
        4. Ledger data availability and caching
          1. Redundant committing peer
          2. Data caching
        5. Fabric performance measurement and benchmarking
    3. Summary
  16. Governance, Necessary Evil of Regulated Industries
    1. Decentralization and governance
    2. Exploring the business models
      1. Blockchain benefits
        1. Supply chain management
        2. Healthcare
        3. Finance – letter of credit
      2. From benefits to profits
      3. Network business model
        1. Founder-led network
        2. Consortium-based network
        3. Community-based network
        4. Hybrid models
          1. Joint venture
          2. New corporation
    3. Role of governance in a business network
    4. Business domains and processes
      1. Membership life cycle
      2. Funding and fees
      3. Regulation
      4. Education
      5. Service life cycle
      6. Disputes
    5. Governance structure
      1. Centralized governance
        1. Strategic governance
        2. Operational governance
        3. Tactical governance
      2. Decentralized governance
    6. Governance and the IT solution
      1. Managed on-boarding
    7. Summary
  17. Hyperledger Fabric Security
    1. Hyperledger Fabric design goals impacting security
    2. Hyperledger Fabric architecture 
      1. Fabric CA or membership service provider
      2. Peer
      3. Smart contract or chaincode
      4. Ledger
      5. Private data
      6. Ordering service
    3. Network bootstrap and governance – the first step towards security
      1. Creating the network
      2. Adding new members
      3. Deploying and updating chaincode 
      4. Data model
    4. Strong identities – the key to the security of the Hyperledger Fabric network
      1. Bootstrapping Fabric CA
        1. Register
        2. Default Fabric roles 
        3. Enroll
          1. Which crypto protocols are allowed in certificate signing requests?
        4. Revoking identities 
      2. Practical considerations in managing users in Fabric CA
    5. Chaincode security
      1. How is chaincode shared with other endorsing peers?
      2. Who can install chaincode?
      3. Chaincode encryption
      4. Attribute-based access control
        1. Pros and cons of attribute-based access control
    6. Common threats and how Hyperledger Fabric mitigates them 
      1. Transaction privacy in Hyperledger Fabric
        1. Channels
        2. Private data
        3. Encrypting transaction data
    7. Hyperledger Fabric and Quantum Computing
    8. General data protection regulation (GDPR) considerations
    9. Summary
  18. The Future of Blockchain and the Challenges Ahead
    1. Summary of key Hyperledger projects
      1. Hyperledger framework – business blockchain technology
      2. Hyperledger tools
        1. Hyperledger Composer
    2. The road ahead for Blockchain
      1. Addressing the divide – the enterprise blockchain and crypto asset-driven ecosystem
      2. Interoperability – understanding business service integration
      3. Scalability and economic viability of the blockchain solution 
    3. Staying engaged with the Hyperledger blockchain 
    4. Summary
  19. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Hands-On Blockchain with Hyperledger
  • Author(s): Salman Baset, Luc Desrosiers, Nitin Gaur, Petr Novotny, Venkatraman Ramakrishna, Anthony O'Dowd
  • Release date: June 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788994521