DL Fabric Gateway™ User Guide— Section 6

This post is part of the ‘DL Fabric Gateway™ User Guide’ originally published as

This post continues our ongoing discussion regarding chaincode installation on DL Fabric Gateway™.

Installing Chaincode on DL Fabric Gateway™

Installing chaincode allows you to upload your code to the Fabric network, which can then be deployed (instantiated) onto channels of your choosing.

Goal

Install chaincode on DL Fabric Gateway™ using the fab_installChaincodeAPI:

POST
https://dlfabricnetwork.dltlabs.com/api/1.0/fab_installChaincode

Step 1

Open a Command Line Interface (CLI) of your choice (Terminal, cmd, etc.)

Step 2

Install curl (if not already installed): Download links — Linux/Windows

Step 3

Copy and paste the following API Call into your CLI of choice, and tap “enter” on your keyboard

curl -X POST \
‘https://dlfabricnetwork.dltlabs.com/api/1.0/fab_installChaincode' \
-H ‘Content-Type: application/json’ \
-H ‘Authorization: AUTH_TOKEN_HERE’ \
-d ‘{
“userName” : “your@email.com”,
“chaincodeName” : “YourChaincodeName”,
“code”: “BASE64_ENCODED_CHAINCODE (will be very long)”,
“chaincodeType” : “golang”,
“chaincodeVersion” :”v1"
}’

In the command line, BASE64_ENCODED_CHAINCODE will be the long string that we generated in Step 7 of “Converting Chaincode to Base64”.

Example:

Image for post
Image for post

Which will return a success response:

{
“status”: “success”,
“message”: “Successfully installed chaincode.”
}

Notice that we have set chaincodeType to: “golang”, since we are using Golang and not Node.js, and that our chaincodeVersion is set to: “v1”. We will go over the chaincode upgrade process in a future section, where chaincodeVersion becomes important.

Additional Details: Chaincode Prerequisites

>> IMPORTANT — In order to deploy any Chaincode, the user must have joined at least 1 channel.

Chaincode is typically coded using Golang or Node.js. Using DL Fabric Gateway™, the user can create and execute chaincode by instantiating it on a channel.

Although the Hyperledger Fabric network offers support to Node.js as well as Golang, our preferred choice is the latter. The reasons why we prefer Golang as our chaincode execution language is as follows:

  1. The execution time is at least 3 times faster than Node.js.
  2. Interprets errors in chaincode before compilation.

In order to demonstrate, we have elected to use the Fab Car chaincode (written in Golang), for which the code is available at the link below:

https://github.com/hyperledger/fabric-samples/blob/release-1.2/chaincode/fabcar/go/fabcar.go

Once we have obtained the Fab Car chaincode, we must convert it to Base64 format in order to use it with DL Fabric Gateway™.

To access the conversion steps, please follow the link: https://medium.com/@dltlabs/dl-fabric-gateway-overview-section-4-69d2b0a79657

Base64 conversion can be done using any conversion tool. The link to one of the most used online Base64 converters is: https://www.base64encode.org/

Image for post
Image for post

Written by

DLT Labs is a global leader in Distributed Ledger Technology and Enterprise Products. To know more, head over to: https://www.dltlabs.com/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store