当前位置:网站首页>Hyperledger Fabric 2. X dynamic update smart contract
Hyperledger Fabric 2. X dynamic update smart contract
2022-06-24 23:27:00 【zltrobin】

One 、 explain
In the last article, I shared the installation and use of smart contract , What if the business changes and the code needs to be modified ? This article shares how to version update installed contracts .
Two 、 Environmental preparation
Blockchain network installation : 《Hyperledger Fabric 2.x Environment building 》
Smart contract installation : 《Hyperledger Fabric 2.x Custom smart contracts 》
Execute the following command , You can see the installed contract information :
peer lifecycle chaincode queryinstalled
- 1.

3、 ... and 、 Repackaging code
Repackage the latest contract source code :
peer lifecycle chaincode package mycc.tar.gz
--path /opt/app/my-fabric-chaincode-java
--lang java
--label mycc
- 1.
Four 、 Reinstall the contract
Again, they are peer0.org1 and peer0.org2 Two agency installation contracts :
peer lifecycle chaincode install mycc.tar.gz
- 1.
Execute the following command , Review the installed contract information :
peer lifecycle chaincode queryinstalled
- 1.
It can be found that a new one has been added Label The same name Package ID Different records :

5、 ... and 、 Re approve
Again, they are peer0.org1 and peer0.org2 Two agencies approve contracts :
peer lifecycle chaincode approveformyorg \
-o localhost:7050 \
--ordererTLSHostnameOverride orderer.example.com \
--tls \
--cafile
${MSP_PATH}/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem \
--channelID mychannel \
--name mycc \
--version
1.1 \
--package
-id mycc:ecd2abc60ea098508aeefc135d8838787e9c1e3b8e411386a23ca56b7dfed758 \
--sequence
2
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
package-id: Fill in the new installation
Package IDsequence: Because it's the second contract , So you need to fill in
2version: Just the identifier , It can be changed but not changed
Execute the following command , Check node approval status :
peer lifecycle chaincode checkcommitreadiness
--channelID mychannel
--name mycc
--version
1.1
--sequence
2
--output json
- 1.
return :
{
"approvals": {
"Org1MSP":
true,
"Org2MSP":
true
}
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
6、 ... and 、 To resubmit
Execute the following command , Submit the contract to the channel :
peer lifecycle chaincode commit \
-o localhost:7050 \
--ordererTLSHostnameOverride orderer.example.com \
--tls \
--cafile
${MSP_PATH}/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem \
--channelID mychannel \
--name mycc \
--peerAddresses localhost:7051 \
--tlsRootCertFiles
${MSP_PATH}/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt \
--peerAddresses localhost:9051 \
--tlsRootCertFiles
${MSP_PATH}/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt \
--version
1.1 \
--sequence
2
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
Need to put sequence and version Change to the value at the time of approval
7、 ... and 、 View submitted contracts
Execute the order :
peer lifecycle chaincode querycommitted
--channelID mychannel
--name mycc
--output json
- 1.
You can see the passage now mychannel The name is mycc Your contract has been updated to 1.1 edition :
{
"sequence":
2,
"version":
"1.1",
"endorsement_plugin":
"escc",
"validation_plugin":
"vscc",
"validation_parameter":
"EiAvQ2hhbm5lbC9BcHBsaWNhdGlvbi9FbmRvcnNlbWVudA==",
"collections": {},
"approvals": {
"Org1MSP":
true,
"Org2MSP":
true
}
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
边栏推荐
- Building Survey [2]
- [JS] - [tree] - learning notes
- golang convert json string to map
- Construction equipment [4]
- Websocket long link pressure test
- Laravel add helper file
- [introduction to UVM== > episode_8] ~ sequence and sequencer, sequence hierarchy
- Still using simpledateformat for time formatting? Be careful of project collapse
- Gocolly manual
- InnoDB, the storage engine of MySQL Architecture Principle_ Redo log and binlog
猜你喜欢

Laravel pagoda security configuration
How should we measure agile R & D projects?

【js】-【树】-学习笔记

慕思股份深交所上市:靠床垫和“洋老头”走红 市值224亿

Dig deep into MySQL - resolve the clustered index / secondary index / federated index of InnoDB storage engine

7-7 数字三角形

华为机器学习服务语音识别功能,让应用绘“声”绘色

选择类排序法

Installing IBM CPLEX academic edition | CONDA installing CPLEX

Chapter VI skills related to e-learning 5 (super parameter verification)
随机推荐
从客户端到服务器
Financial management [4]
Construction equipment [5]
点的螺旋距离
UNION ALL UNION FULL JOIN
Listen to the markdown file and hot update next JS page
Laravel scheduled task
7-8 循环日程安排问题
UNION ALL UNION FULL JOIN
OpenSSL SSL_read: Connection was reset, errno 10054
文件包含漏洞问题
[JS] - [array application] - learning notes
Gocolly manual
golang map clear
Dig deep into MySQL - resolve the difference between clustered and non clustered indexes
15 lines of code using mathematical formulas in wangeditor V5
Still using simpledateformat for time formatting? Be careful of project collapse
7-3 最大子段和
华为机器学习服务语音识别功能,让应用绘“声”绘色
Installation and deployment of ganglia