Presentation Link: ibm.biz/sfhl2018
October 2008. It all started with Satoshi Nakamoto and his paper Bitcoin: A Peer-to-Peer Electronic Cash System which addressed a key problem in electronic commerce:
A blockchain is a decentralized virtual ledger for recording transactions without central authority through a distributed cryptographic protocol. It is made up of three technologies
- cryptographic algorithms,
- a distributed protocol,
- and replicated data
which combined provide a trustworthy service to a group of nodes that do not fully trust each other.
Source: https://www.zurich.ibm.com/dccl/papers/cachin_dccl.pdf
Growing the Enterprise Blockchain Ecosystem Through Open Standards and Open Source Code
Cryptography and Protocols in Hyperledger Fabric
Hyperledger by Linux Foundation
https://www.hyperledger.org/projects/fabric
https://hyperledger-fabric.readthedocs.io/en/release-1.3/
Hyperledger, an open source collaborative effort to advance cross-industry blockchain technologies, is hosted by The Linux Foundation®.
Deployed in Docker images.
https://www.hyperledger.org/projects/composer
https://hyperledger.github.io/composer/latest/installing/development-tools.html
Make sure you have installed the required pre-requisites, following the instructions in Installing pre-requisites.
https://hyperledger.github.io/composer/latest/installing/installing-prereqs.html#macos
https://hyperledger.github.io/composer/latest/installing/installing-prereqs.html#ubuntu
Please Note: enter the command Nvm use Node. Should result in Now using node v8.11.2 (npm v5.6.0) or similar
npm install -g [email protected] //Utility for running a REST Server on your machine to expose your business networks as RESTful APIs:
npm install -g [email protected] // Useful utility for generating application assets:
npm install -g [email protected] //Useful utility for generating application assets:
npm install -g yo // Yeoman is a tool for generating applications, which utilises generator-hyperledger-composer:
npm install -g [email protected]
npm install -g [email protected]
npm install -g [email protected]
npm install -g yo
npm install -g [email protected]
https://hyperledger.github.io/composer/latest/installing/development-tools.html
In a directory of your choice (we will assume ~/fabric-dev-servers), get the .tar.gz file that contains the tools to install Hyperledger Fabric:
mkdir ~/fabric-dev-servers && cd ~/fabric-dev-servers
curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.tar.gz
tar -xvf fabric-dev-servers.tar.gz
A zip is also available if you prefer: just replace the .tar.gz file with fabric-dev-servers.zip and the tar -xvf command with a unzip command in the preceding snippet.
Use the scripts you just downloaded and extracted to download a local Hyperledger Fabric v1.2 runtime:
cd ~/fabric-dev-servers
export FABRIC_VERSION=hlfv12
./downloadFabric.sh
cd ~/fabric-dev-servers
export FABRIC_VERSION=hlfv12
./startFabric.sh
./createPeerAdminCard.sh
To start the web app, run:
composer-playground
If you've previously used an older version of Hyperledger Composer and are now setting up a new install, you may want to kill and remove all previous Docker containers, which you can do with these commands:
Copy
docker kill $(docker ps -q)
docker rm $(docker ps -aq)
docker rmi $(docker images dev-* -q)
]
https://hyperledger.github.io/composer/latest/tutorials/developer-tutorial.html
yo hyperledger-composer:businessnetwork
Enter tutorial-network for the network name, and desired information for description, author name, and author email.
Select Apache-2.0 as the license.
Select org.example.mynetwork as the namespace.
Replace the contents with the following:
/**
* My commodity trading network
*/
namespace org.example.mynetwork
asset Commodity identified by tradingSymbol {
o String tradingSymbol
o String description
o String mainExchange
o Double quantity
--> Trader owner
}
participant Trader identified by tradeId {
o String tradeId
o String firstName
o String lastName
}
transaction Trade {
--> Commodity commodity
--> Trader newOwner
}
Save your changes to org.example.mynetwork.cto
Open the logic.js script file.
Replace the contents with the following:
/**
* Track the trade of a commodity from one trader to another
* @param {org.example.mynetwork.Trade} trade - the trade to be processed
* @transaction
*/
async function tradeCommodity(trade) {
trade.commodity.owner = trade.newOwner;
let assetRegistry = await getAssetRegistry('org.example.mynetwork.Commodity');
await assetRegistry.update(trade.commodity);
}
Save your changes to logic.js.
/**
* Access control rules for tutorial-network
*/
rule Default {
description: "Allow all participants access to all resources"
participant: "ANY"
operation: ALL
resource: "org.example.mynetwork.*"
action: ALLOW
}
rule SystemACL {
description: "System ACL to permit all access"
participant: "ANY"
operation: ALL
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}
Now that the business network has been defined, it must be packaged into a deployable business network archive (.bna) file.
Using the command line, navigate to the tutorial-network directory.
From the tutorial-network directory, run the following command:
composer archive create -t dir -n .
After the command has run, a business network archive file called [email protected] has been created in the tutorial-network directory
https://hyperledger.github.io/composer/latest/tutorials/developer-tutorial.html
composer network install --card PeerAdmin@hlfv1 --archiveFile [email protected]
composer network start --networkName tutorial-network --networkVersion 0.0.1 --networkAdmin admin --networkAdminEnrollSecret adminpw --card PeerAdmin@hlfv1 --file networkadmin.card
composer card import --file networkadmin.card
composer network ping --card admin@tutorial-network
composer-rest-server
Enter admin@tutorial-network as the card name.
Select never use namespaces when asked whether to use namespaces in the generated API.
Select No when asked whether to secure the generated API.
Select Yes when asked whether to enable event publication.
Select No when asked whether to enable TLS security.
yo hyperledger-composer:angular
Select Yes when asked to connect to running business network.
Enter standard package.json questions (project name, description, author name, author email, license)
Enter admin@tutorial-network for the business network card.
Select Connect to an existing REST API
Enter http://localhost for the REST server address.
Enter 3000 for server port.
Select Namespaces are not used
The Angular generator will then create the scaffolding for the project and install all dependencies.
To run the application, navigate to your angular project directory and run npm start . This will fire up an Angular 4 application running against your REST API at http://localhost:4200 .
Fixing Transaction issue in Angular for Hyperledger fabric blockchain application