Launch Development Environment
Typically, to develop and test chaincode, we need at least 3 terminals opened to:
- Run the peer node(s)
- Run the chaincode (e.g. fabric/examples/chaincode/java/SimpleSample, you should replace with your corresponding chaincode folder)
- Send the query
Below are steps to launch, deploy and test chaincode:
Run the peer node(s)
- Launch Git Bash (the terminal)
- cd $GOPATH/src/github.com/hyperledger/fabric/devenv
- vagrant.exe up
- vagrant.exe ssh
- Now we should be in the terminal of the virtual machine
- cd $GOPATH/src/github.com/hyperledger/fabric
- make peer
- peer node start --peer-chaincodedev
Run the chaincode
- Launch another Git Bash
- cd $GOPATH/src/github.com/hyperledger/fabric/devenv
- vagrant.exe ssh
- Now we should be in the terminal of the virtual machine (2nd terminal)
- Do this only once (the first time)
- cd $GOPATH/src/github.com/hyperledger/fabric/core/chaincode/shim/java
- gradle -b build.gradle clean
- gradle -b build.gradle build
- Do this when we need to build the chaincode
- cd $GOPATH/src/github.com/hyperledger/fabric/... (to the chaincode folder, e.g. fabric/examples/chaincode/java/SimpleSample)
- gradle build
- Do this every time to run the chaincode
- cd $GOPATH/src/github.com/hyperledger/fabric/... (to the chaincode folder, e.g. fabric/examples/chaincode/java/SimpleSample)
- gradle run
Send query to chaincode
- Launch another Git Bash
- cd $GOPATH/src/github.com/hyperledger/fabric/devenv
- vagrant.exe ssh
- Now we should be in the terminal of the virtual machine (3rd terminal)
- cd $GOPATH/src/github.com/hyperledger/fabric/devenv
- Here we can deploy, query, etc. the chaincode