2

I am working on some projects with Hyperledger Fabric, currently using the IBM VS Code Extension. The chaincode is written in Go, as is the client application which provides a RESTful API, using the Go Fabric SDK. However, I am having trouble connecting the client application to the chaincode. Most of the tutorials and examples I have seen use Node.js as the client and it seems the Node SDK needs less configuration.

As far as I understand it, the steps should be similar to the following but more detailed information seems to be a little bit lacking when it comes to the Golang Fabric SDK.

The client application needs the following information to be able to communicate with the blockchain network:

  • The enroll ID and secret of the application identity (used to generate a cert and private key), or the certificate and private key directly
  • The connection profile
  • The smart contract name
  • The name of the channel the smart contract was instantiated on
  • Use the certificate and private key of the application identity, along with CA endpoint information inside your connection profile

In the VSCode plugin

  • Register an 'application' identity in the 'Fabric Wallets' section
  • Export the connection profile from the 'Fabric Gateway' section
  • Export the application identity's wallet
  • Update code to point to the exported connection profile
  • Update code to point to the exported wallet

As far as I can tell, the connection profile and other steps needed to connect the SDK to the VS Code Network should be pretty 'standard' so I wonder if someone knows of a working example?

Thanks for the collective help!

Chris Sargent
  • 321
  • 2
  • 13

1 Answers1

2

Unfortunately you are going to struggle with this at the moment. Wallets are not compatible with the Go SDK currently. Also the Go SDK doesn't quite conform (or at least it didn't the last time I tried it) to the connection profile specification so the connection profile from the VS Code extension won't work without some minor modification and didn't work with a CA not using TLS (IIRC I patched the Go SDK to make it work).

There is work underway to bring the Gateway/Wallet programming model to the Go SDK which will then make working with the VS Code extension a lot easier, but I don't know when a version of the Go SDK with a working implementation will be available.

david_k
  • 5,843
  • 2
  • 9
  • 16
  • Thanks for your answer @david_k. So, as far as you know, the option right now would be to use a version of the basic / test network using the cryptogen tool, as described here for example: https://hyperledger-fabric.readthedocs.io/en/release-1.4/build_network.html ? – Chris Sargent Feb 05 '20 at 12:45
  • Well, byfn will setup a CA using TLS and cryptogen will create users which will be in a form that the Go SDK can work with (or you can register and enrol as required). The only thing I can't remember is if byfn provides a connection profile or not. If it did it then probably it will still require some modification to make it work with the Go SDK. – david_k Feb 05 '20 at 13:06
  • @Chris, you can refer to below link for creating config.yaml file in sdk-go. Also checkout the `github.com/hyperledger/fabric-sdk-go/test` directory for a complete end to end examples. https://github.com/hyperledger/fabric-sdk-go/tree/master/test/fixtures/config – metadata Feb 11 '20 at 05:13
  • Thanks @alpha -this has got me quite a long way there. Am still having issues and I'm pretty sure it's down to TLS issues or maybe the client application not running in the same Docker network. I just wish someone could help developers bypass the relentless mass of network configuration. – Chris Sargent Feb 13 '20 at 19:39