hyperledger fabric 测试(七)1.17链码包生成

智能合约生成链码包:peer chaincode package -n mycc -p github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd -v 0 -s -S -i "AND('OrgA.admin')" ccpack.out 

阿里云的安装包生成命令:peer chaincode package ccpack.out -n mycc -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Args":["init","a","100","b","200"]}' -v 1.0 //蓝色可以省略,打包完成后直接上传至链码平台即可

链码包拥有者进行签名:peer chaincode signpackage ccpack.out signedccpack.out

安装智能合约:peer chaincode install -n asset_mgmt -v 1.0 -p sacc

实例化智能合约:peer chaincode instantiate -n sacc -v 1.0 -c '{"Args":["john","0"]}' -P "AND ('Org1.member','Org2.member')"

删除容器移除链码包:docker rm -f

rm /var/hyperledger/production/chaincodes/:

容器命令帮助:docker run -it hyperledger/fabric-peer bash

代码示意:peer chaincode install -n mycc -v 0 -p path/to/my/chaincode/v0

peer chaincode instantiate -n mycc -v 0 -c '{"Args":["a", "b", "c"]}' -C mychannel

peer chaincode install -n mycc -v 1 -p path/to/my/chaincode/v1

peer chaincode upgrade -n mycc -v 1 -c '{"Args":["d", "e", "f"]}' -C mychannel

peer chaincode query -C mychannel -n mycc -c '{"Args":["query","e"]}'

peer chaincode invoke -o orderer.example.com:7050  --tls --cafile $ORDERER_CA -C mychannel -n mycc -c '{"Args":["invoke","a","b","10"]}'

你可能感兴趣的:(区块链(Blockchain),hyperledger)