raghav saraf
raghav saraf

Reputation: 161

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?

Upvotes: 4

Views: 4782

Answers (1)

Urvesh109
Urvesh109

Reputation: 89

/** @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,
});

Upvotes: 9

Related Questions