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

Commit

Permalink
Merge pull request #71 from Tobias-Hunter/readme
Browse files Browse the repository at this point in the history
All README.md files updated with Tutorials
  • Loading branch information
Tobias-Hunter committed Jul 14, 2017
2 parents e18fd62 + 7aba1c5 commit f875b15
Show file tree
Hide file tree
Showing 10 changed files with 460 additions and 140 deletions.
64 changes: 50 additions & 14 deletions packages/animaltracking-network/README.md
@@ -1,22 +1,58 @@
# Animal Tracking Network
Defines an Animal Movement business network based on UK DEFRA government regulations https://www.gov.uk/animal-movement-england.

Farmers can move animals between farms/fields and the UK government farming regulator has
visibility into the locations of all animals and all animal movements between farms.
> This is an Animal Tracking Business Network based on UK DEFRA government regulations (https://www.gov.uk/animal-movement-england). Farmers can move animals between farms/fields and the UK government farming regulator has visibility into the locations of all animals and all animal movements between farms.
- Each Farmer owns a Business that is identified by a Single Business Identifier (SBI)
- Each Farmer owns a set of Animals
- Each Business owns a set of Fields
- Each Field contains a set of Animals owned by the Farmer
- Animals can be transfered between Farmers or between Fields
This business network defines:

## Demo inside Hyperledger Composer
Import the sample into Hyperledger Composer using the `Import/Replace` button.
**Participants**
`Farmer` `Regulator`

Submit a `SetupDemo` transaction to bootstrap a scenario to get you started.
**Assets**
`Animal` `Business` `Field`

You will see the 2 `Farmer` participants have been created, `FARMER_1` and `FARMER_2` as well as 2 `Field`'s, 2 `Business`'s and 8 `Animal`'s.
**Transactions**
`AnimalMovementDeparture` `AnimalMovementArrival` `SetupDemo`

Submit a `AnimalMovementDeparture` when you wish to sent an `Animal` to another `Farmer`, then, as the `Animal`'s new owner, submit an `AnimalMovementArrival` transaction to confirm revceipt.
Each Farmer owns a Business that is identified by a Single Business Identifier (SBI). A Farmer owns a set of Animals. A Business owns a set of Fields. A Field contains a set of Animals owned by the Farmer. Animals can be transferred between Farmers or between Fields.

![Definiton Diagram](./network.png)
To test this Business Network Definition in the **Test** tab:

Submit a `SetupDemo` transaction:

```
{
"$class": "com.biz.SetupDemo"
}
```

This transaction populates the Participant Registries with two `Farmer` participants and a `Regulator` participant. The Asset Registries will have eight `Animal` assets, two `Business` assets and four `Field` assets.

Submit a `AnimalMovementDeparture` transaction:

```
{
"$class": "com.biz.AnimalMovementDeparture",
"fromField": "resource:com.biz.Field#FIELD_1",
"animal": "resource:com.biz.Animal#ANIMAL_1",
"from": "resource:com.biz.Business#BUSINESS_1",
"to": "resource:com.biz.Business#BUSINESS_2"
}
```

This transaction moves `ANIMAL_1` from `FIELD_1` at `BUSINESS_1` to `BUSINESS_2`.

Submit a `AnimalMovementArrival` transaction:

```
{
"$class": "com.biz.AnimalMovementArrival",
"arrivalField": "resource:com.biz.Field#FIELD_2",
"animal": "resource:com.biz.Animal#ANIMAL_1",
"from": "resource:com.biz.Business#BUSINESS_1",
"to": "resource:com.biz.Business#BUSINESS_2"
}
```

This transaction confirms the receipt of `ANIMAL_1` from `BUSINESS_1` to `FIELD_2` at `BUSINESS_2`.

Congratulations!
8 changes: 4 additions & 4 deletions packages/basic-sample-network/README.md
Expand Up @@ -2,14 +2,14 @@

> This is the "Hello World" of Hyperledger Composer samples, which demonstrates the core functionality of Hyperledger Composer by changing the value of an asset.
In the **Define** tab this in Basic Sample Business Network defines:

**Asset**
`SampleAsset`
This business network defines:

**Participant**
`SampleParticipant`

**Asset**
`SampleAsset`

**Transaction**
`SampleTransaction`

Expand Down
70 changes: 64 additions & 6 deletions packages/bond-network/README.md
@@ -1,8 +1,66 @@
# Hyperledger Composer Bond Reference Data Demo
# Bond Network

Example business network that stores information about financial bonds on the blockchain. It allows
the issuer of a bond to update the bond information whilst other members of the business network can
only read the bond data.
> The Bond Network allows the issuer of a bond to update the bond information whilst other members of the business network can only read the bond data.
The data model for a bond is based on the FpML schema:
http://www.fpml.org/spec/fpml-5-3-2-wd-2/html/reporting/schemaDocumentation/schemas/fpml-asset-5-3_xsd/elements/bond.html
This business network defines:

**Participants**
`Issuer` `Member`

**Assets**
`BondAsset`

**Transactions**
`PublishBond`

The `PublishBond` transaction submitted by an `Issuer` participant will create a new `BondAsset`.

To test this Business Network Definition in the **Test** tab:

Create a `Issuer` participant:

```
{
"$class": "org.acme.bond.Issuer",
"memberId": "memberId:1",
"name": "Billy Thompson"
}
```

Create a `Member` participant:

```
{
"$class": "org.acme.bond.Member",
"memberId": "memberId:1",
"name": "Jenny Jones"
}
```

Submit a `PublishBond` transaction:

```
{
"$class": "org.acme.bond.PublishBond",
"ISINCode": "ISINCode:1234",
"bond": {
"$class": "org.acme.bond.Bond",
"instrumentId": [],
"exchangeId": [],
"maturity": "2017-07-13T09:39:05.369Z",
"parValue": 1000,
"faceAmount": 1000,
"paymentFrequency": {
"$class": "org.acme.bond.PaymentFrequency",
"periodMultiplier": 0,
"period": "DAY"
},
"dayCountFraction": "",
"issuer": "resource:org.acme.bond.Issuer#memberId:1"
}
}
```

The `PublishBond` transaction will create a new `BondAsset` in the Asset Registry.

Congratulations!
31 changes: 7 additions & 24 deletions packages/carauction-network/README.md
@@ -1,26 +1,24 @@
# Car Auction Business Network
# Car Auction Network

> This is an interactive, distributed, car auction demo. List assets for sale (setting a reserve price), and watch as assets that have met their reserve price are automatically transferred to the highest bidder at the end of the auction.
In the **Define** tab for this network there is defined:

**Assets:**
`Vehicle` `VehicleListing`
This business network defines:

**Participants:**
`Member` `Auctioneer`

**Assets:**
`Vehicle` `VehicleListing`

**Transactions:**
`Offer` `CloseBidding`

The `makeOffer` function is called when an `Offer` transaction is submitted. The logic simply checks that the listing for the offer is still for sale, and then adds the offer to the listing, and then updates the offer in the `VehicleListing` asset registry.
The `makeOffer` function is called when an `Offer` transaction is submitted. The logic simply checks that the listing for the offer is still for sale, and then adds the offer to the listing, and then updates the offers in the `VehicleListing` asset registry.

The `closeBidding` function is called when a `CloseBidding` transaction is submitted for processing. The logic checks that the listing is still for sale, sorts the offers by bid price, and then if the reserve has been met, transfers the ownership of the vehicle associated with the listing to the highest bidder. Money is transferred from the buyer's account to the seller's account, and then all the modified assets are updated in their respective registries.

To test this Business Network Definition in the **Test** tab:

## Create an Auctioneer

In the `Auctioneer` participant registry, create a new participant.

```
Expand All @@ -32,8 +30,6 @@ In the `Auctioneer` participant registry, create a new participant.
}
```

## Create two Members

In the `Member` participant registry, create two participants.

```
Expand All @@ -56,8 +52,6 @@ In the `Member` participant registry, create two participants.
}
```

## Create a Vehicle

In the `Vehicle` asset registry, create a new asset of a vehicle owned by `memberA@acme.org`.

```
Expand All @@ -68,8 +62,6 @@ In the `Vehicle` asset registry, create a new asset of a vehicle owned by `membe
}
```

## Create a Vehicle Listing

In the `VehicleListing` asset registry, create a vehicle listing for car `vin:1234`.

```
Expand All @@ -85,12 +77,8 @@ In the `VehicleListing` asset registry, create a vehicle listing for car `vin:12

You've just listed an Arium Nova for auction, with a reserve price of 3500!

## Bidding on a VehicleListing

As soon as a `VehicleListing` has been created (and is in the `FOR_SALE` state) participants can submit `Offer` transactions to bid on a vehicle listing.

## Submit two Offer Transactions

Submit an `Offer` transaction, by submitting a transaction and selecting `Offer` from the dropdown.

```
Expand All @@ -111,9 +99,7 @@ Submit an `Offer` transaction, by submitting a transaction and selecting `Offer`
}
```

## End the Auction

To end the auction submit a `CloseBidding` transaction for the listing, by selecting `CloseBidding` from the dropdown.
To end the auction submit a `CloseBidding` transaction for the listing.

```
{
Expand All @@ -124,9 +110,6 @@ To end the auction submit a `CloseBidding` transaction for the listing, by selec

This simply indicates that the auction for `listingId:ABCD` is now closed, triggering the `closeBidding` function that was described above.


## Check the Results of the Auction

To see the Vehicle was sold you need to click on the `Vehicle` asset registry to check the owner of the car. The reserve price was met by owner `memberB@acme.org` so you should see the owner of the vehicle is now `memberB@acme.org`.

If you check the state of the VehicleListing with `listingId:ABCD` is should be `SOLD`.
Expand Down
109 changes: 50 additions & 59 deletions packages/digitalproperty-network/README.md
@@ -1,84 +1,75 @@
# Digital Property Network

Defines a business network where house sellers can list their properties for sale.
> This Defines a business network where house sellers can list their properties for sale.
Note that this network **references** the digital property model, via an npm dependency declared in package.json:
This business network defines:

```
"dependencies": {
"digitalproperty-model": "latest"
}
```
**Participant**
`Person`

**Assets**
`LandTitle` `SalesAgreement`

This allows the model to be shared across different types of business networks, and allows the model to have a lifecycle that is independent of the business network.
**Transaction**
`RegisterPropertyForSale`

## What should I do with this npm module?
It is expected that this npm module would be associated with a CI pipeline and tracked as source code in something like GitHub Enterpise. The CI pipeline this would be able to run functional validation on the whole definition, and also be able to published the module to an NPM repository. This allows sharing of the module etc.
A `Person` is responsible for a `LandTitle`. By creating a `SalesAgreement` between two `Person` participants you are then able to submit a `RegisterPropertyForSale` transaction.

For a production or QA runtime there are administrative steps (deploy, update, remove etc.) that are performed using this Business Network Definition on a running Hyperledger Fabric. The lifecycle at it's simplest is *deploy a network definition*, *update a network definition* and (potentially) *remove the network definition*. These actions are performed using the Business Network Archive - which is a single file that encapsulates all aspects of the Business Network Definition. It is the 'deployable unit'.
To test this Business Network Definition in the **Test** tab:

## Creating the BusinessNetwork.
*Step1:* Create a npm module
Create two `Person` participants:

```
npm init
{
"$class": "net.biz.digitalPropertyNetwork.Person",
"personId": "personId:Billy",
"firstName": "Billy",
"lastName": "Thompson"
}
```
The important aspects of this are the name, version and description. The only dependancy that will be required is the NPM module that contains the model - see step 2.

*Step2:* Create the transaction functions

We need to create a standard JavaScript file to contain the transaction functions

```bash
\git\DigitialProperty-Model > touch lib/DigitalLandTitle.js
```

In this example the following is the implementation of the `registeryPropertyForSale` transaction

```javascript
'use strict';

/**
* Process a property that is held for sale
* @param {net.biz.digitalPropertyNetwork.RegisterPropertyForSale} propertyForSale the property to be sold
* @transaction
*/
function onRegisterPropertyForSale(propertyForSale) {
console.log('### onRegisterPropertyForSale ' + propertyForSale.toString());
propertyForSale.title.forSale = true;

return getAssetRegistry('net.biz.digitalPropertyNetwork.LandTitle').then(function(result) {
return result.update(propertyForSale.title);
}
);
{
"$class": "net.biz.digitalPropertyNetwork.Person",
"personId": "personId:Jenny",
"firstName": "Jenny",
"lastName": "Jones"
}
```

_FUTURE_
Create a file to hold the permissions access control inforation - create a `permissions.acl` file


Create a `LandTitle` asset:

## Work with the network
Once we have the network complete we can create a business network definition archive. This is the unit that will actually be deloyable to the HyperLedger Fabric.

There is a `composer archive` command that can be used to create and inspect these archives. The `composer network` command is then used to administer the business network archive on the Hyperledger Fabric.

### Creating an archive

The `composer archive create` command is used to create the archive. The `--archiveFile` option is used to specify the name of the archive file to create. If this is not specified then a default name will be used that is based on the identifier of the business network (sanitized to be suitable as a filename). For example `@example_digitalPropertyNetwork-0.1.2.bna`.

Please refer to the docs for `composer archive create` for more options.
```
{
"$class": "net.biz.digitalPropertyNetwork.LandTitle",
"titleId": "titleId:ABCD",
"owner": "resource:net.biz.digitalPropertyNetwork.Person#personId:Billy",
"information": "Detached House"
}
```

Create a `SalesAgreement` asset:

```bash
composer archive create --archiveFile digitialLandTitle.bna --inputDir . --sourceType dir --sourceName DigitalLandTitle
```
{
"$class": "net.biz.digitalPropertyNetwork.SalesAgreement",
"salesId": "salesId:1234",
"buyer": "resource:net.biz.digitalPropertyNetwork.Person#personId:Jenny",
"seller": "resource:net.biz.digitalPropertyNetwork.Person#personId:Billy",
"title": "resource:net.biz.digitalPropertyNetwork.LandTitle#titleId:ABCD"
}
```

Once you have this archive it can then be deployed to the HLF (which will assuming is all running for the moment)
Submit a `RegisterPropertyForSale` transaction:

```bash
composer network deploy --archiveFile DigitalLandTitle.zip --enrollId WebAppAdmin --enrollSecret DJY27pEnl16d
```
{
"$class": "net.biz.digitalPropertyNetwork.RegisterPropertyForSale",
"seller": "resource:net.biz.digitalPropertyNetwork.Person#personId:Billy",
"title": "resource:net.biz.digitalPropertyNetwork.LandTitle#titleId:ABCD"
}
```

This `RegisterPropertyForSale` transaction will update `titleId:ABCD` `LandTitle` asset to `forSale`.

Congratulations!

0 comments on commit f875b15

Please sign in to comment.