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

  • 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:
主站蜘蛛池模板: 类乌齐县| 南丰县| 黔西县| 台北市| 麟游县| 嘉义县| 兴城市| 巴楚县| 靖宇县| 南岸区| 修水县| 额济纳旗| 祁东县| 潞城市| 夏河县| 广东省| 泸西县| 襄樊市| 张掖市| 玉田县| 绥化市| 奈曼旗| 大悟县| 潍坊市| 滁州市| 文昌市| 承德县| 平武县| 淮安市| 习水县| 双鸭山市| 泸水县| 霍州市| 綦江县| 河北省| 永春县| 蓝山县| 汉寿县| 鄂伦春自治旗| 房山区| 定远县|