Add further README changes from #335

Signed-off-by: Paul O'M <mahoney@uk.ibm.com>
This commit is contained in:
Paul O'M 2020-11-22 14:25:36 +00:00
parent 3ad52d5ec3
commit 63a4856b38

View file

@ -4,7 +4,7 @@
## Introduction ## Introduction
This folder contains a structured set of smart contracts and application clients (ie. in a choice of languages, eg Node.JS, Java, Go etc) relating to *Commercial Paper*, a finance 'instrument' (in Global Finance). The sample contract also provide a range of queries to try out, to consolidate what you learn when you execute transactions during the tutorial. This folder contains a structured set of smart contracts and application clients (ie. in a choice of languages, eg Node.JS, Java, Go etc) relating to *Commercial Paper*, a finance 'instrument' (in Global Finance). At present, the Node.JS sample contract in particular has further added functionality: an optional two-step authority check (see diagram below), when redeeming a commercial paper instance -and a range of sample ledger queries, to help consolidate your learning - both can be explored using the Node.js application client.
While a more detailed 'explainer' of the Commercial Paper scenario (including use case analysis, code walkthrough & practices, logical/physical representation of ledger data etc) can be found in the [Hyperledger Fabric Commercial Paper Tutorial](https://hyperledger-fabric.readthedocs.io/en/latest/tutorial/commercial_paper.html), you don't have to read through this, just to try out this sample. There's also a [Wikipedia page](https://en.wikipedia.org/wiki/Commercial_paper) While a more detailed 'explainer' of the Commercial Paper scenario (including use case analysis, code walkthrough & practices, logical/physical representation of ledger data etc) can be found in the [Hyperledger Fabric Commercial Paper Tutorial](https://hyperledger-fabric.readthedocs.io/en/latest/tutorial/commercial_paper.html), you don't have to read through this, just to try out this sample. There's also a [Wikipedia page](https://en.wikipedia.org/wiki/Commercial_paper)
@ -14,7 +14,7 @@ While a more detailed 'explainer' of the Commercial Paper scenario (including us
* explore the key 'takeaways': understand differences between asset _state_ changes ('e.g. 'lifecycle') and transaction _inputs_* (e.g. 'inputs' during lifecycle) * explore the key 'takeaways': understand differences between asset _state_ changes ('e.g. 'lifecycle') and transaction _inputs_* (e.g. 'inputs' during lifecycle)
* try out a number of different query types: asset history, asset state, ownership, partial key, named query (criteria-based), ad-hoc queries (you supply a query) * try out a number of different query types: asset history, asset state, ownership, partial key, named query (criteria-based), ad-hoc queries (you supply a query string) - presently available in the Node.JS sample only.
\* the smart contract uses these (along with business logic) to decide outcomes; some inputs change the asset _state_ (like 'ownership') ; some don't. \* the smart contract uses these (along with business logic) to decide outcomes; some inputs change the asset _state_ (like 'ownership') ; some don't.
@ -88,10 +88,10 @@ The tutorial exercises the commercial paper asset lifecycle: _issue_, _buy_ ( 1
Client applications (CLI based) are used: Client applications (CLI based) are used:
- to perform the transactions - to perform the transactions
- run queries - run queries (using the Node.JS client sample)
- examine the transaction inputs (as opposed to _states_) that are written to the ledger after you perform a transaction. - examine the transaction inputs (as opposed to _states_) that are written to the ledger after you perform a transaction (using the Node.JS listener).
It uses the `test-network` (which is part of Fabric Samples). Youll act as Isabella, an employee of MagnetoCorp (Org2), who will issue a commercial paper on its behalf. Youll then switch hats to take the role of Balaji, an employee of DigiBank (Org1), who will buy this commercial paper, hold it for a period of time, and then redeem it with MagnetoCorp for a small profit or yield. Then later, you'll query the ledger - that's it :-) This sample uses the `test-network` . Youll act as Isabella, an employee of MagnetoCorp (Org2), who will issue a commercial paper on its behalf. Youll then 'switch hats' to take the role of Balaji, an employee of DigiBank (Org1), who will buy this commercial paper, hold it for a period of time, and then redeem it with MagnetoCorp for a small profit or yield. Note that the smart contract sample doesn't enforce the actual hold period ; the user can, in fact, redeem the paper immediately.
## Quick Start ## Quick Start
@ -123,7 +123,7 @@ This `README.md` file is in the `commercial-paper` directory, the source code fo
You will need a machine with the following You will need a machine with the following
- Docker and docker-compose installed - Docker and docker-compose installed
- Node.js v12 if you want to run JavaScript client applications - Node.JS v12 if you want to run JavaScript client applications
- Java v8 if you want to run Java client applications - Java v8 if you want to run Java client applications
- Maven to build the Java applications - Maven to build the Java applications
@ -209,6 +209,9 @@ Running in MagnetoCorp directory:
# MAGNETOCORP # MAGNETOCORP
peer lifecycle chaincode package cp.tar.gz --lang node --path ./contract --label cp_0 peer lifecycle chaincode package cp.tar.gz --lang node --path ./contract --label cp_0
# or for the Java contract sample:
# peer lifecycle chaincode package cp.tar.gz --lang java --path ./contract-java --label cp_0
peer lifecycle chaincode install cp.tar.gz peer lifecycle chaincode install cp.tar.gz
export PACKAGE_ID=$(peer lifecycle chaincode queryinstalled --output json | jq -r '.installed_chaincodes[0].package_id') export PACKAGE_ID=$(peer lifecycle chaincode queryinstalled --output json | jq -r '.installed_chaincodes[0].package_id')
@ -229,13 +232,16 @@ peer lifecycle chaincode approveformyorg --orderer localhost:7050 --ordererTLSH
peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name papercontract -v 0 --sequence 1 peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name papercontract -v 0 --sequence 1
``` ```
Running in Digibank Running in Digibank directory:
``` ```
# DIGIBANK # DIGIBANK
peer lifecycle chaincode package cp.tar.gz --lang node --path ./contract --label cp_0 peer lifecycle chaincode package cp.tar.gz --lang node --path ./contract --label cp_0
# or for the Java contract sample:
# peer lifecycle chaincode package cp.tar.gz --lang java --path ./contract-java --label cp_0
peer lifecycle chaincode install cp.tar.gz peer lifecycle chaincode install cp.tar.gz
export PACKAGE_ID=$(peer lifecycle chaincode queryinstalled --output json | jq -r '.installed_chaincodes[0].package_id') export PACKAGE_ID=$(peer lifecycle chaincode queryinstalled --output json | jq -r '.installed_chaincodes[0].package_id')
@ -613,11 +619,11 @@ java -cp target/commercial-paper-0.0.1-SNAPSHOT.jar org.digibank.Redeem
</details> </details>
**<details><summary>Perform Queries: Ownership, Asset History etc</summary>** **<details><summary>Perform Queries: Ownership, Asset History etc (Node.JS sample only) </summary>**
Having completed the full commercial paper lifecycle for one paper (paper number: 00001) some queries below won't show a lot of data - as an optional exercise, you can change the scripts above (paper number: 00002) to create another paper lifecycle and run the `queryapp` application below (change query 1 to the new CP number FYI), with more data available. Having completed the full commercial paper lifecycle for one paper (paper number: 00001) some queries below won't show a lot of data - as an optional exercise, you can change the scripts above (paper number: 00002) to create another paper lifecycle and run the `queryapp` application below (change query 1 to the new CP number FYI), with more data available. As indicated, the query transactions mentioned are presently only available in the Node.JS sample.
Execute the following query script, which will run the following 5 queries, in order: Execute the Node.JS application client script, which will run the following 5 queries, in order:
- History of Commercial Paper (Note: the paper state is shown more descriptively eg. 'ISSUED', 'TRADING' and based on currentState values on ledger) - History of Commercial Paper (Note: the paper state is shown more descriptively eg. 'ISSUED', 'TRADING' and based on currentState values on ledger)
- Ownership of Commercial Papers - Ownership of Commercial Papers
@ -634,7 +640,7 @@ java -cp target/commercial-paper-0.0.1-SNAPSHOT.jar org.digibank.Redeem
</p> </p>
</details> </details>
When you're done with this section, return to the terminal where your _listener_ application is running, and terminate the process. When you're done with this section, return to the terminal where your Node.JS _listener_ application is running, and terminate the process.
## Clean up ## Clean up
When you are finished using the Fabric test network and the commercial paper smart contract and applications, you can use the following command to clean up the network: When you are finished using the Fabric test network and the commercial paper smart contract and applications, you can use the following command to clean up the network: