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

  • 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:
主站蜘蛛池模板: 翁源县| 武隆县| 拜城县| 文安县| 循化| 土默特右旗| 阳东县| 上虞市| 山东省| 阿城市| 廊坊市| 阿坝| 兴宁市| 抚州市| 小金县| 福建省| 巴楚县| 二连浩特市| 仁布县| 平舆县| 霞浦县| 双桥区| 海淀区| 扶沟县| 屯昌县| 伊吾县| 泗水县| 大渡口区| 娱乐| 丰宁| 武平县| 顺昌县| 永修县| 思南县| 太白县| 新竹县| 元氏县| 平谷区| 庆阳市| 平乡县| 工布江达县|