Hyperledger fabric部署链码(二)安装链码到fabric

打包智能合约asset-transfer (basic)后,我们就可以在peer上安装链码。链码需要安装在每一个为交易背书的peer节点上。由于我们的测试网络设置的背书策略,要求来自 Org1 和 Org2 的背书,因此我们需要在这两个组织运营的peer节点上安装链码:

  • peer0.org1.example.com
  • peer0.org2.example.com
    我们先在Org1 peer安装链码,设置Org2 peer的环境变量
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/[email protected]/msp
export CORE_PEER_ADDRESS=localhost:7051

用命令peer lifecycle chaincode install在peer上安装链码

peer lifecycle chaincode install basic.tar.gz

如果命令成功,peer将生成并返回软件包标识符。该软件包标识符将在下一步中用于批准链码。您应该会看到类似下面的输出:

2020-07-16 10:09:57.534 CDT [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:
2020-07-16 10:09:57.534 CDT [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: basic_1.0:e2db7f693d4aa6156e652741d5606e9c5f0de9ebb88c5721cb8248c3aead8123

接下来我们在Org2 peer安装链码,设置Org2 peer的环境变量

export CORE_PEER_LOCALMSPID="Org2MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org2.example.com/users/[email protected]/msp
export CORE_PEER_ADDRESS=localhost:9051

在Org2 peer上安装链码

peer lifecycle chaincode install basic.tar.gz

你可能感兴趣的:(fabric,区块链,golang,智能合约)