Verify signed transaction offchain with Golang

Say I have a signed transaction in string like this

signed_tx = "gqNzaWfEQPk3BpB97TTViTQUxs7uBQjFPrqcqBeOh4ARjiAFzzgLTKKsK0jJxHRW+z0/0LyLiOsdpmmahGaevAL+qnhXkQ6jdHhuiaNmZWXNA+iiZnbOAU3+36NnZW6sbWFpbm5ldC12MS4womdoxCDAYcTY/B293tLXYEvkVo4/bQQZh6w3veS2ILWrOSSK36Jsds4BTgLHpG5vdGXEFmNoYWxsZW5nZS84ODU4MDM0L2dlbXOjcmN2xCDgKkZcseIi0EFwhDpsPkvRw/meiyuhS354NHPAG3CfSqNzbmTEIOAqRlyx4iLQQXCEOmw+S9HD+Z6LK6FLfng0c8AbcJ9KpHR5cGWjcGF5"

How can I verify this is a valid transaction without call to Algorand chain using Golang?

Generally you can parse the b64 to bytes and marshal it into a SignedTransaction object then run an ed25519 verify against the pubkey, signature, and mspgacked txn bytes.

There is a repo here: GitHub - NullableLabs/AlgoAuth: Pass trust from a front-end Algorand WalletConnect session, to a back-end web service that contains the logic to do so in Go

Ben

2 Likes

To complement @Ben’s response, it depends what you mean by “valid transaction”.
You can verify the signature is valid.
But it does not mean the transaction would be accepted by the blockchain.
There are many other restrictions that may make the transaction rejected by the blockchain, such as (this list is not exhaustive):

  • the sender account was rekeyed
  • the sender account does not have enough Algos / ASAs
  • in case of ASA transfer, the receiver account did not opt in; in case of payment, the receiver account is empty and the amount is below 0.1 Algo
  • the transaction is an application call for an invalid application ID / the application ID was destroyed
  • the transaction is not valid for other reasons: for example a key registration without Falcon keys
  • the validity window is invalid
  • the genesis hash/name is invalid
  • …
1 Like