Skip to content
This repository has been archived by the owner on Mar 8, 2020. It is now read-only.

Commit

Permalink
Doc Fixes (#3364)
Browse files Browse the repository at this point in the history
Add new tutorials to the tutorial list
Update the banner

Signed-off-by: Caroline Church <[email protected]>
  • Loading branch information
cazfletch committed Feb 8, 2018
1 parent 766d26e commit 843c97a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 45 deletions.
2 changes: 1 addition & 1 deletion packages/composer-website/jekylldocs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h1>Build Blockchain applications and business networks your way</h1>
</div>
<div class="homepage-callout">
<div class="callout-copy">
<p><strong>Update Feb 1st 2018: </strong>Version 0.17.3 has been released. Please see <a href="https://github.com/hyperledger/composer/releases">the release notes.</a></p>
<p><strong>Update Feb 8th 2018: </strong>Version 0.17.4 has been released. Please see <a href="https://github.com/hyperledger/composer/releases">the release notes.</a></p>
</div>
</div>
<div class="trio">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,21 @@ In order to follow this tutorial, you must start up a fresh {{site.data.conrefs.

2. Download the platform binaries, including cryptogen :

curl -sSL https://goo.gl/6wtTN5 | bash -s 1.1.0-alpha
curl -sSL https://goo.gl/6wtTN5 | bash -s 1.1.0-alpha

Verify the list of docker images downloaded without issues

3. change directory into `first-network` sample

cd first-network
cd first-network

4. Next, start the BYFN network - additional flags (to the `byfn.sh` script below) must be specified, as we're using CouchDB as the world state database (different to that specified on the Fabric BYFN page) - we also want to start a Certificate Authority (CA) for **each** organization.

5. Execute the following commands in sequence from the `first-network` directory:

./byfn.sh -m generate

./byfn.sh -m up -s couchdb -a
./byfn.sh -m generate
./byfn.sh -m up -s couchdb -a

If the command works successfully, the first command will generate Fabric network / security artifacts(see this [link](http://hyperledger-fabric.readthedocs.io/en/release/build_network.html#generate-network-artifacts for more info). Following the second command (above), the BYFN network is started, and verify that you see the following output before proceeding:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ sidebar: sidebars/accordion-toc0.md
# Invoking a {{site.data.conrefs.composer_full}} business network from another business network
{{site.data.conrefs.composer_full}} includes functionality that can be used by a business network to access an asset, participant, or transaction that is recorded in another business network.

This tutorial will demonstrate the steps that a business network developer needs to take in order to invoke a {{site.data.conrefs.composer_full}} business network from a different business network. As part of the tutorial you will deploy the same business network twice. The business networks can be on the same channel or different channels. The business network used in this example will be the tutorial network that is outlined in the [developer tutorial](./developer-tutorial.html). This tutorial will refer to the business networks as "A" and "B"
This tutorial will demonstrate the steps that a business network developer needs to take in order to invoke a {{site.data.conrefs.composer_full}} business network from a different business network. As part of the tutorial you will deploy the same business network twice. The business networks in this tutorial will be on the same channel, but they can be on different channels. The business network used in this example will be the tutorial network that is outlined in the [developer tutorial](./developer-tutorial.html). This tutorial will refer to the business networks as "A" and "B"

## Prerequisites

Expand Down Expand Up @@ -43,27 +43,14 @@ If these commands fail, then you have business network cards from a previous ver

./createPeerAdminCard.sh

## Step Two: Create a second channel (Optional)
## Step Two: Define the business networks
1. Follow steps one and two in the [developer tutorial](./developer-tutorial.html). This will be network A.

The simple network config used in the previous step only creates one channel by default. If business network B is to be deployed to a different channel, then the channel should be created now by using the Hyperledger Fabric operational tools.
2. Follow steps one and two again but create a business network called `other-tutorial-network`. This will be network B.

After the channel has been created a business network card needs to be created to deploy to this channel.

1. Create a connection profile that specifies the second channel

2. To create the business network card run the following commands.

export PRIVATE_KEY=~/fabric-tools/composer/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/keystore/114aab0e76bf0c78308f89efc4b8c9423e31568da0c340ca187a9b17aa9a4457_sk
export CERT=~/fabric-tools/composer/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/signcerts/[email protected]
composer card create -p <Path to profile> -u PeerAdmin -c ${CERT} -k ${PRIVATE_KEY} -r PeerAdmin -r ChannelAdmin --file [email protected]
composer card import -f [email protected] -n otherPeerAdmin@hlfv1

## Step Three: Define the business networks
1. Follow steps one and two in the [developer tutorial](./developer-tutorial.html). If business network A and business network B are being deployed to the same channel then a second business network will need to be created with a different name but with the same model, script and ACL files. This tutorial will assume this will be called `other-tutorial-network`.

2. The transaction logic needs to be updated to query an asset in business network B and then update the quantity property of an asset in business network A.
3. The transaction logic needs to be updated in network A and to query an asset in business network B and then update the quantity property of an asset in business network A.

Replace the contents of the `logic.js` script file to update the transaction processor function to be the following. Where \<CHANNEL\> needs to be replaced with either the name of the channel created in step two, or `composerchannel` if the business networks are on the same channel; and where \<BUSINESS NEWORK NAME\> is either `tutorial-network` if the networks are on different channels, or `other-tutorial-network` if the network are on the same channel.
Replace the contents of the `logic.js` script file to update the transaction processor function to be the following.

/**
* Track the trade of a commodity from one trader to another
Expand All @@ -73,7 +60,7 @@ After the channel has been created a business network card needs to be created t
async function tradeCommodity(trade) {
trade.commodity.owner = trade.newOwner;

const otherNetworkData = await getNativeAPI().invokeChaincode(<BUSINESS NETWORK NAME>, ['getResourceInRegistry', 'Asset', 'org.acme.biznet.Commodity', trade.commodity.tradingSymbol], <CHANNEL>);
const otherNetworkData = await getNativeAPI().invokeChaincode('other-tutorial-network', ['getResourceInRegistry', 'Asset', 'org.acme.biznet.Commodity', trade.commodity.tradingSymbol], 'composerchannel');
const stringAsset = new Buffer(otherNetworkData.payload.toArrayBuffer()).toString('utf8');
const asset = getSerializer().fromJSON(JSON.parse(stringAsset));

Expand All @@ -83,26 +70,16 @@ After the channel has been created a business network card needs to be created t
await assetRegistry.update(trade.commodity);
}

3. Follow step three in the [developer tutorial](./developer-tutorial.html).

4. If business network B is going to be deployed on the same channel as business network A, then repeat steps 1-3 but create a network call `other-tutorial-network`.
4. Follow step three in the [developer tutorial](./developer-tutorial.html).

## Step Four: Deploy the business networks
## Step Three: Deploy the business networks
1. Install and start business network A using the following commands

composer runtime install --card PeerAdmin@hlfv1 --businessNetworkName tutorial-network
composer network start --card PeerAdmin@hlfv1 --networkAdmin admin --networkAdminEnrollSecret adminpw --archiveFile [email protected] --file networkA.card
composer card import --file networkA.card --name networkA
2. Install and start business network B using the following commands

If business network B will be on a different channel:

composer runtime install --card otherPeerAdmin@hlfv1 --businessNetworkName tutorial-network
composer network start --card otherPeerAdmin@hlfv1 --networkAdmin admin --networkAdminEnrollSecret adminpw --archiveFile [email protected] --file networkB.card
composer card import --file networkB.card --name networkB

If business network B will be on the same channel:
2. Install and start business network B using the following commands

composer runtime install --card PeerAdmin@hlfv1 --businessNetworkName other-tutorial-network
composer network start --card PeerAdmin@hlfv1 --networkAdmin admin --networkAdminEnrollSecret adminpw --archiveFile [email protected] --file networkB.card
Expand All @@ -113,7 +90,7 @@ After the channel has been created a business network card needs to be created t
composer network ping --card networkA
composer network ping --card networkB

## Step Five: Create the assets
## Step Four: Create the assets

1. Create a participant in business network A. Run the following command.

Expand All @@ -131,20 +108,20 @@ After the channel has been created a business network card needs to be created t

composer transaction submit --card networkB -d '{"$class": "org.hyperledger.composer.system.AddAsset","registryType": "Asset","registryId": "org.acme.biznet.Commodity", "targetRegistry" : "resource:org.hyperledger.composer.system.AssetRegistry#org.acme.biznet.Commodity", "resources": [{"$class": "org.acme.biznet.Commodity","tradingSymbol": "Ag","owner": "resource:org.acme.biznet.Trader#[email protected]","description": "a lot of gold", "mainExchange": "exchange", "quantity" : 500}]}'
## Step Six: Bind the identity on network A to the participant on network B
## Step Five: Bind the identity on network A to the participant on network B
1. Export the networkA card to get the credentials

composer card export -n networkA

2. Unzip the card
2. Unzip the card, you may need to rename networkA.card to networkA.zip.

3. Bind the identity to the participant. Run the following command.

composer identity bind --card networkB --participantId resource:org.hyperledger.composer.system.NetworkAdmin#admin --certificateFile ./networkA/credentials/certificate

4. Create a card with the bound identity. Where \<PATH TO CONNECTION PROFILE FOR NETWORK B\> should be the one to connect to networkB and \<NAME OF BUSINESS NETWORK B\> should be the name of business network B
4. Create a card with the bound identity.

composer card create -p \<PATH TO CONNECTION PROFILE FOR NETWORK B\> --businessNetworkName <NAME OF BUSINESS NETWORK B> -u admin -c ./networkA/credentials/certificate -k ./networkA/credentials/privateKey -f newNetworkB.card
composer card create -p ~/.composer/cards/networkB/connection.json --businessNetworkName other-tutorial-network -u admin -c ./networkA/credentials/certificate -k ./networkA/credentials/privateKey -f newNetworkB.card

5. Import the card

Expand All @@ -153,6 +130,12 @@ After the channel has been created a business network card needs to be created t
6. Ping the network to activate the identity

composer network ping --card newNetworkB
## Step Six: Review the asset data

View the asset to see that the quantity is 250.

composer network list --card networkA -r org.acme.biznet.Commodity -a Ag

## Step Seven: Submit a transaction

Expand Down
12 changes: 11 additions & 1 deletion packages/composer-website/jekylldocs/tutorials/tutorials.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ excerpt: Tutorials

---

We have two basic tutorial options, and one more advanced tutorial:
We have four basic tutorial options, and two more advanced tutorials:

## Playground Tutorial

Expand All @@ -30,6 +30,10 @@ The developer tutorial will walk you through the steps required to build a {{sit

[**Start Developer Tutorial**](../tutorials/developer-tutorial.html).

## Access Control Language (ACL) Tutorial
This tutorial presumes that you have some experience using {{site.data.conrefs.composer_short}}.
In this tutorial, you will incrementally build ACL rules for a sample Commodity Trading business network, and test the ACLs as an integral step during the rules build. You can complete the tutorial in the online Playground (and you deploy the Trade sample network there) ; but you can equally complete the tutorial if you deploy that sample network to your {site.data.conrefs.hlf_full}} runtime.

## Query Tutorial

This tutorial presumes that you have some experience using {{site.data.conrefs.composer_short}}.
Expand All @@ -54,4 +58,10 @@ In this tutorial, two organization administrators configure their instances of {

[**Start the multi-organization {{site.data.conrefs.hlf_full}} deployment tutorial**](../tutorials/deploy-to-fabric-multi-org.html).

## Invoking a {{site.data.conrefs.composer_full}} business network from another business network

In this tutorial, we will demonstrate the steps that a business network developer needs to take in order to invoke a {{site.data.conrefs.composer_full}} business network from a different business network

[**Start the invoking a {{site.data.conrefs.composer_full}} business network from another business network tutorial**](../tutorials/invoke-composer-network.html).

---

0 comments on commit 843c97a

Please sign in to comment.