Deploying Hyperledger Fabric Network with Convector

Pulkit Saraf
Akeo
Published in
4 min readDec 20, 2019

“Convector is a development framework for enterprise smart contract systems based in JavaScript. Using convector, it becomes easy for developers to create, test and deploy enterprise-grade smart contract systems.”

Convector is designed in such a way that it helps you write reusable pieces of code using the models and controllers. Giving a brief overview of convector, it is crafted using Typescript.

Convector has two fundamental concepts:

  1. Models: assets in the real world describing its properties. It might be a participant in a network.
  2. Controllers: the business logic that is applied to the models.

You can build everything needed for a chaincode using these two fundamental concepts. Convector has its CLI (Convector CLI) which helps to create the convector smart contract projects faster.

Note: We assume that you have a basic knowledge of Hyperledger Fabric and its deployment. (if not, you can refer to our blog — Setup Hyperledger Fabric Network )

Steps to setup convector and Hyperledger Fabric network

  1. Create a Hyperledger network with your desired number of organizations. Here we have deployed the network with one organization having a single peer.
  2. Run the command mentioned below to check the dockers are in running state.
$ docker ps -a

3. To create a smart contract project, Convector- CLI package should be installed globally. Use the following command to install:

$ npm install -g @worldsibu/convector-cli

4. Create a new project with a chaincode package using the following command:

$ conv new <project_name> -c <chaincode_name>

When you execute the command, it creates a directory named convChaincode and some configuration files in it.

5. Enter into the convChaincode folder and install the packages using the command:

$ npm install

6. You can find the model and controller files in the /packages/test-cc/src folder. More controllers and model files can be added in the same package or a different package can be created in the same chaincode project.

You can write your own chaincode in these model and controller files as per your need.

7. Once you are done with writing the chaincode, go to the root folder of the project and create a package of the chaincode.

$ npm run cc:packakage — <chaincode_name>

You will get a package with name chaincode-<chaincode_name> as here it is chaincode-test.

8. Now to install the chaincode on the peer of organisation. First copy the chaincode package inside the peer docker.

$ docker cp <chaincode_package>/ <peer_container_name>:/var/hyperledger/production/chaincodes/

9. Enter inside the CLI docker using the command:

$ docker exec -it <cli_container_name>bash

10. Export the following configuration in the peer docker:

CORE_PEER_MSPCONFIGPATH=<path_to_peer_user_msp>CORE_PEER_ID=<core_peer_id>CORE_PEER_ADDRESS=<core_peer_address>CORE_PEER_LOCALMSPID=<core_peer_mspid>CORE_PEER_TLS_ROOTCERT_FILE=<path_to_tls_root_cert>

11. Now install the chaincode using the following command inside the peer docker:

peer chaincode install -n <chaincode_name> -v <version_of_chaincode> -p <path_to_chaincode_package> -l <chaincode_language>

If the chaincode is installed successfully, then it you will get a response status 200 as shown in the image below:

12. Instantiate the chaincode at the organisation for the channel inside the peer:

peer chaincode instantiate -C <channel_name> -n <chaincode_name> -v <version_of_chaincode> -c <constructor_message_for_chaincode> -o <orderer_address> — tls — cafile <path_to_orderer_tls>

13. Invoke the transaction using the following command in the peer docker:

peer chaincode invoke -o <orderer_address> — tls — cafile <path_to_orderer_tls> -C <channel_name> -n <chaincode_name> -c <constructor_message_for_chaincode>

If the transaction is invoked successfully, it returns a status code 200 as shown in the image below:

Conclusion

We learnt how to deploy a convector chaincode onto the Hyperledger Fabric network. Convector may help the developers to migrate from Composer as Hyperledger Composer has been officially deprecated.

Note: This is one aspect of Convector where we explained deploying the Convector chaincode on Hyperledger Fabric network.
In the next blog, we will explain how to write the chaincode in convector. Do lookout for that!

--

--