0

I was using decodeTransferCheckedInstruction with legacy version but want to move to VersionedTransaction.

However, I can't find any alternative of decodeTransferCheckedInstructionfor versioned transaction (MessageCompiltedInstruction).

It's a simple transfer instruction and I want to get the transferred amount from instruction.

Is there a way to achieve this?

1 Answer 1

2

Since decodeTransferCheckedInstruction requires a TransactionInstruction to decode, we need to get from VersionedTransaction to one of those. Looking around, we have:

  • VersionedTransaction has a VersionedMessage
  • TransactionMessage.decompile takes a VersionedMessage and returns a TransactionMessage
  • TransactionMessage has an array of TransactionInstructions

So you simply need to use TransactionMessage.decompile on your transaction to extract the TransactionInstructions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.