官术网_书友最值得收藏!

  • Hyperledger Cookbook
  • Xun (Brian) Wu Chuanfeng Zhang Andrew Zhang
  • 253字
  • 2021-06-24 14:59:40

Building and deploying the chaincode

  1. Open Terminal two. This Terminal will build and deploy the chaincode. Since we write and build the chaincode from our local Unix system, the chaincode is not yet in the Docker containers. Run the following command in the chaincode-docker-devmode folder:
docker exec -it chaincode bash

  1. The output will be a list of folders:
abac chaincode_example02 fabcar marbles02 marbles02_private sacc
  1. Let's create an assetmgr folder:
mkdir assetmgr

This will create an assetmgr folder in the Fabric container. First, type exit. This will exit the container and return to the chaincode-docker-devmode folder. Check the Fabric chaincode container ID by typing docker ps. You will get a similar result to the following:

In our example, the chaincode container ID is dbf9a0a1da76. The peer port is 7051.

  1. With the container ID, we can copy the local chaincode to the chaincode container. Run the following command:
docker cp ~/itasset/src/assetmgr/assetmgr.go dbf9a0a1da76:/opt/gopath/src/chaincode/assetmgr
  1. Launch the chaincode container again:
docker exec -it chaincode bash
  1. Navigate to the assetmgr folder and execute the go build command. This will compile our assermgr.go in the chaincode container, as shown in the following screenshot: 

The assetmgr chaincode can be found at the following path: /opt/gopath/src/chaincode/assetmgr.

  1. Run the chaincode by providing the peer address and chaincode ID name. The command is as follows:
CORE_PEER_ADDRESS=peer:7052 CORE_CHAINCODE_ID_NAME=mycc:0 ./assetmgr
  1. This command will deploy the chaincode to the peer node at 7052. If you don't see any errors, the chaincode will start with peer. The log indicates that assetmgr.go successfully registered with peer:
主站蜘蛛池模板: 湘阴县| 府谷县| 沭阳县| 南康市| 积石山| 出国| 阳春市| 清丰县| 晋州市| 鹤山市| 许昌市| 凉山| 常宁市| 措美县| 丹东市| 凉山| 峨边| 玉溪市| 黔西县| 永川市| 赤峰市| 宁远县| 高要市| 施秉县| 翁源县| 瑞安市| 江山市| 白山市| 维西| 柳江县| 茶陵县| 汨罗市| 台湾省| 五莲县| 司法| 屯留县| 武夷山市| 方正县| 全州县| 阿瓦提县| 闽侯县|