hyperledger fabric chaincode 教程二

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u011439012/article/details/78991447


# 下面将自己写好的chaincode部署并且实例化到fabric:


## 首先把写好的chaincode copy 到 cli
```
命令参考:docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH
docker cp /chaincode/bdata/ 3a113b6c0ecf:/opt/gopath/src/github.com/hyperledger/fabric/examples/chaincode/go
```
## 安装  bdatas ====
```
peer chaincode install -n bdata -v1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/bdata
```
## 实例化 bdatas ====
```
peer chaincode instantiate -n bdata -v1.0  -c '{"Args":["initbdata","bdata1","blue","hashcode","tom"]}' -C  mychannel
```
## 在实例化的时候代码有错误,原因是属性名称识别大小写的。
改正后需要升级chaincode
```
peer chaincode install -n bdata -v2.0 -p github.com/hyperledger/fabric/examples/chaincode/go/bdata
```


### // ====CHAINCODE 使用 示例 (CLI) ===
```
// ==== 安装  bdatas ====
//peer chaincode install -n bdata -v 4.0 -p github.com/hyperledger/fabric/examples/chaincode/go/bdata
// ==== 实例化 bdatas ====
//ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/tlsca/tlsca.example.com-cert.pem
//peer chaincode instantiate -o orderer.example.com:7050 --tls true --cafile $ORDERER_CA  -n bdata -v 4.0 -c '{"Args":["initbdata","bdata1","blue","hashcode","tom"]}'  -P "OR    ('Org1MSP.member','Org2MSP.member')"  -C mychannel
```

猜你喜欢

转载自blog.csdn.net/u011439012/article/details/78991447
今日推荐