Unable to send transactions to testnet using flow go sdk

I’m trying to send a transaction that looks like this:

    ctx := httpRequest.Context()
flowClient, _ := flow_http.NewClient(flow_http.TestnetHost)

address := flow.HexToAddress(MY_ADDRESS)
account, _ := flowClient.GetAccount(ctx, address)
accountKey := account.Keys[0]

accountKMSKey := cloudkms.Key{

kmsClient, err := cloudkms.NewClient(ctx)
if err != nil {

accountKMSSigner, err := kmsClient.SignerForKey(

script, err := ioutil.ReadFile(PATH_TO_SCRIPT)
latestBlock, err := flowClient.GetLatestBlockHeader(ctx, true)
tx := flow.NewTransaction().
	SetProposalKey(address, accountKey.Index, accountKey.SequenceNumber).

err = tx.AddArgument(cadence.NewUInt64(1710107743))

logging.Infof(ctx, "add arguments err %+v", err)
id := tx.ID()
err = tx.SignEnvelope(account.Address, accountKey.Index, accountKMSSigner)
logging.Infof(ctx, "TRANSACTION Sign err %+v", err)

logging.Infof(ctx, "TRANSACTION %+v", *tx)
err = flowClient.SendTransaction(ctx, *tx)
logging.Infof(ctx, "send transaction err %+v", err)

result, err := flowClient.GetTransactionResult(ctx, id)
logging.Infof(ctx, "result %+v %+v", result, err)
for result.Status != flow.TransactionStatusSealed {
	result, err = flowClient.GetTransactionResult(ctx, id)
	if err != nil {
		logging.Infof(ctx, "result %+v %+v", result, err)

logging.Infof(ctx, "Transaction complete! %+v", result)

My script seems to be loading in, arguments are being passed, transaction is being signed and flowClient.SendTransaction(ctx, *tx) does not return an error. However, result, err := flowClient.GetTransactionResult(ctx, id) returns Flow resource not found: no known transaction with ID. Pretty confused because I’m not seeing any other errors otherwise.

Would really appreciate some help here :slight_smile:

A couple of things here. To handle errors in Go i’d highly suggest to do this:
if err != nil {
You dont want to keep the flow of the program if you encounter an error, as everything will fail at the end, and you wont know easily where it started.
Second, again with errors, you need to handle the errors in the flow client, get address and get latest block header functions. If there is an error there, the rest of the functions may not work at all. Specially in the get block info as if this fail, the TX wont be submitted correctly.
Third, im assuming the function is a http Request. When using the context that comes from the request, if by any reason the request gets cancelled or times out, the context will and so will the rest of the functions that use the ctx.

Double check (print maybe) the address variables to make sure the address and the rest of the inputs are correctly.

Without seeing the script nor the results, hard to see if anything related to the transaction itself is causing the problem.

Try those suggestions to debug the overall go program

Yah I know this is extremely vague so thanks for the help. So the thing is everything looks correct, the account is being fetched, same with block id. and the send transaction doesn’t throw an error.

The issue is you’re saving the transaction ID before signing the envelope message. Transaction ID is computed based on transaction fields The ID will change after the envelope is signed, so the access node won’t know the old ID. You can check the function that computes ID here https://github.com/onflow/flow-go-sdk/blob/master/transaction.go#L124

1 Like

Ahuh, makes sense! Thanks

You are using very low level primities here aswell. Flowkit and overflow are more high level libraries where you dont have to do all the boilerplate yourself.

Sending a transaction in overflow even with google KMS are 2 lines of go with propperly set up flow.json.