mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 15:35:09 +00:00
Update test network docker compose network name (#423)
Signed-off-by: Nikhil Gupta <ngupta@symbridge.com>
This commit is contained in:
parent
15275a0d4d
commit
3714bd5ad5
5 changed files with 49 additions and 50 deletions
|
|
@ -10,10 +10,10 @@ While a more detailed 'explainer' of the Commercial Paper scenario (including us
|
|||
|
||||
<details><summary>Key Objectives </summary>
|
||||
|
||||
* see a Commercial Paper use case in action
|
||||
|
||||
* see a Commercial Paper use case in action
|
||||
|
||||
* 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 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.
|
||||
|
|
@ -22,20 +22,20 @@ While a more detailed 'explainer' of the Commercial Paper scenario (including us
|
|||
</details>
|
||||
|
||||
<details><summary>Blockchain: benefits to Commercial Paper marketplaces?</summary>
|
||||
|
||||
|
||||
* replace long-winded, time consuming processing between multiple organisations - the network makes it one centralized hub and helps simplify workflow.
|
||||
|
||||
|
||||
* full transparency, traceability and ownership of issued papers
|
||||
|
||||
|
||||
* speed up a process that can take days - e. make same-day issuance a reality, or even a market paradigm.
|
||||
|
||||
|
||||
* in asset-backed commercial paper markets, blockchain can help increase accessibility (to a marketplace) to SMEs to partake in issuance, where otherwise it was inaccessible.
|
||||
|
||||
|
||||
* integration to other areas, like supply chain finance
|
||||
|
||||
|
||||
</p>
|
||||
</details>
|
||||
|
||||
|
||||
|
||||
Expand the twisty below to see an overview diagram of a 'sample' Commercial paper marketplace - transactions, queries being executed by different organisations (we'll focus on two of these organisations)
|
||||
|
||||
|
|
@ -45,14 +45,14 @@ While a more detailed 'explainer' of the Commercial Paper scenario (including us
|
|||
|
||||
</p>
|
||||
</details>
|
||||
|
||||
|
||||
But first, it might useful to explain Commercial Paper, an unsecured promissory note issued to obtain capital, and operates in global financial markets. A Commercial Paper instance is represented as an asset with a lifecycle, recorded on the blockchain - transactions change its _state_ (over time) and those transactions, naturally - have _inputs_.
|
||||
|
||||
|
||||
#### Explainers
|
||||
#### Explainers
|
||||
|
||||
<details><summary>Commercial Paper - what is it briefly?</summary>
|
||||
|
||||
|
||||
</br>
|
||||
It is a type of unsecured promissory note, issued by established companies (eg big manufacturers, blue chip corporations) to gain short-term capital - usually no more than 6-9 months. Why? To meet short-term financial obligations. Commercial paper is generally purchased by money market funds and banks - in fact, it becomes a more important investment strategy during financial recessions :-) . A corporation issues a paper (in the form of a promissory note) for specific projects, such as big capital investments, to pay contractors or even to exercise debt restructuring. The tutorial describes MagnetoCorp (car manufacturer) who have landed a huge contract, and will need approx. $5m in capital (payroll obligations), to hire 1000 car workers for at least 6 months (with no car revenues yet - its a financial strain). Underpinning this, of course, is that MagnetoCorp, has every confidence that (say, in 6 months time) it will be in a position to pay out the face value ($5m in this case) when the commercial paper is redeemd by an owner of the paper, upon maturity :-).
|
||||
</p>
|
||||
|
|
@ -61,7 +61,7 @@ It is a type of unsecured promissory note, issued by established companies (eg b
|
|||
<details><summary>Ins and Outs, Attractions of Commercial Paper Investment?</summary>
|
||||
|
||||
</br>
|
||||
Investors (who buy Commercial Paper) are attracted as they agree to buy them at a discount (say $4.94m) on the face value (eg $5m) and moreso, they obtain a higher yield than if they were simply gaining interest in a bank (eg. 2% interest on $4.95m today = $5m in 6 months time). But there is a 'premium' attached, with carrying the risk of a debt/loan that is essentially unsecured (unlike a bank) - which is where credit risk and ratings comes in. As a result, the actual yield from the investment chosen is in effect $10k greater (than pure interest, in the example given).
|
||||
Investors (who buy Commercial Paper) are attracted as they agree to buy them at a discount (say $4.94m) on the face value (eg $5m) and moreso, they obtain a higher yield than if they were simply gaining interest in a bank (eg. 2% interest on $4.95m today = $5m in 6 months time). But there is a 'premium' attached, with carrying the risk of a debt/loan that is essentially unsecured (unlike a bank) - which is where credit risk and ratings comes in. As a result, the actual yield from the investment chosen is in effect $10k greater (than pure interest, in the example given).
|
||||
</p>
|
||||
Once an issuing corporation becomes established in the commercial paper marketplace, it builds a high credit rating (risk affects how much of a premium investors seek and therefore discount accordingly) - in fact, it is often cheaper (for a blue chip company) to draw on a commercial paper than on a bank line of credit. But that rating reflects the issuer's ability to pay back on maturity.
|
||||
</p>
|
||||
|
|
@ -85,13 +85,13 @@ The tutorial exercises the commercial paper asset lifecycle: _issue_, _buy_ ( 1
|
|||
- understanding the _transaction inputs_ for each transaction (some inputs change the asset _state_ - eg. ownership) and some _don't_ (e.g. purchase price) and not part of the asset - but importantly, the _inputs_ for a given transaction are recorded on the blockchain).
|
||||
- understanding the importance of _queries_ such as: asset history, rich queries (criteria matching etc), transaction history (where the inputs are recorded)
|
||||
|
||||
Client applications (CLI based) are used:
|
||||
Client applications (CLI based) are used:
|
||||
|
||||
- to perform the transactions
|
||||
- run queries (Node.js sample only)
|
||||
- examine the transaction inputs (as opposed to _states_) that are written to the ledger after you perform a transaction (using the Node.js listener).
|
||||
|
||||
This sample uses the `test-network` . You’ll act as Isabella, an employee of MagnetoCorp (Org2), who will issue a commercial paper on its behalf. You’ll 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.
|
||||
This sample uses the `test-network` . You’ll act as Isabella, an employee of MagnetoCorp (Org2), who will issue a commercial paper on its behalf. You’ll 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
|
||||
|
|
@ -104,7 +104,7 @@ This `README.md` file is in the `commercial-paper` directory, the source code fo
|
|||
|
||||
1) Install Binaries, Start the Hyperledger Fabric infrastructure
|
||||
|
||||
The Fabric 'test-network' will be used - this has two organizations 'Org1' and 'Org2' DigiBank will be Org1, and MagnetoCorp will be Org2.
|
||||
The Fabric 'test-network' will be used - this has two organizations 'Org1' and 'Org2' DigiBank will be Org1, and MagnetoCorp will be Org2.
|
||||
|
||||
2) Install and Instantiate the Contracts
|
||||
|
||||
|
|
@ -127,7 +127,7 @@ You will need a machine with the following
|
|||
- Java v8 if you want to run Java client applications
|
||||
- Maven to build the Java applications
|
||||
|
||||
You will need to install the `peer` cli binaries and cloned the `fabric-samples` repository. For more information see
|
||||
You will need to install the `peer` cli binaries and cloned the `fabric-samples` repository. For more information see
|
||||
[Install the Samples, Binaries and Docker Images](https://hyperledger-fabric.readthedocs.io/en/latest/install.html) in the Hyperledger Fabric documentation. Once you have installed the cli binaries, ensure you have added the `bin` directory (for your `peer` commands used by scripts below) to your exported `PATH` variable in your `.bashrc` or `.profile` directory (per below). This is important as you will be opening a number of windows which will need PATH set. Finally, check that it finds the `peer` command in your PATH using the `which` command eg.
|
||||
|
||||
```
|
||||
|
|
@ -136,13 +136,13 @@ which peer
|
|||
```
|
||||
|
||||
|
||||
It is advised to have 3 terminal windows (consoles) open;
|
||||
It is advised to have 3 terminal windows (consoles) open;
|
||||
|
||||
* one to monitor the infrastructure
|
||||
* one for MagnetoCorp
|
||||
* one for DigiBank.
|
||||
* one for MagnetoCorp
|
||||
* one for DigiBank.
|
||||
|
||||
Once you've cloned the `fabric-samples` - change to the `commercial-paper` directory in each window.
|
||||
Once you've cloned the `fabric-samples` - change to the `commercial-paper` directory in each window.
|
||||
|
||||
```
|
||||
git clone https://github.com/hyperledger/fabric-samples.git
|
||||
|
|
@ -163,7 +163,7 @@ In one console window, run the network starter script - this will start the two
|
|||
You can re-use this console window if you wish, but it is recommended to run a docker container monitoring script in its own window. This will let you view what Fabric is doing and help diagnose any failures.
|
||||
|
||||
```bash
|
||||
./organization/magnetocorp/configuration/cli/monitordocker.sh net_test
|
||||
./organization/magnetocorp/configuration/cli/monitordocker.sh fabric_test
|
||||
```
|
||||
|
||||
### Setup the Organizations' environments
|
||||
|
|
@ -195,7 +195,7 @@ cd fabric-samples/commercial-paper/organization/digibank
|
|||
|
||||
### Deploy the smart contract to the channel
|
||||
|
||||
You need to perform similar operations for _both_ organizations and for your language choice from the instructions below. For the different contract languages, the steps are very similar - the full set of steps are actually shown in the JavaScript section (see twisty). However, you will perform one or two different initial steps for Java or Go before completing the remaining common steps as instructed in those language sections.
|
||||
You need to perform similar operations for _both_ organizations and for your language choice from the instructions below. For the different contract languages, the steps are very similar - the full set of steps are actually shown in the JavaScript section (see twisty). However, you will perform one or two different initial steps for Java or Go before completing the remaining common steps as instructed in those language sections.
|
||||
|
||||
Note that the commands below make use of the `jq` utility for parsing output - download and install it from [the jq download page](https://stedolan.github.io/jq/download/).
|
||||
|
||||
|
|
@ -225,7 +225,7 @@ peer lifecycle chaincode approveformyorg --orderer localhost:7050 --ordererTLSH
|
|||
--sequence 1 \
|
||||
--tls \
|
||||
--cafile "$ORDERER_CA"
|
||||
|
||||
|
||||
peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name papercontract -v 0 --sequence 1
|
||||
```
|
||||
|
||||
|
|
@ -265,7 +265,7 @@ peer lifecycle chaincode commit -o localhost:7050 \
|
|||
--ordererTLSHostnameOverride orderer.example.com \
|
||||
--channelID mychannel --name papercontract -v 0 \
|
||||
--sequence 1 \
|
||||
--tls --cafile "$ORDERER_CA" --waitForEvent
|
||||
--tls --cafile "$ORDERER_CA" --waitForEvent
|
||||
|
||||
```
|
||||
|
||||
|
|
@ -325,7 +325,7 @@ peer lifecycle chaincode approveformyorg --orderer localhost:7050 --ordererTLSH
|
|||
--sequence 1 \
|
||||
--tls \
|
||||
--cafile "$ORDERER_CA"
|
||||
|
||||
|
||||
peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name papercontract -v 0 --sequence 1
|
||||
```
|
||||
|
||||
|
|
@ -365,7 +365,7 @@ peer lifecycle chaincode commit -o localhost:7050 \
|
|||
--ordererTLSHostnameOverride orderer.example.com \
|
||||
--channelID mychannel --name papercontract -v 0 \
|
||||
--sequence 1 \
|
||||
--tls --cafile "$ORDERER_CA" --waitForEvent
|
||||
--tls --cafile "$ORDERER_CA" --waitForEvent
|
||||
|
||||
```
|
||||
|
||||
|
|
@ -400,7 +400,7 @@ Before the `peer lifecycle chaincode package` command step, you will need to cha
|
|||
go mod vendor
|
||||
```
|
||||
|
||||
Then complete the steps below.
|
||||
Then complete the steps below.
|
||||
|
||||
|
||||
Running in MagnetoCorp contract directory:
|
||||
|
|
@ -425,7 +425,7 @@ peer lifecycle chaincode approveformyorg --orderer localhost:7050 --ordererTLSH
|
|||
--sequence 1 \
|
||||
--tls \
|
||||
--cafile "$ORDERER_CA"
|
||||
|
||||
|
||||
peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name papercontract -v 0 --sequence 1
|
||||
```
|
||||
|
||||
|
|
@ -465,7 +465,7 @@ peer lifecycle chaincode commit -o localhost:7050 \
|
|||
--ordererTLSHostnameOverride orderer.example.com \
|
||||
--channelID mychannel --name papercontract -v 0 \
|
||||
--sequence 1 \
|
||||
--tls --cafile "$ORDERER_CA" --waitForEvent
|
||||
--tls --cafile "$ORDERER_CA" --waitForEvent
|
||||
|
||||
```
|
||||
|
||||
|
|
@ -514,7 +514,7 @@ npm install
|
|||
|
||||
The docker containers don't contain the node or Java runtimes; so it is best to exit the docker containers - but keep the windows open and run the applications locally.
|
||||
|
||||
As mentioned earlier in the Sample introduction section, transaction _inputs_ are recorded on the ledger, as well as any asset _state_ changes. Just *before* you run the _issue_ application script below - you need to launch a block 'listener' application that will show you these _inputs_, as you complete each transaction in the commercial paper lifecycle (eg. Paper Number: 00001, 00002 etc) .
|
||||
As mentioned earlier in the Sample introduction section, transaction _inputs_ are recorded on the ledger, as well as any asset _state_ changes. Just *before* you run the _issue_ application script below - you need to launch a block 'listener' application that will show you these _inputs_, as you complete each transaction in the commercial paper lifecycle (eg. Paper Number: 00001, 00002 etc) .
|
||||
|
||||
For the listener, its best to open a *new* terminal for this in the `commercial-paper/organization/magnetocorp/application` directory (javascript). Next, run the `addToWallet` step in the `issue` transaction below, to add Isabella's identity to the wallet - the listener will use this wallet. Once the listener is launched, it will show the inputs for transactions you will perform and which are committed to blocks (ie part of the ledger). Note: initially, the listener may show a spurious message, and then go into a _listening_ or 'wait' state. As transactions complete below, messages will be displayed by the listener - so keep an eye out. *After* adding Isabella's wallet, you can then launch the listener as follows:
|
||||
|
||||
|
|
@ -524,9 +524,9 @@ node cpListener.js
|
|||
|
||||
**<details><summary>Issue the commercial paper</summary>**
|
||||
|
||||
The paper is issued by *MagnetoCorp*
|
||||
The paper is issued by *MagnetoCorp*
|
||||
|
||||
You can now run the applications to issue the commercial paper. Change to either the
|
||||
You can now run the applications to issue the commercial paper. Change to either the
|
||||
`commercial-paper/organization/magnetocorp/application` directory (javascript) or `commercial-paper/organization/magnetocorp/application-java` directory (java)
|
||||
|
||||
*Add the Identity to be used to the wallet*
|
||||
|
|
@ -553,7 +553,7 @@ Don't forget to check the application listener for messages above!
|
|||
|
||||
**<details><summary>Buy the commercial paper</summary>**
|
||||
|
||||
_Buy_ is performed as *Digibank*;
|
||||
_Buy_ is performed as *Digibank*;
|
||||
|
||||
You can now run the applications to buy the paper. Change to either the
|
||||
`commercial-paper/organization/digibank/application` directory or `commercial-paper/organization/digibank/application-java`
|
||||
|
|
@ -614,23 +614,23 @@ java -cp target/commercial-paper-0.0.1-SNAPSHOT.jar org.digibank.Redeem
|
|||
|
||||
|
||||
**<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. As indicated, the query transactions mentioned are presently only available in the Node.js sample.
|
||||
|
||||
|
||||
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)
|
||||
- Ownership of Commercial Papers
|
||||
- Partial Key query, for Commercial papers in org.papernet.papers namespace belonging to MagnetoCorp
|
||||
- Named Query: all redeemed papers in a state of 'redeemed' (currentState = 4)
|
||||
- Named Query: all commercial papers with a face value > $4m
|
||||
|
||||
|
||||
From the `digibank/application` subdirectory run:
|
||||
|
||||
|
||||
```
|
||||
node queryapp.js
|
||||
node queryapp.js
|
||||
```
|
||||
|
||||
|
||||
</p>
|
||||
</details>
|
||||
|
||||
|
|
@ -640,7 +640,7 @@ When you're done with this section, return to the terminal where your Node.js _l
|
|||
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:
|
||||
|
||||
```
|
||||
./network-clean.sh
|
||||
./network-clean.sh
|
||||
```
|
||||
|
||||
<sup>[_back to top_](#top)</sup>
|
||||
|
|
|
|||
|
|
@ -33,4 +33,4 @@ cp "${DIR}/../test-network/organizations/peerOrganizations/org2.example.com/user
|
|||
cp "${DIR}/../test-network/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/keystore/"* "${DIR}/../test-network/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/keystore/priv_sk"
|
||||
|
||||
echo Suggest that you monitor the docker containers by running
|
||||
echo "./organization/magnetocorp/configuration/cli/monitordocker.sh net_test"
|
||||
echo "./organization/magnetocorp/configuration/cli/monitordocker.sh fabric_test"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ version: '2'
|
|||
networks:
|
||||
basic:
|
||||
external:
|
||||
name: net_test
|
||||
name: fabric_test
|
||||
|
||||
services:
|
||||
cliDigiBank:
|
||||
|
|
@ -34,5 +34,4 @@ services:
|
|||
- ./../../../../organization/digibank:/opt/gopath/src/github.com/
|
||||
- ./../../../../../test-network/organizations:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
|
||||
networks:
|
||||
- basic
|
||||
|
||||
- test
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ version: '2'
|
|||
networks:
|
||||
basic:
|
||||
external:
|
||||
name: net_test
|
||||
name: fabric_test
|
||||
|
||||
services:
|
||||
cliMagnetoCorp:
|
||||
|
|
@ -34,4 +34,4 @@ services:
|
|||
- ./../../../../organization/magnetocorp:/opt/gopath/src/github.com/
|
||||
- ./../../../../../test-network/organizations:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
|
||||
networks:
|
||||
- basic
|
||||
- test
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
# More information at https://github.com/gliderlabs/logspout/tree/master/httpstream
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
DOCKER_NETWORK=net_test
|
||||
DOCKER_NETWORK=fabric_test
|
||||
else
|
||||
DOCKER_NETWORK="$1"
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in a new issue