Professional Documents
Culture Documents
Abhi 6
Abhi 6
Roll no – 01
PRN no - 2043110102
Branch - CSE
Subject - Block Chain and Digital Currency
Experiment - 6
Theory -
Installing the development environment
Follow these instructions to obtain the Hyperledger Composer
development tools (primarily used to create Business
Networks) and stand up a Hyperledger Fabric (primarily used
to run/deploy your Business Networks locally). Note that the
Business Networks you create can also be deployed to
Hyperledger Fabric runtimes in other environments e.g. on a
cloud platform.
Note that you should not use su or sudo for the following
npm commands.
4.
5. Useful utility for generating application assets:
npm install -g [email protected]
6.
7. Yeoman is a tool for generating applications, which
npm install -g yo
8.
2.
Step 3: Set up your IDE
curl -O
https://raw.githubusercontent.com/hyperledger/composer-tools/master/p
ackages/fabric-dev-servers/fabric-dev-servers.tar.gz
tar -xvf fabric-dev-servers.tar.gz
preceding snippet.
3. Use the scripts you just downloaded and extracted to
download a local Hyperledger Fabric v1.1 runtime:
cd ~/fabric-dev-servers
export FABRIC_VERSION=hlfv11
./downloadFabric.sh
4. Controlling your dev environment
Starting and stopping Hyperledger Fabric
You control your runtime using a set of scripts which you'll find
The first time you start up a new runtime, you'll need to run
the start script, then generate a PeerAdmin card:
cd ~/fabric-dev-servers
export FABRIC_VERSION=hlfv11
./startFabric.sh
./createPeerAdminCard.sh
composer-playground
/**
* Define the namespace for the business network
*/
namespace org.example.biznet
/**
* Asset definition
*/
asset Product identified by productId {
o String productId
o String name
o Double price
}
/**
* Participant definition
*/
participant Trader identified by tradeId {
o String tradeId
o String firstName
o String lastName
}
/**
* Transaction definition
*/
transaction Trade {
--> Trader trader
--> Product product
}
/**
* Contract definition
*/
contract TradeContract {
/**
* Transaction logic
* @param {org.example.biznet.Trade} trade - the trade
to be processed
* @transaction
*/
function tradeProduct(trade) {
trade.product.owner = trade.trader;
return getAssetRegistry('org.example.biznet.Product')
.then(function(productRegistry) {
return productRegistry.update(trade.product);
});
}
}
Output -