# Unable to send transactions to testnet using flow go sdk

**URL:** <https://forum.flow.com/t/unable-to-send-transactions-to-testnet-using-flow-go-sdk/4654>\
**Category:** Flow Go SDK\
**Tags:** flow-sdk-go\
**Created:** [April 27, 2023, 4:01pm UTC](https://forum.flow.com/t/unable-to-send-transactions-to-testnet-using-flow-go-sdk/4654 "2023-04-27T16:01:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![OnlyTortoise](https://avatars.discourse-cdn.com/v4/letter/o/85e7bf/32.png) [@OnlyTortoise](https://forum.flow.com/u/OnlyTortoise)\
**Post date:** [April 27, 2023, 4:01pm UTC](https://forum.flow.com/t/unable-to-send-transactions-to-testnet-using-flow-go-sdk/4654/1 "2023-04-27T16:01:14Z")

</div>

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{
	MY_KMS_STUFF
}

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

accountKMSSigner, err := kmsClient.SignerForKey(
	ctx,
	accountKMSKey,
)

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

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 {
	time.Sleep(time.Second)
	fmt.Print(".")
	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 🙂

---

<div class="post-metadata">

**Author:** ![javiersotodev](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@javiersotodev](https://forum.flow.com/u/javiersotodev)\
**Post date:** [April 27, 2023, 6:33pm UTC](https://forum.flow.com/t/unable-to-send-transactions-to-testnet-using-flow-go-sdk/4654/2 "2023-04-27T18:33:39Z")

</div>

A couple of things here. To handle errors in Go i’d highly suggest to do this:  
if err != nil {  
logging.Infof(err.Error())  
return  
}  
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

---

<div class="post-metadata">

**Author:** ![OnlyTortoise](https://avatars.discourse-cdn.com/v4/letter/o/85e7bf/32.png) [@OnlyTortoise](https://forum.flow.com/u/OnlyTortoise)\
**Post date:** [April 27, 2023, 6:47pm UTC](https://forum.flow.com/t/unable-to-send-transactions-to-testnet-using-flow-go-sdk/4654/3 "2023-04-27T18:47:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![navid](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/navid/32/500_2.png) [@navid](https://forum.flow.com/u/navid)\
**Post date:** [April 27, 2023, 7:29pm UTC](https://forum.flow.com/t/unable-to-send-transactions-to-testnet-using-flow-go-sdk/4654/4 "2023-04-27T19:29:58Z")

</div>

Hi,  
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](https://github.com/onflow/flow-go-sdk/blob/master/transaction.go#L124)

---

<div class="post-metadata">

**Author:** ![OnlyTortoise](https://avatars.discourse-cdn.com/v4/letter/o/85e7bf/32.png) [@OnlyTortoise](https://forum.flow.com/u/OnlyTortoise)\
**Post date:** [April 27, 2023, 7:37pm UTC](https://forum.flow.com/t/unable-to-send-transactions-to-testnet-using-flow-go-sdk/4654/5 "2023-04-27T19:37:42Z")

</div>

Ahuh, makes sense! Thanks

---

<div class="post-metadata">

**Author:** ![bjartek](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/bjartek/32/143_2.png) [@bjartek](https://forum.flow.com/u/bjartek)\
**Post date:** [April 28, 2023, 11:30am UTC](https://forum.flow.com/t/unable-to-send-transactions-to-testnet-using-flow-go-sdk/4654/6 "2023-04-28T11:30:16Z")

</div>

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.

> **[GitHub - bjartek/overflow: a DSL to do awesome stuff on the flow blockchain](https://github.com/bjartek/overflow)**
>
> a DSL to do awesome stuff on the flow blockchain. Contribute to bjartek/overflow development by creating an account on GitHub.
