hyperledger-fabrichyperledger-fabric-sdk-go

need reference to use hyperledger fabric go sdk (fabric-sdk-go)


I am writing an application with Hyperledger Fabric. I want to use fabric-sdk-go for which I need to write a config file which would be input to fabsdk.New().

But I could not find any reference/materials on how to write that file, what parameters to use, how will parameters in that file be used by sdk instance generated by fabsdk.New() etc.

Could anyone please help me with this information? You could also share any online materials with the required information.


Solution

  • The config for SDK comes usually from a file called config.yaml that contains information about organizations, peers, channels and much more. For reference use this file or follow this guide. Make sure your fabric-sdk-go branch and version match to the one you use the config you're using.

    To initialize the sdk do something like sdk, err := fabsdk.New(config.FromFile(ConfigFile)) where ConfigFile refers to file "config.yaml", modify the path relative to the the location of where the main.go is run and where the file exists.

    Always close the sdk with sdk.Close() when config changes and before reinitializing.