環境:fabric v2.2.0
執行fabric-sampke/test-network
中賬本互動指令的時報錯
peer chaincode query -C mychannel -n basic -c '{"Args":["ReadAsset","asset6"]}'
報錯如下:
Cannot run peer because cannot init crypto, specified path "/home/yujialing/go/src/github.com/hyperledger/fabric-samples/config/msp" does not exist or cannot be accessed: stat /home/yujialing/go/src/github.com/hyperledger/fabric-samples/config/msp: no such file or directory
原因是沒有設定環境變數,以網路中的某個組織的某個節點進行互動
比如設定環境變數成為Org1
Peer0
的角色
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
export CORE_PEER_ADDRESS=localhost:7051
再次執行賬本互動指令
peer chaincode query -C mychannel -n basic -c '{"Args":["ReadAsset","asset6"]}'
成功解決Cannot run peer because cannot init crypto, specified path "/home/yujialing/go/src/github.com/hyperledger/fabric-samples/config/msp" does not exist or cannot be accessed: stat /home/yujialing/go/src/github.com/hyperledger/fabric-samples/config/msp: no such file or directory
的問題
歡迎小夥伴的討論,若有問題請在評論區評論或私信,謝謝你。