Wednesday, October 14, 2020

Query Fabric transaction

 

func useClientQuery() {
cnfg := config.FromFile("./connection.json")
fmt.Println(reflect.TypeOf(cnfg))
sdk, err := fabsdk.New(cnfg)
if err != nil {
fmt.Printf("Failed to create new SDK: %s", err)
}
defer sdk.Close()
clientChannelContext := sdk.ChannelContext(channelID, fabsdk.WithUser(orgAdmin), fabsdk.WithOrg(orgName))
client, err := ledger.New(clientChannelContext)
if err != nil {
fmt.Printf("Can not get ledger client")
} else {
fmt.Printf("The client is %v", client)
}
tx, err := client.QueryTransaction("e969096e24e768bff2df17d640404b6b72093fa008509acaa31cc8adb6c72260")
fmt.Printf("validation code %d", tx.GetValidationCode())
fmt.Printf("The tx is %v", tx)
//client.QueryBlock()
//client.QueryBlockByTxID("e969096e24e768bff2df17d640404b6b72093fa008509acaa31cc8adb6c72260")
}


1 comment:

  1. Could you please provide a `connection.json` file for the fabric-samples test-network?
    It would appear that the `sdk` reference I obtain is not initialised properly.
    Thanks in advance!

    ReplyDelete