1.启动网络
sudo ./network.sh up
2.创建通道
sudo ./network.sh up createChannel
3.在/fabric-samples/chaincode目录下克隆合约
cd ../chaincode/
git clone https://gitee.com/kernelHP/hyperledger-fabric-contract-java-demo.git
4.在test-network路径下安装合约
cd ../test-network
export PATH=${
PWD}/../bin:$PATH
export FABRIC_CFG_PATH=$PWD/../config/
5.创建链码包
peer lifecycle chaincode package hyperledger-fabric-contract-java-demo.tar.gz --path ../chaincode/hyperledger-fabric-contract-java-demo/ --lang java --label hyperledger-fabric-contract-java-demo_1
查看是否打包成功
ls -ll
6.安装链码包
org1 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节点安装链码文章来源:https://www.toymoban.com/news/detail-804983.html
peer lifecycle chaincode install hyperledger-fabric-contract-java-demo.tar.gz
这个过程比较慢,不要着急,此时这里显示rror: chaincode install failed with status: 500 - error in simulation: failed to execute transaction 58d14eea40e7aa9f6f5f56c76a3e5cdca7bd9a3525d2d418459461590853926b: error sending: timeout expired while executing transaction
不要着急,超时了,可以等一会儿,可以在另个终端的chaincode/hyperledger-fabric-contract-java-demo
目录下看一下下载过程。文章来源地址https://www.toymoban.com/news/detail-804983.html
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b6939678664a hyperledger/fabric-javaenv:2.4 "/bin/sh -c ./build.…" About a minute ago Up About a minute busy_heyrovsky
395ee1d9145d hyperledger/fabric-tools:latest "/bin/bash" 3 minutes ago Up 3 minutes cli
cea8c8a7cfa2 hyperledger/fabric-peer:latest "peer node start" 3 minutes ago Up 3 minutes 0.0.0.0:7051->7051/tcp, :::7051->7051/tcp, 0.0.0.0:9444->9444/tcp, :::9444->9444/tcp peer0.org1.example.com
9ee34fd89972 hyperledger/fabric-orderer:latest "orderer" 3 minutes ago Up 3 minutes 0.0.0.0:7050->7050/tcp, :::7050->7050/tcp, 0.0.0.0:7053->7053/tcp, :::7053->7053/tcp, 0.0.0.0:9443->9443/tcp, :::9443->9443/tcp orderer.example.com
3cbd835434a4 hyperledger/fabric-peer:latest "peer node start" 3 minutes ago Up 3 minutes 0.0.0.0:9051->9051/tcp, :::9051->9051/tcp, 7051/tcp, 0.0.0.0:9445->9445/tcp, :::9445->9445/
到了这里,关于fabric编写第一个合约,Java的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!