Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Blockchain by (4.1k points)

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.

1 Answer

0 votes
by (14.4k points)

There are two options for doing this successfully.

In case you are not using a docker image for starting your nodes, 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

If you are running your nodes/peers in a docker image 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

Finally, to deploy the chaincode you have to set the path (parameter -p) to the folder in which your chaincode is contained, relative to $GOPATH/src/. This path is:

github.com/hyperledger/fabric/peer/yourfolderwiththecc.

The second option is similar but it uses a shared filesystem between docker and vagrant to access the chaincode. The idea is to run the docker so that the local-dev folder in the docker image is linked to the vagrant's local-dev folder. And, with  -e GOPATH=/local-dev you set the GOPATH so that the relative path can start from the /local-dev folder.

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.1k users

Browse Categories

...