- Hyperledger Cookbook
- Xun (Brian) Wu Chuanfeng Zhang Andrew Zhang
- 416字
- 2021-06-24 14:59:41
Invoking the assermgr chaincode
Next, we can start to invoke the remaining chaincode methods: Order, Ship, and Distribute.
- To order the device from OEM, we need to pass three parameters to the chaincode—assetId, Comment, and Location. Here, assetId is 100, and we will assume that Location is New York.
- Now, issue invoke to call the Order method in the assetmgr chaincode. The command is as follows:
peer chaincode invoke -n mycc -c '{"Args":["Order", "100", "initial order from
school", "New York"]}' -C myc
- If all goes well, you should see the following result. The log shows that the chaincode has been invoked successfully. We can see that the result is successfully saved to blockchain:

- In our assetmgr, we have defined a query method. We can invoke this method to verify whether the records have been saved in the Fabric blockchain. Issue the following query command with assetId as 100:
peer chaincode query -C myc -n mycc -c '{"Args":["query","100"]}'
We can find the asset with an assetId of 100 from the Fabric ledger:

- Once the OEM receives the order, it starts to work and produce the iPad device. Then, the OEM ships the device to the school. To do this, issue the following Ship command with assetId, Comment, and Location:
peer chaincode invoke -n mycc -c '{"Args":["Ship", "100", "OEM deliver ipad to school", "New Jersey"]}' -C myc
The following screenshot will be the output of the previous code:

- Once the device is received, the school will distribute the device to the student. Issue the following Distribute command with assetId, Comment, and Location:
peer chaincode invoke -n mycc -c '{"Args":["Distribute", "100", "Distribute device to student", "New York"]}' -C myc
We should see the following result:

- We have now completed the entire process for our demo use case. As we discussed earlier, blockchain is a ledger system; it will keep track of all transactions. Once records are saved to the blockchain, they cannot be altered. We should be able to see this historical transaction data. In our asset manager example, we issued the Order, Ship, and Distribute commands and the related chaincode was invoked. All related asset transaction records should be kept in the blockchain. Let's verify this by issuing the getHistory command:
peer chaincode query -C myc -n mycc -c '{"Args":["getHistory","100"]}'
This command will provide the following results:

As we can see, the getHistory command returns all of the transaction records we invoked from Fabric blockchain.
推薦閱讀
- 走進(jìn)奇妙的數(shù)學(xué)世界(小學(xué)一二年級)
- 武俠數(shù)學(xué)
- 有限自動機(jī)理論
- Origin 9.0科技繪圖與數(shù)據(jù)分析超級學(xué)習(xí)手冊
- 張梅玲:讓孩子受益一生的數(shù)學(xué)思維訓(xùn)練
- 紅發(fā)克拉拉的數(shù)學(xué)奇想
- 一個數(shù)學(xué)家的辯白(雙語版)
- 2016年管理類專業(yè)學(xué)位聯(lián)考綜合能力考試 數(shù)學(xué)考點歸納與真題解析
- 數(shù)學(xué)女孩5:伽羅瓦理論
- 數(shù)學(xué)多大點事兒
- 數(shù)理統(tǒng)計及其在數(shù)學(xué)建模中的實踐(使用MATLAB)
- ANSYS 15.0有限元分析從入門到精通 (清華社視頻大講堂大系)
- 數(shù)學(xué)思維的力量
- 在動手實驗中學(xué)習(xí)科學(xué)與數(shù)學(xué)
- 文化偉人代表作圖釋書系:幾何原本