Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I confirm if a transaction has happened on Solana using the transaction hash (signature)

The confirmTransaction method is being deprecated. Instead there's a sendandconfirmtransaction method but that is not available on the connection object, so I can't use for transactions that are to be signed using phantom.

I have a transaction hash(signature) after the transaction so I'm trying to confirm if a transaction was done on the backend using the transaction hash, how is this possible?

like image 234
raghav saraf Avatar asked Oct 23 '25 16:10

raghav saraf


1 Answers

/** @deprecated Instead, call `confirmTransaction` using a `TransactionConfirmationConfig` */

Method is not deprecated try this:

const tx = await connection.requestAirdrop(publicKey, 1e9);
const latestBlockHash = await connection.getLatestBlockhash();

await connection.confirmTransaction({
  blockhash: latestBlockHash.blockhash,
  lastValidBlockHeight: latestBlockHash.lastValidBlockHeight,
  signature: tx,
});
like image 125
Urvesh109 Avatar answered Oct 26 '25 09:10

Urvesh109



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!