0%

Learn to develop blockchain-based distributed ledgers and deploy a Hyperledger Fabric network with concrete exercises and examples

Key Features

  • Updated with the latest features and additions that come with Hyperledger Fabric 2
  • Write your own smart contracts and services using Java and JavaScript on a Hyperledger Fabric network
  • Dive into real-world blockchain challenges such as integration and scalability

Book Description

Blockchain with Hyperledger Fabric - Second Edition is a refreshed and extended version of the successful book on practical Hyperledger Fabric blockchain development. This edition includes many new chapters, alongside comprehensive updates and additions to the existing ones. Entirely reworked for Hyperledger Fabric version 2, this edition will bring you right up to date with the latest in blockchain. Using a real-world Trade Finance and Logistics example, with working code available on GitHub, you'll really understand both how and why Hyperledger Fabric can be used to maximum effect. This book is your comprehensive guide and reference to explore and build blockchain networks using Hyperledger Fabric version 2.

This edition of the book begins by outlining the evolution of blockchain, including an overview of relevant blockchain technologies. Starting from first principles, you'll learn how to design and operate a permissioned blockchain network based on Hyperledger Fabric version 2. You will learn how to configure the main architectural components of a permissioned blockchain network including Peers, Orderers, Certificate Authorities, Channels, and Policies. You'll then learn how to design, develop, package, and deploy smart contracts, and how they are subsequently used by applications. This edition also contains chapters on DevOps, blockchain governance, and security, making this your go-to book for Hyperledger Fabric version 2.

What you will learn

  • Discover why blockchain is a technology and business game changer
  • Set up blockchain networks using Hyperledger Fabric version 2
  • Understand how to create decentralized applications
  • Learn how to integrate blockchains with existing systems
  • Write smart contracts and services quickly with Hyperledger Fabric and Visual Studio Code
  • Design transaction models and smart contracts with Java, JavaScript, TypeScript, and Golang
  • Deploy REST gateways to access smart contracts and understand how wallets maintain user identities for access control
  • Maintain, monitor, and govern your blockchain solutions

Who this book is for

This book is designed in such a way that professionals from different areas including business leaders, technology leaders, blockchain application developers, and even beginners can benefit from it.

Table of Contents

  1. Preface
    1. Who this book is for
    2. What this book covers
    3. Downloading the example code
    4. Conventions used
    5. Get in touch
    6. Reviews
  2. Blockchain – An Enterprise and Industry Perspective
    1. Our focus for the new edition
    2. Defining the terms – what is blockchain?
    3. Design considerations for blockchain solutions
    4. Four core building blocks
    5. Additional capabilities to consider
    6. Fundamentals of the secure transaction processing protocol
    7. Where blockchain technology has been and where it's going
    8. The great divide
    9. An economic model for blockchain delivery
    10. Learning as we go
    11. The promise of trust and accountability
    12. Blockchain in the enterprise
    13. What applications are a good fit?
    14. Enterprise blockchain business evaluation considerations
    15. A few thoughts on blockchain business models
    16. Business growth and innovation
    17. How do growth and innovation relate to a blockchain-powered network?
    18. Considerations for evaluating the economic value of blockchain entities
    19. Blockchain investment rubric
    20. How does the enterprise view blockchain?
    21. Integrating a blockchain infrastructure for the whole enterprise
    22. Enterprise design principles
    23. Business drivers and evolution
    24. Ensuring the sustainability of blockchain-based business networks
    25. Design principles that drive blockchain adoption
    26. Business considerations for choosing a blockchain framework
    27. Technology considerations for choosing a blockchain framework
    28. Identity management
    29. Scalability
    30. Enterprise security
    31. Development tooling
    32. Crypto-economic models
    33. Decentralization with systemic governance
    34. Enterprise support
    35. Use case-driven pluggability choices
    36. Shared ledger technology
    37. Consensus
    38. Crypto algorithms and encryption technology
    39. Enterprise integration and designing for extensibility
    40. Other considerations
    41. Consensus, ACID properties, and CAP
    42. Attestation – SSCs are signed and encrypted
    43. Use of HSMs
    44. Summary
    45. References
  3. Exploring Hyperledger Fabric
    1. Building on the foundations of open computing
    2. Fundamentals of the Hyperledger project
    3. The Linux Foundation
    4. Hyperledger
    5. Open source and open standards
    6. Hyperledger frameworks, tools, and building blocks
    7. Hyperledger distributed ledger frameworks
    8. Hyperledger libraries
    9. Hyperledger tools
    10. The building blocks of blockchain solutions
    11. Hyperledger Fabric component design
    12. Principles of Hyperledger design
    13. Hyperledger Fabric reference architecture
    14. Hyperledger Fabric runtime architecture
    15. Strengths and advantages of a componentized design
    16. Hyperledger Fabric – the journey of a sample transaction
    17. Actors and components in a Hyperledger Fabric network
    18. Actors in a blockchain network
    19. Components in a blockchain network
    20. Developer interaction
    21. CAP theorem
    22. New features covered in this book
    23. Summary
  4. Business Networks
    1. A busy world of purposeful activity
    2. Why a language for business networks?
    3. Defining a business network
    4. Introducing participants
    5. Types of participant
    6. Individual participants
    7. Organizational participants
    8. System or device participants
    9. A participant is an agent
    10. Participant identity
    11. Introducing assets
    12. Assets flow between participants
    13. Tangible and intangible assets
    14. The structure of assets
    15. Ownership
    16. A special kind of relationship
    17. Ownership and asset tokenization
    18. Asset life cycles
    19. Describing a life cycle with transactions
    20. Introducing transactions
    21. Change and transactions
    22. Transaction definition and instance
    23. Implicit and explicit transactions
    24. The importance of contracts
    25. Signatures
    26. Smart contract multi-party transactions
    27. Digital transaction processing
    28. Initiating transactions
    29. Transaction history
    30. Transaction streams
    31. A network of networks
    32. Current value and transaction history
    33. A business network as a history of transactions
    34. Regulators
    35. Introducing events
    36. A universal concept
    37. Event notifications
    38. An event example
    39. Events and transactions
    40. External and explicit events
    41. Loosely coupled design
    42. Events are useful!
    43. Business network technology
    44. More dematerialization
    45. The blockchain benefit
    46. Interacting with a blockchain
    47. Organizational structure
    48. Technical componentry
    49. Participants
    50. APIs
    51. Application tier
    52. Smart contract
    53. Ledger
    54. Peer
    55. Ordering service
    56. Network channel
    57. Identity
    58. Summary
  5. Setting the Stage with a Business Scenario
    1. Trading and letters of credit
    2. The importance of trust in facilitating trade
    3. The letter of credit process today
    4. Business scenario and use case
    5. Overview
    6. Real-world processes
    7. Simplified and modified processes
    8. Terms used in trade finance and logistics
    9. Shared process workflow
    10. Shared assets and data
    11. Participants' roles and capabilities
    12. Advantages of blockchain applications over current real-world processes
    13. Designing and configuring a Hyperledger Fabric trade network
    14. Designing a network
    15. Installing prerequisites
    16. Setting up the development/test environment
    17. Testing the IBP extension
    18. Forking and cloning the trade-network repository
    19. Creating and running a network configuration
    20. Preparing the network
    21. Generating network cryptographic material
    22. Generating channel artifacts
    23. Composing a sample trade network
    24. Network components' configuration files
    25. Configuring peer databases
    26. Launching a sample trade network
    27. Configuring our development environment for network operations
    28. Creating Fabric identity wallets
    29. Creating a Fabric environment
    30. Creating a node file
    31. Creating and connecting to a Fabric environment in VS Code
    32. Summary
  6. Designing Smart Contract Transactions and Ledger Data Structures
    1. Architecture of the trade solution
    2. Starting the contract development
    3. Opening and packaging a contract
    4. Deploying a contract in the testing environment
    5. Invoking and debugging a contract
    6. Creating a contract
    7. The contract interface
    8. Implementing the contract
    9. Access control
    10. ABAC
    11. Registering a user
    12. Enrolling a user
    13. Access control in the contract
    14. Implementing contract functions
    15. Scenario contracts' functions
    16. Defining contract assets
    17. Coding contract functions
    18. Creating an asset
    19. Reading and modifying an asset
    20. Testing a contract
    21. Creating a test suite file
    22. Defining a test suite
    23. Unit tests
    24. Running tests in the terminal
    25. Running tests in VS Code
    26. Advanced contract design topics
    27. Cross-contract and cross-ledger invocation
    28. Composite keys
    29. Range and composite key queries
    30. State queries and CouchDB
    31. Indexes
    32. History queries
    33. Transaction mechanisms
    34. The ReadSet and WriteSet
    35. Multiversion concurrency control
    36. Logging output
    37. Configuration
    38. Logging API
    39. Standard output and error
    40. Additional API functions
    41. Summary
  7. Developing Smart Contracts
    1. Business networks
    2. Solution application components
    3. The transaction ledger and multi-party transactions
    4. Smart contracts
    5. Applications
    6. Network channels
    7. The multi-party transaction
    8. Transaction type
    9. Transaction identifier
    10. Proposal
    11. Response
    12. Valid and invalid transactions
    13. The ledger
    14. State database
    15. State
    16. State collections
    17. Blockchain
    18. Immutable blocks and transactions
    19. Immutability
    20. Primacy of the blockchain
    21. Smart contracts
    22. A central role in the network
    23. Smart contracts and consensus
    24. Writing a smart contract
    25. Smart contract structure
    26. Contract class and transaction methods
    27. Elaborating a smart contract
    28. Writing smart contract transaction methods
    29. Marshalling the transaction proposal input
    30. Accessing the ledger to generate a transaction response
    31. Accessing the state database
    32. Returning a signed transaction response
    33. Checking that business objects exist
    34. Transaction handlers
    35. Other functionality available in fabric-contract-api
    36. Annotations
    37. Packaging smart contracts
    38. A word on terminology
    39. Smart contract package definition agreement
    40. Programming language
    41. Choice of programming language
    42. Using a type system
    43. Modularity – a big idea in Hyperledger Fabric
    44. Endorsement policy
    45. The structure of an endorsement policy
    46. Network agreement
    47. Why endorsement?
    48. Endorsement policy – a separate concern
    49. State-based endorsement
    50. Collection endorsement policy
    51. Summary
  8. Developing Applications
    1. Applications
    2. The three basic application operations
    3. The application SDK
    4. Declarative APIs and the fabric-network package
    5. Separating the physical from the logical
    6. Querying the ledger
    7. Submitting a new transaction
    8. The process
    9. How the SDK makes consensus easy
    10. Requesting ledger notification
    11. Wallets and identity
    12. Using an identity
    13. Using a wallet
    14. Gateways
    15. Why gateways are useful
    16. Discovery
    17. A network view for an application
    18. Accessing networks and smart contracts
    19. Single network gateway
    20. Multi-network gateway
    21. Querying the ledger
    22. Smart contract packaging and namespaces
    23. Using EvaluateTransaction to query the ledger
    24. Separating the logical from the physical
    25. Synchronous and asynchronous queries
    26. Query in a more complex topology
    27. Submitting a new transaction
    28. The other organizations in the network
    29. What it means to evaluate and submit a transaction
    30. The network topology doesn't matter!
    31. Atomic transactions within and across networks
    32. Combining transactions in a single unit of work
    33. Events and notifications
    34. Transactions, events, and smart contracts
    35. Transactions and events
    36. Smart contracts and events
    37. Event listening and notification
    38. Listening – how it works
    39. Asynchronous responses
    40. Summary
  9. Advanced Topics for Developing Smart Contracts and Applications
    1. Customizing SDK behavior
    2. Connection options to the rescue
    3. Event handler functions
    4. Checkpoint handler
    5. Transient data
    6. Explicitly recording transaction input
    7. Hiding the transaction input
    8. Private data
    9. Using private data collections
    10. Smart contract exploitation
    11. Private data with transient data
    12. Understanding private data collections
    13. Private data consensus and off-chain data
    14. Private data collections and verifiability
    15. Recapping on styles
    16. The verify-style transaction
    17. Applications, organizations, and private data
    18. Private data consensus
    19. The insert-style transaction
    20. The most important trade
    21. Insert-style smart contract
    22. Insert-style application transaction submission
    23. Read your own writes
    24. Collection and state endorsements policy
    25. Levels of endorsement policy
    26. A note on collection policies
    27. The transfer-style transaction
    28. The createInfo transaction
    29. The transferInfo transaction
    30. The updateInfo transaction
    31. The transfer-style application transaction submission
    32. Summarizing smart contracts, transactions, and applications
    33. Advanced smart contract packaging
    34. Multi-definition packages
    35. Functional packaging
    36. Summary
  10. Network Operation and Distributed Application Building
    1. Stages in a Fabric network's life cycle
    2. Fabric application model and architecture
    3. Fabric application development overview
    4. Architecture of a Fabric application for trade
    5. Operations – network setup and bootstrap
    6. Operations overview – channel and contract setup
    7. Prerequisites – creating all channel artifacts
    8. Creating all channel artifacts
    9. Launching the network
    10. Overview of Fabric tools and commands
    11. Creating channels
    12. Using the trade.sh script as a shortcut
    13. Verifying block creation
    14. Joining organization peers to channels
    15. Setting organization anchor peers on channels
    16. Running all channel operations in one go
    17. Installing and initializing contracts
    18. Using CLI tools to install and initialize contracts
    19. Installing contracts using the VS Code IBP extension
    20. Developing service-layer applications
    21. Application runtime life cycle
    22. An application for the importer's organization
    23. Importer application structure
    24. Project dependencies
    25. Setting application properties and generating a connection profile
    26. Designing a service API for the importer application
    27. User registration, login, and session management
    28. User roles and access control
    29. Fabric registration, enrolment, and identity wallets
    30. Contract invocations through gateways
    31. Launching and testing the application
    32. Event management
    33. Exercising the application through a presentation layer
    34. Launching applications
    35. An end-to-end scenario – trade request to final payment
    36. Users and their credentials
    37. Registering users
    38. Logging in users
    39. Requesting a trade as an importer
    40. Accepting a trade as an exporter
    41. Requesting a letter of credit as an importer
    42. Issuing a letter of credit as an importer's bank
    43. Accepting a letter of credit as an exporter's bank
    44. Requesting an export license as an exporter
    45. Issuing an export license as a regulator
    46. Preparing a shipment as an exporter
    47. Accepting a shipment and issuing a bill of lading as a carrier
    48. Requesting a partial payment as an exporter's bank
    49. Making a partial payment as an importer's bank
    50. Delivering a shipment as a carrier
    51. Requesting the balance payment as an exporter's bank
    52. Making the balance payment as an importer's bank
    53. Viewing the list of active or processed trades as an importer
    54. Using a production-grade ordering service
    55. Summary of key steps
    56. Summary
  11. Enterprise Design Patterns and Considerations
    1. Design considerations
    2. Managing heterogeneity
    3. Process alignment
    4. Message affinity
    5. Service discovery
    6. Identity mapping
    7. Integration design patterns
    8. Integrating with an existing system of record
    9. Integrating with an operational data store for blockchain analytics
    10. Microservice and event-driven architecture
    11. Resiliency and fault tolerance
    12. Reliability and availability
    13. Serviceability
    14. Summary
  12. Agility in a Blockchain Network
    1. Defining the promotion process
    2. Aligning the promotion process to components
    3. Smart contract considerations
    4. Integration layer considerations
    5. Continuous integration
    6. Promotion process overview
    7. Configuring a CI pipeline
    8. Customizing the pipeline process
    9. Publishing our smart contract package
    10. Configuring your GitHub repository
    11. Setting the code owners of our smart contract
    12. Protecting the master branch
    13. Configuring Git for commit signing and validation
    14. Configuring GPG on your local workstation
    15. Testing considerations for the trade network
    16. Unit testing
    17. Defining our user story and business scenarios
    18. Test fixture
    19. Mapping scenarios to Mocha
    20. Implementing unit tests
    21. Integration testing
    22. Setting up the integration tests
    23. Testing the trade business process
    24. Running the integration tests
    25. Exercising the end-to-end process
    26. Creating a new transaction
    27. Adding the mergeTrade unit test
    28. Submitting a pull request with a signed commit
    29. Releasing the new version
    30. Continuous delivery
    31. Kubernetes as a platform for Hyperledger Fabric
    32. Infrastructure as Code and Ansible
    33. Deployment process overview
    34. Centralization versus decentralization
    35. Notifying the consortium
    36. Applying these concepts to our network
    37. Setting up Ansible
    38. Starting the network using Ansible
    39. Pulling a new chaincode release
    40. Upgrading the network
    41. Summary
  13. Governance – A Necessary Evil of Regulated Industries
    1. Decentralization and governance
    2. Exploring business models
    3. Blockchain benefits
    4. Supply chain management
    5. Healthcare
    6. Letters of credit
    7. From benefits to profits
    8. B2B and B2C considerations
    9. Network business models
    10. Founder-led networks
    11. Consortium-based networks
    12. Community-based networks
    13. Hybrid models
    14. Funding models
    15. Token-based models
    16. Traditional models
    17. Membership considerations
    18. Governance of a business network
    19. Mapping business roles to blockchain roles
    20. Governance structure
    21. Centralized governance
    22. Exploring the levels of governance
    23. Mapping governance to organizational structure
    24. Decentralized governance
    25. Business domains and processes
    26. Membership life cycle
    27. Funding and fees
    28. Regulation
    29. Education
    30. Service life cycle
    31. Disputes
    32. Blockchain as a governance tool
    33. Managing network policies
    34. Types of policies
    35. Organization level versus network level
    36. Consortiums
    37. Channels
    38. Endorsements
    39. Summary
  14. Life in a Blockchain Network
    1. Modifying or upgrading a Hyperledger Fabric application
    2. Changing requirements and update modes
    3. Fabric blockchain and application life cycle
    4. Network organization resource updates
    5. Adding a peer to an organization
    6. Installing a smart contract on a new peer
    7. Removing a peer from an organization
    8. Channel configuration updates
    9. Adding a new organization to a live network
    10. Prerequisites for adding a new organization to the network
    11. Generating cryptographic material for the new organization
    12. Generating channel artifacts for the new organization
    13. Generating the cryptographic and channel artifacts in one operation
    14. Docker containers for the new organization
    15. Launching network components for the new organization
    16. Updating the channel configuration
    17. Joining the new organization's peer to the channels
    18. Setting the anchor peer for the new organization's peer on the channels
    19. Installing contracts on peers in the new organization
    20. Smart contract and policy updates
    21. Overview of contract update procedures
    22. Modification in contract business logic
    23. Endorsement policy updates
    24. Upgrading contract code and endorsement policies on the channels
    25. Augmenting the distributed application
    26. Platform upgrades
    27. Upgrading a live four-organization trade network
    28. System monitoring and performance
    29. Measurement and analytics
    30. Fabric system measurement considerations
    31. Metrics for performance analysis
    32. Fabric application performance measurement and data collection
    33. Measuring system health indicators
    34. Fabric support for component monitoring
    35. Profiling containers and applications
    36. Measuring application performance
    37. Fabric engineering guidelines for performance
    38. Platform performance characteristics
    39. System bottlenecks
    40. Configuration and tuning
    41. Ledger data availability and caching
    42. Fabric performance measurement and benchmarking
    43. Summary
  15. Hyperledger Fabric Security
    1. Hyperledger Fabric design goals impacting security
    2. Hyperledger Fabric architecture
    3. Fabric CA or membership service provider
    4. Peer
    5. Smart contracts
    6. Ledger
    7. Private data
    8. Ordering node
    9. History of the ordering service in Hyperledger Fabric
    10. Network bootstrap and data governance: the first step toward security
    11. Bootstrapping the network with known members
    12. Defining the process for sharing data
    13. Defining the data model of the shared data
    14. Mapping data sharing needs Hyperledger-based mechanisms for operational agility
    15. Adding new members to the network (or channel)
    16. Deploying, instantiating, and upgrading smart contracts on peers in the network
    17. Strong identities: the key to the security of the Hyperledger Fabric network
    18. Bootstrapping Fabric CA
    19. Register
    20. Enroll
    21. Revoking identities
    22. Practical considerations in managing users in Fabric CA
    23. Smart contract security
    24. How is a smart contract shared with other endorsing peers?
    25. Who can install smart contracts?
    26. Smart contract encryption
    27. Attribute-based access control
    28. Common threats and how Hyperledger Fabric mitigates them
    29. Hyperledger Fabric and quantum computing
    30. GDPR considerations
    31. Summary
  16. Blockchain's Future, Protocol Commercialization, and Challenges Ahead
    1. Summary of key Hyperledger projects
    2. Hyperledger frameworks: business blockchain technology
    3. Distributed ledger frameworks
    4. Hyperledger libraries
    5. Hyperledger tools
    6. Blockchain's future and the challenges ahead
    7. Addressing the divide: the enterprise blockchain and cryptoasset-driven ecosystem
    8. Interoperability: understanding business service integration
    9. Blockchain protocol commercialization: a "BizTech" agenda
    10. Layer 1 – Foundational trust and transaction layer
    11. Layer 2 – Protocol optimization layer
    12. Layer 3 – Blockchain business service layer
    13. Layer 4 – Industry/business application layer
    14. Adjunct business layer
    15. Devising modularity to avoid lock-in linkages
    16. Scalability and economic viability of blockchain solutions
    17. How can you help and stay engaged?
    18. Summary
  17. Another Book You May Enjoy
  18. Index
34.239.170.244