Advanced Blockchain Technology: Frameworks and Enterprise-Level Practices

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

This book is a must-have for blockchain developers who want to learn from scratch how to leverage blockchain technology in a real-world setting. The first section provides a brief overview of blockchain technology, including its concepts, history, technology genre, major related companies and typical application scenarios, and presents an ecological map for the blockchain industry by comparing and analyzing some mainstream platforms. The second section systematically introduces Ethereum and HyperLedger, exemplars of well-known open-source blockchain platforms, and demonstrates how to conduct blockchain applications development based on the two platforms. The third section illustrates core technology of enterprise blockchain platforms (to take Hyperchain, an independent, controllable blockchain alliance as an example), and covers Hyperchain based enterprise blockchain applications development technology. The fourth section presents 6 actual blockchain-based applications examples, and analyzes applications development procedure and related key codes. Examples in this book are of great practicability and operability, allowing practitioners to get started easily, and eventually utilize these skills to develop real-life, usable blockchain applications.

Author(s): Liang Cai, Qilei Li, Xiubo Liang
Publisher: Springer
Year: 2022

Language: English
Pages: 434
City: Singapore

Foreword 1
Building an Independent and Controllable Alliance Blockchain, Opening Up a New Horizon for the Development of Fintech
Foreword 2
Building a New Multi-party Business Collaboration Platform Using Blockchains
Preface
Book Structure
Example Code and Errata
Acknowledgments
Contents
Part I: Blockchain Basics
Chapter 1: Introduction to Blockchain Basics
1.1 Blockchain Basics
1.1.1 From Bitcoin to Blockchain
1.1.2 Definition of Blockchain
Blockchain Data Structure
Distributed Consensus Algorithm
Cryptography
1.1.3 Blockchain-Related Concepts
Distributed Ledger
Cryptography and Authorization Technology
Consensus Mechanism
Smart Contract
1.1.4 Classification of Blockchain
Public Chain
Consortium Chain
Private Chain
1.2 Blockchain Development History
1.2.1 Technology Origins
1.2.2 Blockchain 1.0: ``Digital Currency´´
1.2.3 Blockchain 2.0: Smart Contracts
1.2.4 Blockchain 3.0: Beyond ``Currency,´´ Economy, and Market
1.3 Key Technologies of Blockchain
1.3.1 Basic Model
1.3.2 Data Layer
Block Structure
Merkle Tree
Asymmetric Encryption and Digital Signatures
1.3.3 Network Layer
P2P Network Architecture
Transmission Mechanism
Authentication Mechanism
1.3.4 Consensus Layer
PoW (Proof-of-Work) Mechanism
PoS (Proof of Stake) Mechanism
DPoS (Proof of Share Authority) Mechanism
PBFT (Practical Byzantine-Fault-Tolerance) Algorithm
Raft (Channel Trustworthy) Consensus Algorithm
1.3.5 Incentive Layer
Issuance Mechanism
Distribution Mechanisms
1.3.6 Contract Layer
1.4 Status Quo of Blockchain Industry
1.4.1 Blockchain Development Trends
1.4.2 Government-Driven Blockchain
1.4.3 Ecological Mapping of Blockchain
1.5 Blockchain Application Scenarios
1.5.1 Digital Bills
1.5.2 Supply Chain Finance
1.5.3 Accounts Receivable
1.5.4 Data Trading
1.5.5 Bond Trading
1.5.6 Block Trading
1.5.7 Cross-Border Payment
1.5.8 Other Scenarios
1.6 Mainstream Blockchain Platforms
1.7 Summary
Part II: Open Source Blockchain Platforms
Chapter 2: In-Depth Interpretation of Ethereum
2.1 Basics Introduction to Ethereum
2.1.1 History of Ethereum Development
2.1.2 Basic Ethereum Concepts
2.1.3 The Ethereum Client
Go-ethereum
Browser-Solidity (Remix)
Parity
Ethereum Wallets
2.1.4 Ethereum Account Management
Using the geth Command Line
Using the geth Console
2.1.5 Ethereum Network
2.2 The Core Principle of Ethereum
2.2.1 Ethereum Consensus Mechanism
2.2.2 Ethereum Virtual Machine
2.2.3 Ethereum Data Storage
2.2.4 Ethereum Encryption Algorithm
2.3 Ethereum Smart Contracts
2.3.1 Introduction to Smart Contracts and Solidity
2.3.2 Smart Contract Programming and Deployment
Solidity-Hello World
Document Layout and Contract Structure
Data Types and State Variables
Type of Boolean
Integer Type
Address
Byte Arrays
String
Arrays
Mapping/Dictionary
Function Calls
Internal Calls
External Function Calls
Named Parameter Calls
Function Visibility
Pure/View Functions
Events
Special Variables
Ethereum ``Currency Unit´´
Time Units
Block and Transaction Attributes
Contract Deployment
2.3.3 Smart Contract Testing and Execution
Truffle Suite Ganache
Truffle Test Example Analysis
2.3.4 Smart Contract Example Analysis
2.4 History, Problems, and Future Development of Ethereum
2.4.1 Historical Events
The DAO Attack
Replay Attack
The Birth of EEA
Parity Wallet Bug
2.4.2 Current Problems of Ethereum
Inefficient Consensus
Lack of Privacy Protection
Large-Scale Data Storage Difficulties
Information Difficult to Regulate
2.4.3 Ethereum 2.0
Beacon Chain
Sharding
eWASM
Casper FFG
2.5 Summary
Chapter 3: Fundamentals of Ethereum: Application Development
3.1 Building an Ethereum Development Environment
3.1.1 Configuring the Ethereum Environment
Install Go Environment
Installing Node.js and npm
Installing Brew
Installing Ethereum
Installing the solc Compiler
3.1.2 Building an Ethereum Private Chain
Create Accounts (Public Key)
Write the Original Block File
Initialize the Original Block
Configure the Script to Unlock the Accounts Automatically
Write the Ethereum Startup Script
Initiating Mining
3.2 Ethereum Remix IDE
3.2.1 Compiling Smart Contracts
3.2.2 Obtaining Bytecode and ABI Files
3.2.3 Testing Contract Methods
3.3 Ethereum Programming Interface
3.3.1 jSON-RPC
Smart Contracts
Compiling the Contract
Bytecode
abiDefinition
Obtaining the Calling Account
View the Ethers in the Current Account
Deploying the Contract
Calling the Contract Method
Find Transaction Details by Transaction Hash
3.3.2 JavaScript API
Compiling the Contract
Deploying the Contract
Calling Contract Methods
3.4 DApp Development Framework and Process
3.4.1 Meteor
Install Meteor
Loading the Ethereum web3 Module
Calling the Ethereum web3.js Interface
Deploying DApp Applications
3.4.2 Truffle
Truffle Installation
Truffle Project Creation
Smart Contract Compilation and Deployment
Client Application Running
3.4.3 Layered Extensible Development Process
Underlying Storage
Back-End Systems
Upper Layer Client
3.5 The First Ethereum Application
3.5.1 Optimizing the MetaCoin Application
Verify the Validity of the Account Address
Feedback Prompt When MetaCoin Is Insufficient
3.5.2 MetaCoin Code in Detail
Implementation of index.html
Implementation of Contract Code
Implementation of index.js
3.6 Deploying to the Ethereum Public Chain (Mainnet)
3.6.1 Infura
3.6.2 Project Configuration
3.6.3 Deploying MetaCoin
3.7 Summary
Chapter 4: In-Depth Interpretation of Hyperledger Fabric
4.1 Project Introduction
4.1.1 Project Background
4.1.2 Project Introduction
Fabric
Iroha
Sawtooth Lake
Blockchain Explorer
Cello
4.2 Introduction to Fabric
4.3 Core Concepts
4.3.1 Anchor Nodes
4.3.2 Access Control List
4.3.3 Blocks
4.3.4 Blockchain
4.3.5 Smart Contracts
4.3.6 Channels
4.3.7 Submit
4.3.8 Concurrent Control Version Checking
4.3.9 Configuration Blocks
4.3.10 Consensus
4.3.11 Consent Setting
4.3.12 Consortium
4.3.13 World State
4.3.14 Dynamic Membership Management
4.3.15 Genesis Blocks
4.3.16 Gossip Protocol
4.3.17 The Ledger
4.3.18 Followers
4.3.19 Leaders
4.3.20 Principal Peer Node
4.3.21 Logging
4.3.22 Membership Service Provider
4.3.23 Membership Management Service
4.3.24 Sorting Service or Ordering Service
4.3.25 Organization
4.3.26 Node
4.3.27 Policy
4.3.28 Private Data
4.3.29 Private Data Set
4.3.30 Raft
4.4 Architecture Details
4.4.1 Architecture Interpretation
4.4.2 Membership Services
PKI System
User/Client Registration Process
Out-of-Band Process
Online Process
4.4.3 Blockchain Services
The P2P Network
Ordering Service
Distributed Ledger
4.4.4 Chaincode Services
4.5 Chaincode Analysis
4.5.1 Chaincode Overview
4.5.2 Chaincode Structure
Chaincode Interface
API Methods
Chaincode Return Information
4.5.3 CLI Command Line Calls
4.5.4 Chaincode Execution Swimlane Diagram
4.6 Transaction Flow
4.6.1 General Process
4.6.2 Process Details
The Client Sends the Transaction Proposal to the Specified Endorsement Node
PROPOSE Message Format
Message Mode
Endorsement Node Simulates Transaction Execution and Generates Endorsement Signature
The Client Collects the Transaction Endorsement and Broadcasts It Through the Ordering Service
The Ordering Service Transmits the Block to the Peer Node
4.6.3 Endorsement Strategies
4.6.4 Verifying the Ledger and PeerLedger Checkpoints
4.7 Summary
Chapter 5: Application Development: Fundamentals of Hyperledger Fabric
5.1 Environment Deployment
5.1.1 Software Download and Installation
Oracle VM VirtualBox
Vagrant
Git
5.1.2 Setting Up Development Environment
5.1.3 Go and Docker
Go Language Environment
Docker Environment
5.2 Chaincode Development Guide
5.2.1 Interface Introduction
5.2.2 Case Study
initMarble Initialize Data
readMarble Query Marbles Data
transferMarble
transferMarblesBasedOnColor
5.2.3 Introduction to Private Data
Writing Private Data
Read Private Data
5.3 CLI Application Examples
5.3.1 Preparation
5.3.2 Writing the Code
5.3.3 Initiate Network and Chaincode Calls
5.3.4 Switching on the Network Manually
5.4 SDK Application Examples
5.4.1 Introduction to the SDK
5.4.2 SDK Application Development
Write the Code
Application Operation
5.5 Summary
Part III: The Enterprise-Level Blockchain Platform Hyperchain
Chapter 6: Anatomy of the Core: Principles of Enterprise-Level Blockchain Platform
6.1 Hyperchain Overall Architecture
6.2 Basic Components
6.2.1 Consensual Algorithm
RBFT Overview
RBFT Routine Process
RBFT View Replacement
RBFT Auto-Recovery
RBFT Node Addition and Deletion
6.2.2 Network Communication
Communication Principles
Node Type
Flow Control Mechanism
6.2.3 Smart Contracts
Smart Contract Execution Engine
HyperEVM
HyperJVM
HVM
HyperVM Design Principles
HyperVM Execution Flow
6.2.4 Ledger Data Storage Mechanism
Blockchain
Contract Status
Merkle Tree
6.3 Expand Components
6.3.1 Privacy Protection
Partitioned Consensus
Privacy Transaction
Encrypted On-Chain/Hashed On-Chain
Contract Access Control
6.3.2 Encryption Mechanism
Hash Algorithm
ECDSA-Based Transaction Signatures
ECDH-Based Key Negotiation
Ciphertext Transmission Based on Symmetric Encryption
Transport Layer Security
State-Secret Support
6.3.3 Member Management
CA System
Certificate Management
Certification Issuance
Node Access
Certificate Checking
Certificate Revocation
Key Management
6.3.4 Blockchain Governance
Hyperchain Implements Blockchain Governance Through Confederation Autonomy and Node Permission Management
Permissions Management
6.3.5 Message Subscription
System Design
Concrete Implementation
6.3.6 Data Management
Data Visualization
Data Archiving
6.3.7 Verification Based on Hardware Acceleration
6.4 Summary
Chapter 7: Hyperchain Application Development Fundamentals
7.1 Platform Functionality
7.1.1 Platform Interaction
7.1.2 Transaction Calls
7.1.3 Contract Management
7.1.4 Block Queries
7.2 Platform Deployment
7.2.1 Hyperchain Configuration
peerconfig.json: Configure Node IP and Port Number
pbft.yaml: Configure the Consensus Algorithm
global.yaml: Global Configuration
LICENSE: Hyperchain Certificate of Authority
7.2.2 Hyperchain Deployment
LICENSE Document
Network Configuration File host.toml
Network Configuration File addr.toml
Logical Network Configuration File peerconfig.toml
Global Configuration File global.toml
7.2.3 Hyperchain Operation
Communication Anomalies
ViewChange Exception
Ignore Duplicate Exception
7.3 The First Hyperchain Application
7.3.1 Writing Smart Contracts
7.3.2 Deployment and Contract Invocation
7.4 Summary
Part IV: Blockchain Applications and Use Cases
Chapter 8: Ethereum Application and Case Studies
8.1 Case Study of Ethereum-Based Generic Points System
8.1.1 Project Introduction
8.1.2 System Function Analysis
8.1.3 General System Design
Solution Selection
Ethereum Client
Development Framework
Ethereum Interface
Overall Architecture
8.1.4 Smart Contract Design
Tool Contract
Contract State Design
Contract Method Design
Constructors
Customer/Merchant Registration
Judge Whether the Customer/Merchant Is Registered
Customer/Merchant Login
Issue Scores
Transfer Scores
Post Goods
Purchase Goods
8.1.5 System Implementation
Establish Projects
Detailed Implementation
Connecting to Ethereum
Customer/Merchant Registration
Customer/Merchant Login
Issue Scores
Transfer Scores
Post Goods
Purchase Items
8.1.6 System Deployment
Project Configuration
Contract Configuration
Overall Configuration
Project Deployment
8.2 Case Study of an Ethereum-Based E-Coupon System
8.2.1 Project Introduction
8.2.2 System Functional Analysis
8.2.3 General System Design
Scheme Design
System Architecture Design
System Data Storage Division
8.2.4 Smart Contract Design
Outline Design
Contract Status Design
Bank Contract
Merchant Contract
Consumer Contract
Coupon Contract
Contract Method Design
Construct Method
Bank Contract
Merchant Contract
Consumer Contract
Coupon Contract
Functional Methods
Settlement Coupon Correlation
Coupon Correlation
Coupon Issuance
Coupon Termination
Coupon Distribution
Coupon Payment
Consumer Transfer
Reading Blockchain Stored Data
8.2.5 System Implementation and Deployment
System Deployment Diagram
Hardware and Software Environment Deployed
Software Environment
Hardware Environment
Blockchain Environment Construction
Install Curl Command
Install the Go Environment (Go Version 1.5.1 Is Installed Here)
Configure Go´s Environment Variables
Install Node.js.npm
Verify Node.js.npm
Install Ethereum
Install solc
Create Accounts (Public Key)
Write the Founding Block File
Initialize the Founding Block
Configure the Script to Unlock the Accounts Automatically
Write Ethereum Startup Script
Deploy the Bank Contract and Get the abi File
8.3 Summary
Chapter 9: Hyperledger Fabric Application Case Studies in Detail
9.1 Case Study of a Fabric-Based Social Culture Heritage Management Platform
9.1.1 Project´s Background Analysis
9.1.2 System Functional Analysis
9.1.3 General System Design
Overall Thought
Application Architecture
9.1.4 General Design of Smart Contracts
9.1.5 Core Functional Contract Design
Objects in Smart Contracts
Initialization Methods for Smart Contracts
New Transactions
Read Transaction Log Information
Search for Relics Transaction Records
9.1.6 Tool Contract Design
9.1.7 Deployment Implementation
Pre-Installation Preparation
Chaincode Operations
9.2 Case Study of a High-End Fabric-Based Food Safety System
9.2.1 Background Analysis
9.2.2 Solution Proposal
9.2.3 System Functional Analysis
Overall Functional Diagram
System Function Description
9.2.4 General System Design
Overall System Architecture
System Flow Chart
9.2.5 API Design
9.2.6 Smart Contract Design
Core Functional Contract Design
Contract Objects in Smart Contracts
Initialization Methods for Smart Contracts
Smart Contract Invoke Method
User Registration
Delete User
Registration of Foodstuffs
Food Establishment
Distribution of Foodstuffs
Food Distribution
User Inquiry, Food Ingredient Inquiry, and Food Delivery Inquiry
Foodstuffs Circulation Records Search and Food Circulation Records Search
9.2.7 Leveraging the Node.js SDK
9.2.8 Deployment Implementation
Network Configuration
Encryption Configuration
Channel Configuration
Start All Containers
Backup Configuration File to Host 2
Operating Mainframe 2
Return to Host 1 to Instantiate the Chaincode
Test with the Console
9.3 Summary
Chapter 10: Use Cases and Detailed Explanation of Enterprise-Level Blockchain
10.1 Case Study of Hyperchain-Based Accounts Receivable Management System
10.1.1 Project Introduction
10.1.2 System Functional Analysis
Electronic Voucher Issuance for Accounts Receivable
Accounts Receivable Transfer for Payment
Accounts Receivable Financing
10.1.3 General System Design
General Idea
Application Architecture
Display Module
Core Business Module
Data Storage Module
Associated System Modules
Main Function Design
Deployment Architecture
10.1.4 Smart Contract Design
Outline Design
Contract Design
Contract Method Design
Functional Methods
10.1.5 System Security Design
10.2 Case Study of Hyperchain-Based Ride-Hailing Platform
10.2.1 Project Introduction
10.2.2 System Functional Analysis
Passenger Function Analysis
Identity System
Positioning System
Order System
Payment System
Evaluation System
Driver Function Analysis
Identity System
Positioning System
Order System
Payment System
Evaluation System
Function Analysis of Third-Party Payment Platform
10.2.3 General System Design
Business Logic Design
Itinerary Business Logic
Payment Business Logic
System Architecture Design
Business Layer
Payment Layer
Interface Layer
Blockchain Layer
10.2.4 Smart Contract Design
Conceptual Design
Payment Contract Design
Constructors
Permission Controllers
Registration Function
Record Function
Transfer Function
Query Function
Taxi Contract Design
Constructor
Private Functions
Passenger Submits an Order
Driver Order-Grabbing
Prepayment from Passengers
Driver Picks Up Passenger
Real-Time Billing
Complete the Order
Cancellation Function
Passenger Evaluation
Driver Registration
Query Function
10.2.5 System Implementation and Deployment
System Deployment Diagram
System Deployment Environment
Hardware Environment
Software Environment
Blockchain Environment Construction
Install Git
Install Curl
Install and Configure Go Language Environment
Get the Blockchain Executable Binary
Start the Blockchain
10.3 Summary