fabric writes the first contract, Java

1. Start the network

sudo ./network.sh up

2. Create a channel

sudo ./network.sh up createChannel

3. Clone the contract in the /fabric-samples/chaincode directory

cd ../chaincode/
git clone https://gitee.com/kernelHP/hyperledger-fabric-contract-java-demo.git

Insert image description here

4. Install the contract under the test-network path

cd ../test-network
export PATH=${
   
    
    PWD}/../bin:$PATH
export FABRIC_CFG_PATH=$PWD/../config/

5. Create chaincode package

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

Check whether packaging is successful

ls -ll 

6. Install the chaincode package

org1 peer node installs chaincode package

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 node installation chain code

peer lifecycle chaincode install hyperledger-fabric-contract-java-demo.tar.gz 

This process is relatively slow, so don't worry. At this time, it says don't worry. It has timed out. You can wait for a while. You can check the download process in the directory rror: chaincode install failed with status: 500 - error in simulation: failed to execute transaction 58d14eea40e7aa9f6f5f56c76a3e5cdca7bd9a3525d2d418459461590853926b: error sending: timeout expired while executing transaction of another terminal .chaincode/hyperledger-fabric-contract-java-demo

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/

Guess you like

Origin blog.csdn.net/weixin_42375493/article/details/125216647