DL Fabric Gateway™ User Guide— Section 5

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

This post continues our ongoing discussion regarding chaincode conversion to Base64 outside of DL Fabric Gateway™.

Converting Chaincode to Base64

Goal

Convert Chaincode to Base64 in order to install on DL Fabric Gateway™.

The following steps take place outside the DL Fabric Gateway™ Platform. These steps, however, are still required to fully utilize the functionality provided by DL Fabric Gateway™.

Step 1

Open any web browser, preferably Google Chrome. If Google Chrome is not available, any modern browser will also work.

Step 2

In the web browser address bar, enter https://github.com/hyperledger/fabric-samples/blob/release-1.2/chaincode/fabcar/go/fabcar.go.

Step 3

Copy all of the text in fabcar.go to your clipboard (ctrl + c)

Step 4

Open a new tab, and in the web browser address bar, enter https://www.base64encode.org/. You should see the following:

Image for post
Image for post

Step 5

Select “Encode” at the top

Step 6

Paste all of the code copied in Step 3 in the topmost text-box, as in the image below (ctrl + v)

Image for post
Image for post

Step 7

Click “> ENCODE <” (visible in the image above). You will see the Base64 encoding of the chaincode in the lower textbox.

*Note

For your benefit, we have also provided the Base64 formatted chaincode:

LyoKICogTGljZW5zZWQgdG8gdGhlIEFwYWNoZSBTb2Z0d2FyZSBGb3VuZGF0aW9uIChBU0YpIHVuZGVyIG9uZQogKiBvciBtb3JlIGNvbnRyaWJ1dG9yIGxpY2Vuc2UgYWdyZWVtZW50cy4gIFNlZSB0aGUgTk9USUNFIGZpbGUKICogZGlzdHJpYnV0ZWQgd2l0aCB0aGlzIHdvcmsgZm9yIGFkZGl0aW9uYWwgaW5mb3JtYXRpb24KICogcmVnYXJkaW5nIGNvcHlyaWdodCBvd25lcnNoaXAuICBUaGUgQVNGIGxpY2Vuc2VzIHRoaXMgZmlsZQogKiB0byB5b3UgdW5kZXIgdGhlIEFwYWNoZSBMaWNlbnNlLCBWZXJzaW9uIDIuMCAodGhlCiAqICJMaWNlbnNlIik7IHlvdSBtYXkgbm90IHVzZSB0aGlzIGZpbGUgZXhjZXB0IGluIGNvbXBsaWFuY2UKICogd2l0aCB0a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gJmNhcikKCWNhci5Pd25lciA9IGFyZ3NbMV0KCgljYXJBc0J5dGVzLCBfID0ganNvbi5NYXJzaGFsKGNhcikKCUFQSXN0dWIuUHV0U3RhdGUoYXJnc1swXSwgY2FyQXNCeXRlcykKCglyZXR1cm4gc2hpbS5TdWNjZXNzKG5pbCkKfQoKLy8gVGhlIG1haW4gZnVuY3Rpb24gaXMgb25seSByZWxldmFudCBpbiB1bml0IHRlc3QgbW9kZS4gT25seSBpbmNsdWRlZCBoZXJlIGZvciBjb21wbGV0ZW5lc3MuCmZ1bmMgbWFpbigpIHsKCgkvLyBDcmVhdGUgYSBuZXcgU21hcnQgQ29udHJhY3QKCWVyciA6PSBzaGltLlN0YXJ0KG5ldyhTbWFydENvbnRyYWN0KSkKCWlmIGVyciAhPSBuaWwgewoJCWZtdC5QcmludGYoIkVycm9yIGNyZWF0aW5nIG5ldyBTbWFydCBDb250cmFjdDogJXMiLCBlcnIpCgl9Cn0=
Image for post
Image for post

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