I want to confirm a transaction gracefully and wait for it to be finalized. I understand the best way to do this is to use the
Connection.confirmTransaction method with the
BlockheightBasedTransactionConfirmationStrategy argument reference.
But that method requires 3 things, transaction signature, recent blockhash, and last valid block height. I have the first two, since recent blockhash can be obtained from the
Transaction object returned from
Connection.getTransaction. But how can I get the last valid block height?
Or is there any other way to handle cases like this and confirm transactions effectively?