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

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:
主站蜘蛛池模板: 辽中县| 灌南县| 收藏| 伊春市| 莎车县| 桃源县| 高安市| 岳阳县| 甘南县| 铁力市| 东乡族自治县| 政和县| 阳信县| 平和县| 静乐县| 衢州市| 右玉县| 凤台县| 华安县| 青海省| 林周县| 四子王旗| 阳曲县| 乐东| 开阳县| 措勤县| 开平市| 徐水县| 岳普湖县| 定襄县| 冀州市| 平昌县| 连山| 北辰区| 桂东县| 瑞安市| 卢氏县| 辽阳县| 长岭县| 寿宁县| 琼结县|