1

I have been using the following chunk of code for awhile and it seems to work about 98% of the time, however there are cases where the transaction does go through seemingly immediately, but this does not pick it up in time, even when I have my confirmTransactionInitialTimeout set to 60 seconds. Is there a better alternative or something that I'm doing wrong? Thanks! (I am using the $50 plan on quicknode as an RPC)

const connection = new Connection(
        process.env.NEXT_PUBLIC_CONNECTION_NETWORK == "devnet"
      ? process.env.NEXT_PUBLIC_SOLANA_RPC_HOST_DEVNET
      : process.env.NEXT_PUBLIC_SOLANA_RPC_HOST_MAINNET_BETA,
        { commitment: "processed", confirmTransactionInitialTimeout: 60000 },
);

await connection.confirmTransaction({
    signature: signature,
    blockhash: blockhash.blockhash,
    lastValidBlockHeight: blockhash.lastValidBlockHeight,
})

2 Answers 2

1

I'm not 100% sure that I've fixed it, but after some research, it seems that it's possible for the transaction to be confirmed before it hits my confirm function, causing it to time out because it's already been confirmed. I think I solved this by adding this function before my confirm transaction. If it's already been confirmed, it doesn't need to run confirmTransaction, otherwise it does this:

connection.getSignatureStatus(signature)

0

So, in Solana chain, this is expected when some transactions get dropped for some reason. You can find more information here: https://www.quicknode.com/guides/solana-development/solana-transaction-propagation-handling-dropped-transactions

There is no silver bullet to force all the transactions to be accepted by chain. But you can find some good code samples in the article on how to handle Transaction propagation better.

1
  • Thanks for the response! But the concern is for transactions that do indeed go through, but almost act like they're dropped. In my application, a user submits their NFT to our dev wallet, then once the TX is confirmed, we will write to our database to keep track. However, sometimes the TX just isn't picked up even though the NFT is actually sent.
    – Thud
    Commented Nov 30, 2022 at 0:31

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.