Hands-On Smart Contract Development with Hyperledger Fabric V2

Book description

Blockchain technology continues to disrupt a wide variety of organizations, from small businesses to the Fortune 500. Today hundreds of blockchain networks are in production, including many built with Hyperledger Fabric. This practical guide shows developers how the latest version of this blockchain infrastructure provides an ideal foundation for developing enterprise blockchain applications or solutions.

Authors Matt Zand, Xun Wu, and Mark Anthony Morris demonstrate how the versatile design of Hyperledger Fabric 2.0 satisfies a broad range of industry use cases. Developers with or without previous Hyperledger experience will discover why no other distributed ledger technology framework enjoys such wide adoption by cloud service providers such as Amazon, Alibaba, IBM, Google, and Oracle.

  • Walk through the architecture and components of Hyperledger Fabric 2.0
  • Migrate your current Hyperledger Fabric projects to version 2.0
  • Develop blockchain applications on the Hyperledger platform with Node.js
  • Deploy and integrate Hyperledger on Amazon Managed Blockchain, IBM Cloud, and Oracle Cloud
  • Develop blockchain applications with Hyperledger Aries, Avalon, Besu, and Grid
  • Build end-to-end blockchain supply chain applications with Hyperledger

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. How to Build Enterprise Blockchain Applications with Hyperledger
    2. Who Is This Book For?
    3. Overview of the Chapters
    4. Conventions Used in This Book
    5. Using Code Examples
    6. O’Reilly Online Learning
    7. How to Contact Us
    8. Acknowledgments
  2. I. Introduction to Blockchain
  3. 1. Fundamental Concepts of Blockchain
    1. What Is Blockchain?
    2. Origin of Blockchain
      1. The Blockchain Revolution
      2. Blockchain 2.0
    3. Core Components of Blockchain
      1. Decentralized Network
      2. Cryptography
      3. Wallet
      4. Shared Ledger
      5. Consensus
      6. Smart Contracts
    4. Blockchain Architecture
      1. Nodes
      2. Blocks
      3. Chains
      4. Channels
    5. Supporting Technology and Concepts
      1. DLT
      2. Decentralization
      3. Peer-to-Peer
      4. Immutability
      5. Identity
      6. Accounts
      7. SDK
      8. API
      9. Transactions
      10. Incentives
      11. Privacy
      12. State
      13. Turing Complete
      14. Gas
      15. Tokens
      16. On-Chain
      17. Off-Chain
      18. Scalability
      19. Cryptocurrency
      20. Enclaves
      21. Oracles
      22. DApps
      23. Virtual Machine
      24. Fork
      25. Governance
      26. Genesis
      27. Clients
    6. Summary
  4. II. Introduction to Hyperledger Projects
  5. 2. Overview of Hyperledger Projects and Tools
    1. Evolution and Phases of Blockchain Technology
      1. Blockchain 1.0
      2. Blockchain 2.0
      3. Blockchain 3.0
      4. Blockchain 4.0
    2. Hyperledger Family, Architecture, and Ecosystem
      1. The Hyperledger Design Philosophy
      2. Overview of Hyperledger
    3. Overview of Hyperledger Projects
      1. Distributed Ledger Frameworks
      2. Domain-Specific
    4. Overview of Hyperledger Tools and Libraries
      1. Tools
      2. Libraries
    5. Summary
  6. 3. Hyperledger Fabric Architecture and Components
    1. Hyperledger Fabric Overview
    2. Hyperledger Fabric Model
      1. Blockchain Network
      2. Identity
      3. Membership Service Provider
      4. Policies
      5. Nodes
      6. Chaincode
      7. Ledger
      8. The Ordering Service
      9. Private Collections of Data
    3. Summary
  7. III. Developing Smart Contracts with Hyperledger Fabric
  8. 4. Smart Contract Development
    1. Installing Prerequisites and Setting Up Hyperledger Fabric
      1. Git
      2. cURL
      3. Node.js and npm
      4. Docker and Docker Compose
      5. Fabric Installation Script
      6. Fundamental Requirements of a Smart Contract
      7. SDK
      8. Create and Execute Queries
    2. Defining a Smart Contract
      1. Define Assets by Using Key-Value Pairs
      2. Collect Private Data
      3. Set Attribute-Based Access Control
      4. Initialize the Ledger State
    3. Installing and Instantiating a Smart Contract
      1. Package the Chaincode
      2. Install the Chaincode
      3. Query the Installation
      4. Approve the Package
      5. Check Commit Readiness
      6. Commit the Chaincode Definition
      7. Query Whether the Chaincode Is Committed
      8. Initialize the Contract
      9. Execute a Query
    4. Summary
  9. 5. Smart Contract Invocation
    1. Overview of fabric-samples, Fabcar, and the Test Network
      1. fabric-samples
      2. Fabcar
      3. Fabric Test Network
    2. Deploying a Smart Contract
      1. Understand the startFabric.sh Anatomy
      2. Execute startFabric.sh
      3. Generate Fabric Certificate Authorities
      4. Create Org1 Identities
      5. Invoke the Peer Chaincode
    3. Invoking Smart Contract Transactions
      1. Peer Command
      2. Fabric SDK for Node.js Command-Line Application
    4. Summary
  10. 6. Testing and Maintenance
    1. Creating a Fabcar UI Client
      1. Error Response Handling
      2. Fabcar UI Web Pages
      3. Fabcar UI Code
      4. Fabcar UI Execution
    2. Performing Rapid Smart Contract Testing
      1. Setting Up
      2. Preparing the Fabcar Smart Contract for Testing and Debugging
      3. Performing Fabcar Testing and Debugging
    3. Identifying and Reviewing Logs
    4. Creating Unit Test Contracts
    5. Summary
  11. IV. Blockchain Supply Chain with Hyperledger
  12. 7. Building Supply Chain DApps with Hyperledger Fabric
    1. Designing a Blockchain Supply Chain
      1. Understanding the Supply Chain Workflow
      2. Defining a Consortium
      3. Reviewing the PLN Life Cycle
      4. Understanding Transactions
    2. Writing Chaincode as a Smart Contract
      1. Project Structure
      2. Contract Class
      3. Transaction Logic
    3. Compiling and Deploying Fabric Chaincode
      1. Install Prerequisites
      2. Review the Project Structure
      3. Install Binaries and Docker Images
      4. Start the PLN Network
      5. Monitor the PLN Network
      6. Create a PLN Channel
    4. Running and Testing the Smart Contract
      1. Install the Smart Contract
      2. Test the Smart Contract
    5. Developing an Application with Hyperledger Fabric Through the SDK
    6. Summary
  13. V. Hyperledger Fabric—Other Topics
  14. 8. Deploying Hyperledger Fabric on the Cloud
    1. Deploying Hyperledger Fabric on Amazon Blockchain Services
      1. Set Up Amazon Managed Blockchain with Prerequisites
      2. Set Up the Hyperledger Fabric Network
      3. Set Up the Hyperledger Fabric Client
      4. Clone the Samples Repository
      5. Run the Hyperledger Fabric Application
    2. Using IBM Cloud for Blockchain Applications
      1. Understand the Platform Features
      2. Create an IBM Cloud Account
      3. Decide the Structure of the Blockchain Network
      4. Create and Join the Fabric Network
      5. Build the Blockchain Network
      6. Deploy the Smart Contract
      7. Create the Application
    3. Oracle Blockchain Platform Overview
    4. Oracle Blockchain Platform Use Case
      1. Explore the Use Case
      2. Engage with the Solution
      3. Experiment with Oracle Blockchain Platform
      4. Experience the Solution
    5. Summary
  15. 9. Hyperledger Fabric V2 Integration
    1. New Features of Hyperledger Fabric V2
      1. Decentralized Governance for Smart Contracts
      2. New Chaincode Application Patterns
      3. Private Data Enhancements
      4. External Chaincode Launcher
      5. State Database Cache for CouchDB
      6. Alpine-Based Docker Images
      7. Sample Test Network
    2. Updating the Capability Level of a Channel
      1. Update to the Newest Capability Levels
      2. Upgrade Components
      3. Set Environment Variables for the Binaries
      4. Back Up and Restore the Ledger
      5. Upgrade the Orderer Nodes
      6. Upgrade the Peers
      7. Upgrade the Node SDK Clients
    3. Considerations for Moving to V2
      1. Chaincode Life Cycle
      2. Chaincode Shim Changes (Go Chaincode Only)
      3. Chaincode Logger (Go Chaincode Only)
      4. Peer Databases Upgrade
      5. Capabilities
    4. Summary
  16. 10. Overview of Other Hyperledger Projects
    1. Hyperledger Aries
      1. Set Up the VON Network
      2. Run Hyperledger Aries Cloud Agent
    2. Hyperledger Avalon
      1. Trusted Execution Environment
      2. Zero-Knowledge Proofs
      3. Multiparty Computation
      4. Hyperledger Avalon Architecture
    3. Hyperledger Besu
      1. Hyperledger Besu Architecture
      2. Set Up Hyperledger Besu
      3. Smart Contract and DApp in Hyperledger Besu Private Network
    4. Hyperledger Grid
      1. Domain Models
      2. Smart Contracts
      3. Pike
      4. Sample Apps
    5. Summary
    6. Concluding Remarks
    7. Next Steps
      1. Now It’s Your Turn
      2. Further Reading
  17. Index

Product information

  • Title: Hands-On Smart Contract Development with Hyperledger Fabric V2
  • Author(s): Matt Zand, Xun Wu, Mark Anthony Morris
  • Release date: September 2021
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781492086123