This repository has been archived by the owner on Mar 8, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from Tobias-Hunter/readme
All README.md files updated with Tutorials
- Loading branch information
Showing
10 changed files
with
460 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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! |
Oops, something went wrong.