- Hyperledger Cookbook
- Xun (Brian) Wu Chuanfeng Zhang Andrew Zhang
- 253字
- 2021-06-24 14:59:40
Building and deploying the chaincode
- 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
- The output will be a list of folders:
abac chaincode_example02 fabcar marbles02 marbles02_private sacc
- 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.
- 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
- Launch the chaincode container again:
docker exec -it chaincode bash
- 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.
- 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
- 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:

推薦閱讀
- 矩陣決策:如何鎖定關(guān)鍵點(diǎn)做出制勝策略
- 幾何原本
- Ethereum Smart Contract Development
- 幾何之美
- 數(shù)字乾坤
- ANSYS 12.0有限元分析完全手冊(cè)
- 高等數(shù)學(xué)(上冊(cè))
- 模糊數(shù)學(xué)基礎(chǔ)及應(yīng)用
- ABAQUS 2018有限元分析從入門(mén)到精通
- 周髀算經(jīng)
- 數(shù)據(jù)科學(xué)與機(jī)器學(xué)習(xí):數(shù)學(xué)與統(tǒng)計(jì)方法
- 概率論思想方法的歷史研究
- 別萊利曼的趣味幾何學(xué)
- 幾何和統(tǒng)計(jì)(全彩版)
- 全局優(yōu)化理論幾種算法的改進(jìn)研究