0

I am using web3.js to send SOL txns, using the sendTransaction method.

Sometimes, when I send a txn, the method will return me a transaction address. But when I look it up in solscan.io (even after 5 mins), the transaction does not exist, meaning it was never executed.

  1. What causes txns to not execute? How can I prevent it from happening?
  2. How can I detect if a txn fails?
1
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
    – Community Bot
    Feb 18 at 14:32

1 Answer 1

0

A transaction can fail for all sorts of reasons, from a bug in the on-chain program to an account not having enough funds.

To detect if a transaction has failed, you can use the confirmTransaction or getTransaction https://solana.com/docs/rpc/http/gettransaction method, which will give you information about the transaction status.

Even better, however, is to simulate the transaction before sending it. This way you can know if it will fail without spending the transaction fee: https://solana.com/docs/rpc/http/simulatetransaction

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.