【Hyperledger第四讲】 Hyperledger Fab

2019-04-24  本文已影响0人  洞链

准备环境


hyperledger fabric运行网络、postman(测试API工具)、nodejs8.9.4

目录结构分析


balance-transfer目录结构分析
├── app  // 与fabric网络交互的实现
│   ├── create-channel.js
│   ├── helper.js
│   ├── install-chaincode.js
│   ├── instantiate-chaincode.js
│   ├── invoke-transaction.js
│   ├── join-channel.js
│   ├── network-config-aws.json
│   ├── network-config.json
│   └── query.js
├── app.js   // 定义与fabric网络交互的API
├── artifacts  // 启动fabric网络需要的配置
│   ├── base.yaml
│   ├── channel
│   ├── docker-compose.yaml
│   └── src
├── config.js
├── config.json
├── node_modules
│   └── .......
├── package.json
├── package-lock.json
├── README.md
├── runApp.sh
└── testAPIs.sh

运行示例


  1. 下载示例
git clone https://github.com/hyperledger/fabric-samples.git
cd fabric-samples
  1. 启动脚本
cd balance-transfer
./runApp.sh
./runApp.sh执行结果
  1. 测试脚本
  • 创建channel
  • 安装chaincode
  • 初始化chaincode
  • 执行chaincode
  • 各种查询
./testAPIs.sh
POST request Create channel  ...

{"success":true,"message":"Channel 'mychannel' created Successfully"}

POST request Join channel on Org1

{"success":true,"message":"Successfully joined peers in organization Org1 to the channel:mychannel"}

POST request Join channel on Org2

{"success":true,"message":"Successfully joined peers in organization Org2 to the channel:mychannel"}

POST Install chaincode on Org1

{"success":true,"message":"Successfully install chaincode"}

POST Install chaincode on Org2

{"success":true,"message":"Successfully install chaincode"}

POST instantiate chaincode on peer1 of Org1

{"success":true,"message":"Successfully instantiate chaingcode in organization Org1 to the channel 'mychannel'"}

POST invoke chaincode on peers of Org1

Transacton ID is 2eded4ef539d54b6822ba214788c5ae1515985d9c3628fdd259f5e0ab53582e5


GET query chaincode on peer1 of Org1

a now has 90 after the move

GET query Block by blockNumber

GET query Transaction by TransactionID

GET query ChainInfo

GET query Installed chaincodes

["name: mycc, version: v0, path: github.com/example_cc/go"]

GET query Instantiated chaincodes

["name: mycc, version: v0, path: github.com/example_cc/go"]

GET query Channels

{"channels":[{"channel_id":"mychannel"}]}

Total execution time : 90 secs ...

参考文档


https://blog.csdn.net/zhayujie5200/article/details/79684032
https://blog.csdn.net/qq_27818541/article/details/78246947
https://blog.csdn.net/weixin_41926234/article/details/80626078
上一篇下一篇

猜你喜欢

热点阅读