内存要求:
To run Hyperledger Composer and Hyperledger Fabric, we recommend you have at least 4Gb of memory.
开发工具:
Operating Systems: Ubuntu Linux 14.04 / 16.04 LTS (both 64-bit), or Mac OS 10.12
Docker Engine: Version 17.03 or higher
Docker-Compose: Version 1.8 or higher
Node: 8.9 or higher (note version 9 is not supported)
npm: v5.x
git: 2.9.x or higher
Python: 2.7.x
如果系统是Ubuntu,可以使用以下命令安装相应工具:
$ curl -O https://hyperledger.github.io/composer/prereqs-ubuntu.sh
$ chmod u+x prereqs-ubuntu.sh
$ ./prereqs-ubuntu.sh
开发环境
CLI tools:
$ npm install -g composer-cli
REST Server:
$ npm install -g composer-rest-server
generating application assets:
$ npm install -g generator-hyperledger-composer
Yeoman:
$ npm install -g yo
浏览器应用(可选):
$ npm install -g composer-playground
启动composer-playground:
$ composer-playground
安装Hyperledger Fabric
$ mkdir ~/fabric-tools && cd ~/fabric-tools
$ curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.tar.gz
$ tar -zxvf fabric-dev-servers.tar.gz
下载本地Hyperledger Fabric runtime:
$ ./downloadFabric.sh
启动Hyperledger Fabric
$ ./startFabric.sh
生成PeerAdmin card
$ ./createPeerAdminCard.sh
======================================================================
Start a clean Hyperledger Fabric by running the following commands:
$ cd ~/fabric-tools
$ ./stopFabric.sh
#$ ./teardownFabric.sh
#$ ./downloadFabric.sh
$ ./startFabric.sh
Delete any business network cards that may exist in your wallet. It is safe to ignore any errors that state that the business network cards cannot be found:
$ composer card delete -n PeerAdmin@fabric-network
$ composer card delete -n admin@tutorial-network
======================================================================
Step 1: Creating a business network structure.
1、Create a skeleton business network using Yeoman
$ yo hyperledger-composer:businessnetwork
2、Enter tutorial-network for the network name, and desired information for description, author name, and author email.
3、Select Apache-2.0 as the license.
4、Select org.acme.biznet as the namespace.
Step 2: Defining a business network
1、Open the org.acme.biznet.cto model file.
2、Replace the contents with the following:
/**
* My commodity trading network
*/
namespace org.acme.biznet
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
}
3、save
1、Open the logic.js script file.
2、Replace the contents with the following:
/**
* Track the trade of a commodity from one trader to another
* @param {org.acme.biznet.Trade} trade - the trade to be processed
* @transaction
*/
function tradeCommodity(trade) {
trade.commodity.owner = trade.newOwner;
return getAssetRegistry('org.acme.biznet.Commodity')
.then(function (assetRegistry) {
return assetRegistry.update(trade.commodity);
});
}
3、save
1、Create a permissions.acl file in the tutorial-network directory.
2、Add the following access control rules to permissions.acl:
/**
* Access control rules for tutorial-network
*/
rule Default {
description: "Allow all participants access to all resources"
participant: "ANY"
operation: ALL
resource: "org.acme.biznet.*"
action: ALLOW
}
rule SystemACL {
description: "System ACL to permit all access"
participant: "ANY"
operation: ALL
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}
3、save
Step 3: Generate a business network archive
1、Using the command line, navigate to the tutorial-network directory.
2、From the tutorial-network directory, run the following command:
$ composer archive create -t dir -n .
会生成 tutorial-network@0.0.1.bna 文件
Step 4: Building a connection profile
1、Create a connection profile file called connection.json.
2、example
{
"name": "fabric-network",
"type": "hlfv1",
"mspID": "Org1MSP",
"peers": [
{
"requestURL": "grpc://localhost:7051",
"eventURL": "grpc://localhost:7053"
}
],
"ca": {
"url": "http://localhost:7054",
"name": "ca.org1.example.com"
},
"orderers": [
{
"url" : "grpc://localhost:7050"
}
],
"channel": "composerchannel",
"timeout": 300
}
3、save
Step 5: Locating the certificate and private key for the Hyperledger Fabric administrator
为方便操作,可将以下文件拷贝到同一个目录
文件1:connection.json
文件2:Admin@org1.example.com-cert.pem 位置(~/fabric-tools/fabric-scripts/hlfv1/composer/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem)
文件3:xxxx_sk 位置(~/fabric-tools/fabric-scripts/hlfv1/composer/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/114aab0e76bf0c78308f89efc4b8c9423e31568da0c340ca187a9b17aa9a4457_sk)
Step 6: Creating a business network card for the Hyperledger Fabric administrator
$ composer card create -p connection.json -u PeerAdmin -c Admin@org1.example.com-cert.pem -k 114aab0e76bf0c78308f89efc4b8c9423e31568da0c340ca187a9b17aa9a4457_sk -r PeerAdmin -r ChannelAdmin
会生成PeerAdmin@fabric-network.card文件
Step 7: Importing the business network card for the Hyperledger Fabric administrator
$ composer card import -f PeerAdmin@fabric-network.card
Step 8: Installing the Hyperledger Composer runtime onto the Hyperledger Fabric peer nodes
即:Install Chaincode
$ composer runtime install -c PeerAdmin@fabric-network -n tutorial-network
Step 9: Starting the blockchain business network
即:Instantiate Chaincode
$ composer network start -c PeerAdmin@fabric-network -a tutorial-network@0.0.1.bna -A admin -S adminpw
会生成admin@tutorial-network.card文件
Step 10: Importing the business network card for the business network administrator
$ composer card import -f admin@tutorial-network.card
Step 11: Testing the connection to the blockchain business network
$ composer network ping -c admin@tutorial-network
Step 12: Generating a REST server
1、To create the REST API, navigate to the tutorial-network directory and run the following command:
$ composer-rest-server
2、Enter admin@tutorial-network as the card name.
3、Select never use namespaces when asked whether to use namespaces in the generated API.
4、Select No when asked whether to secure the generated API.
5、Select Yes when asked whether to enable event publication.
6、Select No when asked whether to enable TLS security.
=====================================================================
Appendix: destroy a previous setup
$ docker kill $(docker ps -q)
$ docker rm $(docker ps -aq)
$ docker rmi $(docker images dev-* -q)
=====================================================================
=====================================================================
After changing the files in a business network, the business network must be repackaged as a business network archive (.bna) and redeployed to the Hyperledger Fabric instance.
Regenerate your business network archive
$ composer archive create --sourceType dir --sourceName . -a tutorial-network@0.0.1.bna
Deploy the updated business network definition
$ composer network update -a tutorial-network@0.0.1.bna -c admin@tutorial-network
Test that the network is deployed
$ composer network ping -c admin@tutorial-network
=====================================================================
相关推荐
本文档将指导您通过两台虚拟机(VMs)部署一个Hyperledger Fabric区块链网络,并使用Hyperledger Composer构建业务网络。该网络包括两个组织:Org1和Org2,每个组织都有其自己的成员服务提供商(MSP)。我们将详细...
使用Hyperledger Composer开发区块链应用。只要掌握了,就不需要再学习nodejs和go啦。Composer 简化了区块链开发的流程。
区块链文件管理系统具有Hyperledger Fabric区块链的简单文档管理系统,使用Hyperledger Composer API,IPFS,MongoDB,Express.js,GraphQL,React.js和Material-UI先决条件操作系统:Ubuntu Linux 14.04 / 16.04 ...
// 参考文档https://www.ibm.com/developerworks/cn/cloud/library/cl-lo-hyperledger-fabric-study-notes1/index.html?cm_mmc=dwchina-_-homepage-_-social-_-wechat // 1.重启 Fabric: $ ~/fabric-tools/...
Hyperledger Composer示例应用程序 :warning: :warning: :warning: 截至2019年8月29日,Hyperledger Composer项目已弃用。 任何维护者都没有积极开发新功能。 没有维护者通过GitHub问题积极地提供支持。 但是,...
作曲家钱包云这是使用数据库(基于Apache CouchDB)的Hyperledger Composer Wallet实现。 请注意,“精简版”计划的速率受限于每秒可以执行的查询数量。用法下面的步骤假定您拥有要使用的Hyperledger Composer应用...
这是一个有趣的演示,您可以进行分叉并进行研究,以学习如何使用React与Hyperledger进行交互。 区块链技术经常被讨论,但是很少被展示。 Learn Hyperledger旨在解决这一问题。 到目前为止,仅基于Linux的操作系统...
在此代码模式中,我们将使用Hyperledger Composer创建这样的区块链应用程序。 该网络由居民,银行和公用事业公司组成。 居民可以相互交换硬币以换取能量。 该应用程序假设一个预付费系统,在该系统中,在消耗能量并...
12. Hyperledger Composer开发基础介绍:Hyperledger Composer是基于Hyperledger Fabric的一个业务网络开发工具。它提供了模型驱动的业务网络定义、高级API和丰富的开发工具,降低了区块链应用开发的复杂性。 13. ...
通过Hyperledger Composer附带的REST服务器,传感器数据通过wifi从传播器推送到Hyperledger,并作为资产存储。 我们实施了从农民仓库运来的卡车将豆子装进商人仓库的集装箱时可能发生的交易。 称重容器(由压力...
此代码定义了一个供供应商,发货人和零售商使用的Hyperledger业务网络,以列出要出售的产品,列出要投标的装运合同,协商合同价格以及创建生成货物的合同,并记录温度读数。 合同是Hyperledger易腐货物网络指定的...
借助超级账本进行区块链开发使用Hyperledger Fabric和Composer构建去中心化的应用程序。 该学习路径是您使用以太坊,Hyperledger Fabric和Hyperledger Composer探索和构建区块链网络的简单参考。 它从区块链概述开始...
其中,Hyperledger Fabric 和 Hyperledger Composer 是两个重要的组件。 **Hyperledger Fabric** 是一个灵活且可扩展的区块链框架,支持创建私有、许可型的区块链网络。它的设计目标是为了解决企业环境中对隐私、...
保险网Hyperledger Composer演示这是人寿保险公司的网络,用于跟踪已去世的定期人寿保单持有人(客户)的被提名人,并在客户拥有其人寿保险单上有长期护理报销附加费的情况下防止超额索偿该网络定义: 参与者...
$ composer archive create --sourceType dir --sourceName . // 安装bnd到节点,一次安装,就永久存在节点中了,如果提示已安装,则增加版本号,重头开始做 $ composer network install --card PeerAdmin@hlfv1 --...
如果您是区块链,Hyperledger Fabric或Hyperledger Composer的新手,我们建议您从Hyperledger Composer网站开始: 该站点将通过开发示例区块链应用程序来帮助您起步并运行,该应用程序用于在数字财产业务
英赫尔区块链集成的电子健康系统概要建立在区块链上的电子健康记录系统。 透明。 安全。 一成不变。屏幕截图 注意:此存储库仅用于后端。...技术栈面向区块链的Hyperledger Composer,Fabric和Playground,前
了解如何使用Hyperledger Composer构建区块链网络。 可以在这里找到该研讨会的介绍幻灯片: : 此回购包括如何构建基本区块链网络并将其导出为.bna的演练。 包括的所有文件都是使用本自述文件作为演练的结果。 概述...
使用Hyperledger的动手区块链 这是Packt发布的《 进行的代码库。...使用Hyperledger Composer快速编写智能合约 如果您觉得这本书适合您,请立即获取! 说明和导航 所有代码都组织在文件夹中。 该代码将如下所示: