cryptogen generate --config=./crypto-config.yaml
configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID ${CHANNEL_NAME}
// 組織Org1的錨節點 configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID ${CHANNEL_NAME} -asOrg Org1MSP // 組織Org2的錨節點 configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID ${CHANNEL_NAME} -asOrg Org2MSP
peer channel create -o orderer.example.com:7050 -c ${CHANNEL_NAME} -f ./channel-artifacts/channel.tx --tls ${CORE_PEER_TLS_ENABLED} --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
cli錯誤提示: Error: got unexpected status: FORBIDDEN -- Failed to reach implicit threshold of 1 sub-policies, required 1 remaining: permission denied 容器內部提示: UTC [cauthdsl] deduplicate -> ERRO 014 Principal deserialization failure (the supplied identity is not valid: x509: certificate signed by unknown authority (possibly because of "x509: ECDSA verification failure" while trying to verify candidate authority certificate "ca.org1.example.com")) for identity
錯誤緣由:因爲啓動過網絡而且更新了證書,在沒有刪除乾淨的環境中啓動複用的以前的volume,因此致使證書認證失敗。git
解決方案:github
$ docker-compose -f docker-compose-cli.yaml -f docker-compose-couch.yaml down --volumes Stopping cli ... done Stopping peer1.org2.example.com ... done Stopping peer0.org2.example.com ... done Stopping orderer.example.com ... done Stopping peer0.org1.example.com ... done Stopping peer1.org1.example.com ... done Removing cli ... done Removing peer1.org2.example.com ... done Removing peer0.org2.example.com ... done Removing orderer.example.com ... done Removing peer0.org1.example.com ... done Removing peer1.org1.example.com ... done Removing network net_byfn Removing volume net_peer0.org2.example.com Removing volume net_peer1.org2.example.com Removing volume net_peer1.org1.example.com Removing volume net_peer0.org1.example.com Removing volume net_orderer.example.com
peer channel join -b mychannel.block
peer channel list
peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
docker exec peer0.org1.example.com ls /var/hyperledger/production/chaincodes
peer chaincode instantiate -o orderer.example.com:7050 --tls ${CORE_PEER_TLS_ENABLED} --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n mycc -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "OR('Org1MSP.member','Org2MSP.member')"
peer chaincode query -C $CHANNEL_NAME -nmycc -c '{"Args":["query","a"]}' peer chaincode query -C $CHANNEL_NAME -nmycc -c '{"Args":["query","b"]}'
peer chaincode invoke -oorderer.example.com:7050 --tls ${CORE_PEER_TLS_ENABLED}--cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C ${CHANNEL_NAME} -n mycc -c'{"Args":["invoke","a","b","10"]}'