I want to install custom chaincode on my hyperledger fabric channel. I put my chaincode.go file besides of my .yaml files .when I run this command :
peer chaincode install -n mycc -v 1.0 -p github.com/chaincode/chaincode_example02/go/
I got this error:
Error: error getting chaincode code mycc: path to chaincode does not
exist: /opt/gopath/src/github.com/chaincode/chaincode_example02/go
I do not know where is opt/gopath or how to address the chaincode.go file?
please help me
When you launch your network (if you are using the first-network template), you bring up a container 'CLI', you can find it in docker-compose-cli.yaml
This container is used to operate on the differents nodes of the architecture.
You need to create a volume who match your chaincode path like so
Then, when the container 'cli' goes up, you can enter into it with
docker exec -it cli bash
Now you can navigate to your path and see your chaincode directory.
And do your command :
peer chaincode install -n mycc -v 1.0 -p path/define/in/your/volume/section/to/your/chaincode
Related
I am trying to develop a supply chain application using Hyperledger Fabric.
During development, I am using Hyperledger Fabric Test Network and I added a 3. organization using "addOrg3.sh" command. All the codes I used when I start the network are listed below.
cd ../test-network
./network.sh down
docker rm -f $(docker ps -aq)
./network.sh up createChannel -ca -s couchdb
cd addOrg3
./addOrg3.sh up -c mychannel -ca -s couchdb
export FABRIC_CFG_PATH=$PWD
../../bin/configtxgen -printOrg Org3MSP > ../organizations/peerOrganizations/org3.example.com/org3.json
cd ..
./network.sh deployCC -ccn SupplychainContract -ccp ../supply-chain/chaincode/ -ccl javascript -ccep "OR('Org1MSP.peer','Org2MSP.peer','Org3MSP.peer')"
export PATH=${PWD}/../bin:$PATH
export FABRIC_CFG_PATH=$PWD/../config/
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
cd ../supply-chain/server
rm -r ./wallet/*
node enrollAdmin.js org1 admin adminpw
node enrollAdmin.js org2 admin adminpw
node enrollAdmin.js org3 admin adminpw
chmod 777 wallet
chmod 777 ./wallet/*
However, on the running project, while using a wallet belonging to the org3 network, I can run submitTransaction command on the chaincode without any problem, but when I try to run the evaluateTransaction command, it gives an error as follows.
ERROR MESSAGE: 2022-12-07T12:45:38.620Z - error: \[SingleQueryHandler\]: evaluate: message=Query failed. Errors: \["Error: Peer peer0.org3.example.com:11051 is not running chaincode SupplychainContract"\], stack=FabricError: Query failed. Errors: \["Error: Peer peer0.org3.example.com:11051 is not running chaincode SupplychainContract"\]
When I call the related method using submitTransaction , there is no problem. if i use docker-compose -f ./compose/docker/docker-compose-org3.yaml up -d while raising the network, it conflicts with another container produced by addOrg3.sh .
How can I solve this problem?
I think the issue you are seeing is because the default query handler implementation prefers the client's org peers, and it also returns (either a result or an error) from the first peer it is able to successfully invoke. Your org3 client evaluates the transaction on the org3 peer, which responds with an error saying the smart contract is not deployed there.
The submit implementation is more complex and will use service discovery to identify peer that can satisfy the endorsement policy for a given chaincode, so will not attempt to use the org3 peer.
Using Fabric v2.2, your best options are probably either:
Deploy the chaincode on the org3 peer; or
Implement your own query handler that provides appropriate behaviour.
This tutorial page describes how to configure an alternative query handler and how to write a custom query handler:
https://hyperledger.github.io/fabric-sdk-node/release-2.2/tutorial-query-peers.html
A possible approach would be for your handler to use all network peers and to keep trying peers until it either receives an endorsed response or has tried all available peers.
If you can use Fabric v2.4 (or later), you should consider using the Fabric Gateway client API instead. This will just work without any additional configuration.
I am following the documentation (https://hyperledger-fabric.readthedocs.io/en/latest/test_network.html) to deploy a test network for Fabric on Ubuntu 16.04 on Amazon Lightsail. All commands have been executed successfully with results as expected until
./network.sh deployCC -l javascript
The following error message is received:
Error: endorsement failure during invoke. response: status:500 message:"error in simulation: failed to execute transaction 2554869d3683a7e77202f448aa201fd2f97243faa4ff5dd4839eb8d3175cf53b: could not launch chaincode fabcar_1:bec08b518fdb2bda0a0fb41a4a6f996a87ba08887583febedbc791cba7e91537: chaincode registration failed: container exited with 0" !!!!!!!!!!!!!!! Invoke execution on peer0.org1 peer0.org2 failed !!!!!!!!!!!!!!!!
Any assistance will be tremendously appreciated.
K
For fabcar sample, you can use startFabric.sh script inside fabcar to deploy chaincode with the language that you want. Specifically run ./startFabric.sh javascript in your case.
This script generally runs ./network.sh with some additional network cleanups.
everything is working as expected now. The issue had been with system sizing - increasing the memory to 4GB RAM fixed it
Thank you everyone for your suggestions.
K
I am assuming that you are doing a fresh installation.First stop all the containers if it's not stop.
docker stop $(docker ps -a -q)
After that remove the unused volume using the command.
docker volume prune
or docker system prune to remove any unused data.
You have to remove the certificates manually(if it's not deleted).First of all execute the ./network.sh down command.Then go into the test-network/organizations and remove the content of peerOrganizations and ordererOrganizations
Then move to the fabric-ca directory and remove the content of org1 ,org2 and ordererOrg, keep in mind that in here you don't have to remove any .yaml file.
And remove the fabcar.tar.gz package in test network.
Now start the network using the commands below:
./network.sh up createChannel -ca -c mychannel -s couchdb -i 2.0.0
./network.sh deployCC -l javascript
I have the same problem with javascript chaincode (it works 2 days ago, having the same error now), but deployCC with golang (weirdly) doesn't have this problem. So if using javascript is not a requirement you can also just run ./network.sh deployCC
Shut down your network. Then start it again. Then create a channel and deploy your chaincode. It will work.
I was getting same error because I created a named channel first and tried to deployed code there with -c. But when I shutdown and performed all steps again with default "mychannel" and it worked fine for me.
I am following a hyperledger composer tutorial.
I am not able to execute step 15. while executing command :
composer identity request -c PeerAdmin#byfn-network-org1-only -u admin -s adminpw -d alice
I am getting the following error:
Error: failed to request identity. Error trying to enroll user and
return certificates. Error: Calling enrollment endpoint failed with
error [Error: connect ECONNREFUSED 127.0.0.1:7054]
When I checked the running containers, CA is not running.. If this is the case then i don't understand why there isn't a command to start CA in the byfn script.
Can anyone suggest a workaround to make the above command execute please?
This Composer Tutorial uses a modified version of byfn.sh which has a -a option to start the CA.
Be sure to clone the specific repo as follows:
git clone -b issue-6978 https://github.com/sstone1/fabric-samples.git
and then start byfn with the -a option: ./byfn.sh -m up -s couchdb -a
Or you can start fabric-ca manually by fabric-ca-server start -b admin:$ADMIN_PASSWORD command
Thanks
Kiran Thakkar
I followed this suggestion and succeeded. Please try:
Something wrong on deploy chaincode for hyperledger v1.0
Instruction: looking for the IP adress of your docker and replace to 'localhost' in all files: enrollAdmin.js, invoke.js...
I'm trying Hyperledger Composer v0.16.0. According to this procedure, I want to Deploy BNA to Fabric network on cloud. but following error occurs.
Kindly let me know how I can solve it.
command:
composer network start --card PeerAdmin#myfabric --networkAdmin admin --networkAdminEnrollSecret adminpw --archiveFile trade-network.bna --file networkadmin.card
result:
tarting business network from archive: trade-network.bna
Business network definition:
Identifier: trade-network#0.1.13
Description: Commodities Trading Business Network
Processing these Network Admins:
userName: admin
✖ Starting business network definition. This may take a minute...
Error: Error trying to instantiate composer runtime. Error: No valid responses from any peers.
Response from attempted peer comms was an error: Error: chaincode error (status: 500, message: chaincode instantiation policy violated(Failed to authenticate policy))
Error: No valid responses from any peers may be b/c you don't ./startFabric (in fabric-tools folder) or may be the .acl file (permissions.acl) have error (try change it to the beginning version).
The error 'Error: Error trying to instantiate composer runtime.' Suggests you have not run the composer runtime install command e.g.
composer runtime install -c PeerAdmin#fabric-network -n tutorial-network
Or that the command did not complete successfully.
The other possibility is that your fabric has stopped or is not contactable.
The runtime must be installed on fabric for the network to start.
"composer runtime install -c PeerAdmin#hlfv1 -n "
The Steps:
1) ./startFabric.sh,
2) ./createPeerAdminCard.sh,
3) composer runtime install -c PeerAdmin#hlfv1 -n ,
4) composer network start -a ./#0.0.1.bna -A admin -S adminpw -c PeerAdmin#hlfv1
there seems to be some challenges / bug with the use of composer
Composer Updates : 0.19.0 Changes:
End of March developers of Composer framework released version 0.19.0. Although there are multiple new features (mostly under the covers) in this release, it also introduced some BREAKING changes :( So what does that mean? It means that:
Some of the composer CLI commands have become obsolete or have changed
BNA Installation commands have changed ( install + start )
Following Composer CLI commands have been removed
runtime install, network deploy, network update, network undeploy
BNA upgrade requires an install of new version followed by
Composer card commands standardised to use -c or --card. Earlier some commands used -n and some used -c
Some of the Composer API have changed
That error can mean that the identity you are using to perform a network start doesn't have channel admin authority and thus is not authorised to perform a network start. I would suggest you check with whoever created your Hyperledger Fabric environment and channel to find out who the right identities are for administrative authority on the channel and build a card with the appropriate crypto material representing that identity in order to perform a network start.
1. ./stopFabric.sh
2. export FABRIC_VERSION=hlfv11
3. ./startFabric.sh
4. ./createPeerAdminCard.sh
5. install network
6. start network
Please create a new card with your business network name. Hopefully it will work:
composer network start --card PeerAdmin#myfabric --networkAdmin admin --networkAdminEnrollSecret adminpw --archiveFile trade-network.bna --file trade-network.card
I came up with a solution to my problem, which is similar to yours, it might be useful to you too:
I noticed that with other networks it works properly so, there is a problem with the DNS:
Edit or create /etc/docker/daemon.json in your machine and add:
{ "dns": ["your dns", "8.8.8.8"] }
Stop Fabric, restart Docker, Start Fabric
Repeat composer install and composer start
Well i was getting the similar error :-
Upgrading business network definition. This may take a minute...
Error: Error trying to upgrade business network. Error: No valid responses from any peers.
Response from attempted peer comms was an error: Error: 2 UNKNOWN: chaincode error (status: 500, message: could not find chaincode with name 'airlinev9')
Command failed
My composer version: v0.19.4
What I was trying to do:-
I was trying the update my BNA to a newer version. But got the error which i shown you above.
What I did to solve the issue :-
I first deleted the previous card using the command :-
composer card delete -c admin#airlinev9
And then start the BNA with (already created, installed):-
composer network start -c PeerAdmin#hlfv1 -n airlinev9 -V 0.0.3 -A
admin -S adminpw
And it worked for me.
I am SUPER new to HyperLedger hence I am not sure on how it worked out me but just in case might work for you too so try it out. I did only 2 things((on fabric-tool directory) :
1) ./startFabric.sh
2) ./createPeerAdminCard.sh
Ok I agree I lied. Not 2 things but 3.
3) Retry .bna association as expected normally.
I hope it works for you too :)
I am working on this tutorial http://hyperledger-fabric.readthedocs.io/en/latest/build_network.html
To Create and Join Channel i am trying to run following peer command :
peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
I am connected to container as well after executing docker exec -it cli bash. Even i have tried ./peer but i am still getting no peer directory exist or peer command not found
This may be due to relative path is not correct, where peer binary is stored. You can find it inside hyperledger/fabric/build/bin. Once you locate the peer binary export it using.
e.g. export PATH=$PATH:$GOPATH/src/github.com/hyperledger/fabric/build/bin/
Then try to create channel using commands you are using.