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