Building Enterprise Blockchain Solutions on AWS
US$ 19.95
The publisher has enabled DRM protection, which means that you need to use the BookFusion iOS, Android or Web app to read this eBook. This eBook cannot be used outside of the BookFusion platform.
Description
Contents
Reviews
Language
English
ISBN
9789390684434
Cover Page
Title Page
Copyright Page
Dedication Page
About the Author
About the Reviewer
Acknowledgement
Preface
Errata
Table of Contents
1. An Introduction to a Blockchain
Structure
Objectives
Challenges with the traditional centralized infrastructure
What is a blockchain?
Cryptographically secured
Immutability
Distributed ledger
Decentralized
Smart contract
How a blockchain works
Consensus mechanism algorithms
Public blockchain
Bitcoin
Ethereum
Current challenges with a public blockchain
Private and permissioned blockchain
Public versus a private blockchain
Blockchain use-cases
Criteria to choose a blockchain
Blockchain use-cases
Conclusion
Points to remember
Multiple choice questions
Answers
Questions
Key Terms
2. Exploring a Blockchain on AWS
Structure
Objectives
Amazon managed blockchain
Problems with self-hosting a blockchain network
What is an Amazon managed blockchain?
Advantages of an Amazon managed blockchain
When to use
Who is using an Amazon managed blockchain?
AWS blockchain templates
What are AWS blockchain templates?
Ethereum template
Hyperledger fabric template
When to use
Amazon Quantum Ledger Database
Why QLDB?
What is QLDB?
Advantages of QLDB
When to use
Who is using?
AWS blockchain partners
Why AWS blockchain partners
What are AWS blockchain partners?
Who are the AWS blockchain partners?
Conclusion
Points to remember
Multiple choice questions
Answer
Questions
Key terms
3. Exploring the Amazon Quantum Ledger Database
Structure
Objectives
Pre-requisites for this chapter
Record keeping
Current challenges with record-keeping
Auditing in a bank
Exploring QLDB
What is QLDB?
How QLDB works?
Building a record-keeping database with QLDB for bank auditing
Record-keeping database architecture
Steps in building a record-keeping database for a bank
Step 1: Create a new ledger:
Step 2: Creating tables
Creating a customer table
Creating an Account table
Creating a Tx table
Creating a Loan table
Creating a LoanPayment table
Creating a Tax table
Step 3: Creating Indexes
Creating an index for the Customer table
Creating an index for the Account table
Creating an index for the Tx table
Creating an index for the Loan table
Creating an index for the LoanPayment table
Creating an index for the Tax table
Step 4: Inserting data
Inserting data into the Banker table:
Inserting data into Customer table:
Inserting data into the Account table:
Inserting data into the Tx table:
Inserting data into the Loan table:
Inserting data into the LoanPayment table:
Inserting data into the Tax table:
Step 5: Querying a table
Querying the sample data from the Customer table from the Bank-RecordKeeping ledger
Step 6: Updating the table data
Step 7: Deleting the table data
Step 8: Viewing the history of changes
Step 9: Auditor verifying bank transactions
Exporting journal data
Streaming journal data
Conclusion
Points to remember
Multiple choice questions
Answers
Questions
Key Terms
4. Exploring Hyperledger Fabric
Structure
Objectives
Hyperledger Fabric overview
Features of Hyperledger Fabric
When to use Hyperledger Fabric
Hyperledger Fabric architecture
Hyperledger Fabric workflow
Hyperledger Fabric model
Assets
Ledger
Smart contract - chaincode
Channels
Membership service provider
Gossip protocol
Consensus
Hyperledger Fabric network components
What are organizations in the network?
Understanding of peers
Understanding of a client node
Understanding of endorsing peers
Understanding of an ordering service
Understanding of an Anchor peer
Conclusion
Points to remember
Multiple choice questions
Answer
Questions
Key Terms
5. AWS Managed Blockchain to Create Fabric Network
Structure
Objectives
Pre-requisites for this chapter
Understanding of Amazon managed blockchain
What is Amazon managed blockchain?
How Amazon managed blockchain works?
Healthcare supply chain project overview
Current challenges in the health care supply chain
Blockchain use-case in healthcare
Healthcare supply chain project work flow
Healthcare supply chain project code
Healthcare supply chain project architecture
Stages in building the healthcare supply chain project
Fabric network architecture with AWS Managed Blockchain
Network architecture for the healthcare supply chain project
Network architecture for the Manufacturer member
Steps in building the Hyperledger Fabric network
Step 1 – Provisioning an AWS Cloud9 instance
Steps to provision an AWS Cloud9 instance as follows:
Step 2 – Creating a Fabric network on the AWS console with AWS Managed Blockchain
Steps to create a Fabric Network as follows:
Step 3 – Creating the manufacturer peer node
Steps to create the Manufacturer peer node:
Step 4 – Provisioning a Fabric client node using the Cloud Formation template in a Cloud9 instance
Steps to create the Manufacturer peer node:
Step 5 - ssh into the Fabric client node
Steps to ssh into the Fabric client node:
Step 6 – Configuring an environment variable in the Fabric client node
Steps to configure the environment variables:
Step 7 – Enrolling an admin identity
Steps to enroll an admin identity:
Step 8 - Updating the configtx channel configuration
Steps to update the configtx channel configuration:
Step 9 - Creating a Fabric channel
Steps to create a Fabric channel:
Step 10 - Joining the Manufacturer peer node to myChannel
Conclusion
Points to remember
Multiple choice questions
Answer
Questions
Key terms
6. Developing the Chaincode, API, and UI with the Fabric SDK on AWS
Structure
Objectives
Pre-requisites for this chapter
Explore a chaincode
Understanding of a chaincode
Chaincode use-cases
Understanding of the Fabric Node.js SDK
Installing fabric-shim
Writing the chaincode
Let's understand the chaincode with the sample code
Understanding the chaincode lifecycle
Installing the chaincode on your peer node
Instantiating the chaincode on the channel
Querying the chaincode
Invoking a transaction
Upgrading the chaincode
Steps to install the latest version of the balance transfer:
Identify chaincode functions for the healthcare supply chain project
Writing the healthcare chaincode with the Node.js SDK
Step 1: Create a healthcare chaincode file and import libraries
Step 2: Create asset states
Step 3: Write the Init function
Step 4: Write the Invoke function
Step 5: Write the function to create a manufacturer
Step 6: Write a function to create a medical asset
Step 7: Write a function to create a distributor
Step 8: Write a function to create a hospital
Step 9: Write a function to create a pharmacy
Step 10: Write a function to get asset details
Step 11: Write a function to transfer the asset ownership
Step 12: Write a function to dispose of an asset
Step 13: Write a function to delete an asset
Step 14: Add the healthcare chaincode to shim
Installing and instantiating healthcare chaincode on the peer
Step 1 - Copy the chaincode into the CLI container
Step 2 - Install the healthcare chaincode on your peer
Step 3 - Instantiate the healthcare chain code on the channel
Interacting with the healthcare chaincode
Invoking healthcare chaincode functions
Step 1: Create a manufacturer
Step 2: Create an asset
Step 3: Create a distributor
Step 4: Create a hospital
Step 5: Create a pharmacy
Querying healthcare chaincode functions
Transferring the ownership of a medical asset
Step 1 – Transfer to a distributor
Step 2 – Transfer to a hospital
Step 3 – Transfer to a pharmacy
Step 4 – Check the current asset owner; it should be a pharmacy
Step 5 – Transfer to a customer
Step 6 – Recall the asset
Step 7 – Dispose of an expired medical asset
Step 8 – Delete an asset from the world state
Creating the API to interact with the chaincode
Understanding the fabric-client Fabric Node.js SDK
Express.js API project structure
Running the REST API on the Fabric Client node
Testing the healthcare API
Designing the UI application for the healthcare supply chain project
Conclusion
Points to Remember
Multiple choice questions
Answers
Questions
Key terms
7. Adding Members to the Fabric Network on AWS
Structure
Objectives
Pre-requisites for this chapter
Fabric network architecture for manufacturer and distributor
Steps for members to join and participate in the Fabric network
Inviting distributor member organization
Distributor member joining the Fabric network
Step 1 – Provisioning an AWS Cloud9 instance for the distributor
Steps to provision an AWS Cloud9 instance
Step 2 – Creating a distributor member in AWS Managed Blockchain
Steps to create distributor member
Step 3 – Creating a distributor peer node
Steps to create a manufacturer peer node
Step 4 – Provisioning Fabric Client node using CloudFormation template in Cloud9 instance
Steps to create Manufacturer peer node
Step 5 – ssh into the Fabric Client node
Step 6 – Configuring the environment variable in the Fabric Client node
Steps to configure the environment variables
Step 7 – Enrolling admin identity
Steps to enroll admin identity
Step 8 – Share distributor public key with the manufacturer
Configuring the network to add a new distributor member
Step 1 – Creating an MSP folder for the distributor
Step 2 – Updating the configtx channel configuration to include the distributor member
Step 3 – Generating a channel configuration for the distributor
Step 4 – Endorsing peer signing new channel configuration
Step 5 – Update the channel with the new configuration
Step 6 – Sharing genesis block with the distributor
Step 7 – Copying genesis block to the distributor
Instantiating and running healthcare chaincode on the distributor
Step 1 – Starting peer node on the distributor
Step 2 – Copying chaincode
Step 3 – Installing chaincode
Step 4 – Instantiating chaincode
Step 5 – Invoking chaincode functions
Step 6 – Get channel information
Step 7 – Invoke chaincode with the preceding peer address details
Endorsing distributor transaction from the manufacturer
Step 1 – Manufacturer updating endorsement policy
Step 2 – Update endorsement policy
Step 3 – Distributor updates chaincode
Step 4 – Verify from distributor account
Step 5 – Querying chaincode functions
Adding hospital and pharmacy organization
Conclusion
Points to remember
Multiple choice questions
Answer
Questions
Key terms
8. Deep Dive into Ethereum Blockchain
Structure
Objectives
Ethereum platform
Ethereum peer-to-peer network
Features of Ethereum blockchain
Ethereum virtual machine
Ethereum accounts
Externally-owned account (accounts)
Contract account (contracts)
Ether denominations
Gas and transactions
What is Gas in Ethereum?
Terms within Gas
What are transactions in Ethereum?
Examples of a transaction
Calculating transaction cost
Ethereum public network
Ethereum production network - MainNet
Understanding of Ethereum client
List of Ethereum clients
Installing Geth
Exploring Ethereum blockchain with Etherscan
Exploring Ethereum blockchain with Ethstats
Ethereum test networks - TestNet
Ethereum private and permissioned network
Private network
Permissioned network
Exercise - Transferring Ether between accounts
Step 1 – Add MetaMask wallet in Chrome browser
Step 2 – Create an Ethereum account in MetaMask
Step 3 – Get fake Ether to one account
Step 4 – Create a recipient account
Step 5 – Initiate the transaction by mentioning the Gas and recipient address
Step 6 – Check the transaction status in Etherscan
Step 7 – Check Account 2 balance
Conclusion
Points to remember
Multiple choice questions
Answer
Questions
Key terms
9. AWS Blockchain Template to Create Private Ethereum
Structure
Pre-requisites for this chapter
Steps to create a key pair
AWS Blockchain templates for Ethereum
Benefits of AWS blockchain templates
AWS Ethereum template network architecture
Ethereum network architecture with ECS container platform
Create a VPC and subnets
Create Elastic IP address
Create VPC, one public, and one private Subnet
Create a second public subnet in different Availability zone
Create security groups
Creating a security group for EC2 instance
Creating a Security Group for Load Balancer
Adding Inbound rules for an EC2 security group
Editing outbound rules for Load Balancersecurity group
Create an IAM Role
Creating IAM role for ECS
Creating an EC2 instance profile
Creating a policy
Creating a role
Creating Bastion host
Creating Linux instance
Provision private Ethereum network
Connecting to EthStats and EthExplorer using the Bastion host
Connecting to AWS Ethereum network with Metamask
Conclusion
Points to remember
Multiple choice questions
Answer
Questions
Key Terms
10. Solidity Smart Contract Language
Structure
Objectives
Understanding smart contract
Smart contract
Where to use smart contract
Solidity - a smart contract language for Ethereum
Solidity files and compiler
Solidity editor - Remix
Create, compile, deploy and run your first smart contract
Exploring data types
Value types
Value types supported in solidity
boolean
int
address
bytes
enums
Referencetypes
array
string
mapping
struct
Functions
Public
Private
Internal
External
View
Pure
Payable
Function modifiers
Conditional statements
If else decision control
Loops
while
for
do while
break
continue
Constructors
Inheritance
Polymorphism
Abstract contracts
Interfaces
Libraries
Error handling
require
assert
revert
Events andlogging
Conclusion
Points to remember
Multiple choice questions
Answer
Questions
Key terms
11. Create and Deploy Asset Tracker Contract on AWS
Structure
Objectives
Pre-requisites for this chapter
Asset Management
Asset
Challenges with current asset management solutions
Advantages of building asset management in blockchain
Asset tracker project
Ganache - setup local blockchain network
Installing Ganache
Truffle framework - setup asset tracker project
Installing Truffle
Creating AssetTracker project
Web3.js - Ethereum JavaScript API
Installing web3.js
Creating participants contracts
Creating a manufacturer contract
Creating a shipper contract
Creating a dealer contract
Creating a buyer contract
Creating asset contract
Creating the main contract - AssetTracker contract
Compiling all the contract
Configure deployment script
Running the AssetTracker smart contract
Truffle develop
Creating a contract instance
Getting Ethereum accounts with web3.js
Creating participants
Creating a vehicle asset
Transfer vehicle
Deploying AssetTransfer contact to the AWSEthereum private network
Approach 1 – Deploy AsssetTracker contract with Remix online tool
Approach 2 – Deploy the AsssetTracker contract with Truffle
Conclusion
Points to remember
Multiple choice questions
Answer
Questions
Key Terms
12. Testing and Interacting with Asset Tracker on AWS
Structure
Objectives
Pre-requisites for this chapter
Unit testing of the Asset Tracker smart contract
Identify the application behavior to write test cases
Creating a test file
Initializing the test file
Writing tests to validate the behavior
Run all the tests with the Truffle test
web3.js
Installing web3.js
Initiating web3
web3 modules and functions
Building the frontend application with HTML, CSS, and Node.js
Adding UI and JavaScript files to the project
Writing app.js to interact with the Asset Tracker contract
Creating the application object
Initializing the web3 provider
Instantiating the contract
Function to create a manufacturer
Function to create a shipper
Function to create a dealer
Function to create a buyer
Function to create an asset
Function to transfer an asset
Writing the index.html page
Running the application against AWS
Conclusion
Points to remember
Multiple choice questions
Answers
Questions
Key terms
Index
Loading...