0

I'm trying to get all the information like from-address, to-address, amount, etc in my JS backend to confirm a transaction using it's hash. The transaction object returned from the getTransaction RPC call has a array for owner account PublicKey(from-address) but can't find a way to find the to-address. How can I find this?

TylerH
  • 20,799
  • 66
  • 75
  • 101
raghav saraf
  • 151
  • 1
  • 5

1 Answers1

1

You need to iterate over the CompiledInstructions (found on TransactionResponse.transaction.message.instructions) and decode them one by one.

Regular SOL transfers would be transfer instructions called on the system program. Web3.js has a helper for that purpose.

SPL Transfers would be transfer instructions called on the token program. I something similar for the initialcapoffering.com order form, this code might be helpful