打包智能合约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/Admin@org1.example.com/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:<status:200 payload:"\nJbasic_1.0:e2db7f693d4aa6156e652741d5606e9c5f0de9ebb88c5721cb8248c3aead8123\022\tbasic_1.0" >
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/Admin@org2.example.com/msp
export CORE_PEER_ADDRESS=localhost:9051
在Org2 peer上安装链码
peer lifecycle chaincode install basic.tar.gz