How to use a chaincode that s not on github

0 votes

I have developed a chaincode using this and now that I know that it works I want to test it in a network with multiple nodes.

Where should I put my chaincode so that I can deploy it in the Hyperledger fabric network?

I have used this to setup the network.

Aug 3, 2018 in Blockchain by aryya
• 7,460 points
832 views

1 answer to this question.

0 votes

There are two options:

  1. If you are not using a docker image to start your nodes then you should deploy the chaincode by specifying a fully qualified path, in other words, you should set the parameter when deploying:

    -p /home/user/my/awesome/chaincode

  2. If you are running your nodes/peers in a docker image (like the instructions you are following to setup a development network) then you have two options:

    The first one is to put your chaincode inside a folder in the path $GOPATH/src/github.com/hyperledger/fabric/peer. Then you can build your image (go test -run BuildImage_Peer).

    Now the docker image will have the chaincode in its filesystem (you can check it by navigating in it by using docker run --rm -it -e CORE_VM_ENDPOINT=http://172.17.0.1:2375 -e CORE_PEER_ID=vp0 -e CORE_PEER_ADDRESSAUTODETECT=true hyperledger-peer /bin/bash).

    Finally, to deploy the chaincode you have to set the path (parameter -p) to the folder that contains your chaincode, relative to $GOPATH/src/. This path would be: github.com/hyperledger/fabric/peer/yourfolderwiththecc.

    The second option is similar (not tested yet), but it uses a shared filesystem between docker and vagrant to access the chaincode. The idea is to run the docker with something like -v local-dev:localdev, so that local-dev folder in the docker image is linked to vagrant's local-dev folder (where you should put your chaincode) and with -e GOPATH=/local-dev you set the GOPATH so that the relative path can start from the /local-dev folder.

Observation: the path with github.com might be confusing because it seems that it is getting the chaincode from Github, but it is just the folder name.

Important: to deploy a chaincode, only one peer needs to have available the chaincode file (the one where the deploy is sent), as the consensus is responsible of broadcasting the chaincode.

Credits to @ghaskins for his help figuring out how to do it

answered Aug 3, 2018 by charlie_brown
• 7,720 points

Related Questions In Blockchain

+1 vote
1 answer

How to deploy ethereum smart contracts on a website?

There are many ways to do this: 1 ...READ MORE

answered Mar 27, 2018 in Blockchain by Johnathon
• 9,090 points
1,931 views
0 votes
1 answer

How to create a new wallet on a blockchain?

Firstly, you need to have a clear ...READ MORE

answered Apr 4, 2018 in Blockchain by Christine
• 15,790 points
1,358 views
+1 vote
1 answer
0 votes
1 answer

How to read a state after writing it into a chaincode?

Data that is 'written' in chaincode is ...READ MORE

answered May 28, 2018 in Blockchain by Perry
• 17,100 points
2,033 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,906 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,433 views
+1 vote
1 answer

Language in which cryptokitties is programmed?

Cryptokitties is built on the Ethereum network. The ...READ MORE

answered Mar 27, 2018 in Blockchain by Johnathon
• 9,090 points
661 views
0 votes
1 answer

How to store picture(s) in a hyperledger blockchain channel

You can hold images as encrypted characters ...READ MORE

answered Jun 16, 2018 in Blockchain by charlie_brown
• 7,720 points
1,338 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP