error getting chaincode code mycc: path to chaincode does not exist - hyperledger-fabric

I'm doing this tutorial: https://hyperledger-fabric.readthedocs.io/en/latest/build_network.html
Now I am on my Peer and want to Install & Instantiate Chaincode.
For this I am doing:
root#23096337731b:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/go/
But then I get this output:
2019-01-31 08:01:44.988 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-01-31 08:01:44.988 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Error: error getting chaincode code mycc: path to chaincode does not exist: /opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/go
Update:
I think it's because I'm doing this:
peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/go/
And the compiler thinks that the github link is a local directory.

The key point is the place where you put the chaincode must be mounted exactly.
In the tutorial source code, when you read the file docker-compose-cli.yaml, you will see this line
volumes
- ./../chaincode/:/opt/gopath/src/github.com/chaincode
./../chaincode is the path to the chaincode folder
One more thing, if you choose golang for the chaincode, the path when you call install chaincode will be shorter (read more):
# this installs the Go chaincode. For go chaincode -p takes the relative path from $GOPATH/src
peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/go/
Node.js version:
# this installs the Node.js chaincode
# make note of the -l flag to indicate "node" chaincode
# for node chaincode -p takes the absolute path to the node.js chaincode
peer chaincode install -n mycc -v 1.0 -l node -p /opt/gopath/src/github.com/hyperledger/fabric-samples/chaincode/chaincode_example02/node/

First you need to check if the chaincode is on that folder. Also the path for a go chaincode has to be relative to the gopath.

Related

How to list chaincode?

