1.跨链合约部署
broker合约是管理合约,transfer合约是业务交易合约,需要说明的是 transfer合约需要经过broker合约审核通过后才能发起或接受跨链交易,
具体方法是:调用broker合约的audit方法,其参数依次是业务合约地址和合约状态(数字1表示审核通过,数字2表示审核失败)。
安装和实例化broker合约
peer chaincode install -n broker -v 1.0 -p github.com/hyperledger/fabric/peer/chaincode/src/src/github.com/pier-client-fabric/example/contracts/src/broker
peer chaincode instantiate -o orderer.cpsec.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/cpsec.com/orderers/orderer.cpsec.com/msp/tlscacerts/tlsca.cpsec.com-cert.pem -C cpsec -n broker -v 1.0 -c '{"Args":["init","ccp", "broker", "ccid","broker"]}'
#安装和示例化transfer合约
peer chaincode install -n transfer -v 1.0 -p github.com/hyperledger/fabric/peer/chaincode/src/src/github.com/pier-client-fabric/example/contracts/src/transfer
peer chaincode instantiate -o orderer.cpsec.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/cpsec.com/orderers/orderer.cpsec.com/msp/tlscacerts/tlsca.cpsec.com-cert.pem -C cpsec -n transfer -v 1.0 -c '{"Args":["init","ccp", "transfer", "ccid","transfer"]}'
#业务合约需要broker管理合约审计后,才能进行跨链交易
peer chaincode invoke -o orderer.cpsec.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/cpsec.com/orderers/orderer.cpsec.com/msp/tlscacerts/tlsca.cpsec.com-cert.pem -C cpsec -n broker --peerAddresses peer0.org1.cpsec.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.cpsec.com/peers/peer0.org1.cpsec.com/tls/ca.crt -c '{"Args":["audit","cpsec","transfer","1"]}'