I'm able to follow https://hyperledger-fabric.readthedocs.io/en/release-2.2/test_network.html
$ peer chaincode invoke ... -c '{"function":"InitLedger","Args":[]}'
2021-08-23 17:52:59.534 PST [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
I leanred peer chaincode list can list chaincodes, but the following commands don't give expected result.
$ peer chaincode list -C mychannel --installed
Get installed chaincodes on peer:
$ peer chaincode list -C mychannel --instantiated
Get instantiated chaincodes on channel mychannel:
Given I've successfully deployed the basic chaincode, how do I see it through peer chaincode list?
I think issue, will be with the path that is getting set. Make sure to export the following peer path where chaincode is installed :-
FABRIC_LOGGING_SPEC
CORE_PEER_MSPCONFIGPATH
CORE_PEER_LISTENADDRESS
CORE_PEER_LOCALMSPDIR
If tls is enabled, export the following path along with the paths above
CORE_PEER_TLS_ENABLED
CORE_PEER_TLS_KEY_FILE
CORE_PEER_TLS_CERT_FILE
CORE_PEER_TLS_ROOTCERT_FILE
And then try the commands
peer chaincode list --installed
peer chaincode list --instantiated -C mychannel
If you want to just view the installed chaincode below is the command for the HLF2.2x
peer lifecycle chaincode queryinstalled --peerAddresses localhost:7051
--tlsRootCertFiles $CORE_PEER_TLS_ROOTCERT_FILE
If you want to view the commited chaincode list below is the command
peer lifecycle chaincode querycommitted --channelID channelName
in HLF2.2x chaincode lifecycle is introduced. So if you want to execute chaincode you need to approve and commit after installed on peer.

Hyperledger fabric 1.4 Error on Instantiate chaincode

Setting up Built Your First Network (BYFN), after creating and joining Channel, chaincode is installed on both organization peers using following cli command -
peer chaincode install -n mycc -v 1.0 -p github.com/chaincode/chaincode_example02/go/
Chaincode Installation is successful.
While I tried to Instantiate chaincode from the CLI using following command given by HLF document.
The following error occurred while Instantiate the chaincode in Hyperledger fabric v 1.4.
root#8804d95b7083:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n mycc -v 1.0 -c '{"Args":["init","a", "100", "b","200"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')"
Error: must supply value for chaincode name parameter
Usage:
peer chaincode instantiate [flags]
Flags:
-C, --channelID string The channel on which this command should be executed
--collections-config string The fully qualified path to the collection JSON file including the file name
Is there any alternative way to resolve this error other than re-setup the Network?
There is a conflict with the CLI command there. You used go cli command for installing the chaincode and NodeJS cli command for instantiating the chaincode.

Chaincode path does not exist

Problem:
I have set up a Hyperledger Fabric network. When I try to install a chaincode it is only installed in the first peer. But when I try to install chaincode on other peers it was failed by saying that chaincode does not exist.
This is the command I issued on the first peer.
peer chaincode install -n fabcar -v 1.0.0 -l node -p /opt/gopath/src/github.com/chaincode/fabcar/javascript-low-level
This is the output after the command.
2020-03-01 07:27:26.245 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-03-01 07:27:26.245 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2020-03-01 07:27:26.705 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:
This is the command I issued on the second peer.
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/doctor.hrm.com/users/Admin#doctor.hrm.com/msp CORE_PEER_ADDRESS=peer1.doctor.hrm.com:10051 CORE_PEER_LOCALMSPID="DoctorMSP" CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/doctor.hrm.com/peers/peer1.doctor.hrm.com/tls/ca.crt peer chaincode install -n fabcar -v 1.0.0 -l node -p /opt/gopath/src/github.com/fabcar/javascript-low-level
This is the error that was given to me.
2020-03-01 07:34:28.268 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-03-01 07:34:28.268 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Error: error getting chaincode code fabcar: path to chaincode does not exist: /opt/gopath/src/github.com/fabcar/javascript-low-level
Can someone help me with this to find the issue?
Check your GOPATH set in cli container docker-compose.yaml file.
If GOPATH=/opt/gopath then you should give path inside src folder. So you should give path in peer chaincode install as github.com/fabcar/javascript-low-level
so your command will be
peer chaincode install -n fabcar -v 1.0.0 -l node -p github.com/chaincode/fabcar/javascript-low-level
so check your GOPATH set in cli container of docker-compose.yaml and accordingly set the path in peer chaincode install command

Hyperledger -- Contract instantiation issue

I am trying to instantiate the java contact in Commercial Paper Tutorial and get the following error in the monitor.
There is no issue while installing the chain code.
Command run:
docker exec cliMagnetoCorp peer chaincode instantiate -n papercontract -v 0 -l java -c '{"Args":["org.papernet.commercialpaper:instantiate"]}' -C mychannel -P "AND ('Org1MSP.member')"
Error:
peer0.org1.example.com|2019-12-19 00:10:10.220 UTC [endorser] SimulateProposal -> ERRO 045 [mychannel][7cd11866] failed to invoke chaincode name:"lscc" , error: container exited with 1
Please help on what i should do to resolve the error.
Never mind. Fixed the issue.
Changed the build.gradle entry for fabric-chaincode-shim version from 1.4.2 to 1.4.4
compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.4.4'

Upgrade ChainCode Fabric

This is command that am using
docker exec cli\
peer chaincode upgrade \
-o orderer.pk.snowshadow.me:7050 \
-C mychannel -n mycc -c '{"Args": []}'\
-p "basic-network/chaincode" \
-v 1.3 \
>&upgrade.log
this is what am getting in upgrade.log
2018-11-19 13:47:41.501 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001[0m Using default escc
2018-11-19 13:47:41.501 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002[0m Using default vscc
Error: could not assemble transaction, err Proposal response was not successful, error code 500, msg cannot get package for chaincode (mycc:1.3)
Did you install the new version of your chaincode before upgrade?
If you did't, try this before the upgrade command:
peer chaincode install -n mycc -v 1.3 -p basic-network/chaincode
If you did so, the error may be for some of this reasons:
1- The path parameter must be passed on the instalation I never used it in an upgrade operation, and I also don't use quotation marks on them.
2- Try passing the args like this: '{"Args":[""]}'

Resources