2

I'm trying to retrieve transaction information using Solana's APIs, but I consistently receive null when calling getTransaction for my transaction ID (txid). This happens even though the transaction was initiated. Is there a known issue with transaction visibility or confirmation delays on the Solana network? How can I reliably determine if my transaction has successfully completed or encountered an issue?

here are few ways i tried and all of them just return null, or nothing:

let txids = await buildAndSendTx(innerTransactions);
console.log("TXID: ", txids[0]);

// Attempt 1 
try{
  connection.onSignature(
  txids[0],
  (signatureResult, context) => {
      if (signatureResult.err == null){
        console.log("Transaction succeeded");
      }else{
        console.log("Transaction failed");
      
      }
  },
  'confirmed'
  );
} catch (error) {
  console.error('Greška pri praćenju transakcije:', error);
}
// Attempt 2

const status = await connection.getSignatureStatus(txids[0]);

if (status && status.value) {
    if (status.value.err) {
        console.log("Transaction failed");
    } else {
        console.log("Transaction succeeded");
    }
} else {
    console.log("Transaction status not found");
}
// Attempt 3

console.log(await connection.getTransaction(txids[0]))

Here is code for buildAndSendTx

export async function buildAndSendTx(innerSimpleV0Transaction: 

InnerSimpleV0Transaction[], options?: SendOptions | ConfirmOptions) {
  const willSendTx = await buildSimpleTransaction({
    connection,
    makeTxVersion,
    payer: wallet.publicKey,
    innerTransactions: innerSimpleV0Transaction,
    addLookupTableInfo: addLookupTableInfo,
  })

  return await sendTx(connection2, wallet, willSendTx, options)
}

And here is code for sendTx

export async function sendTx(
  connection: Connection,
  payer: Keypair | Signer,
  txs: (VersionedTransaction | Transaction)[],
  options?: ConfirmOptions,
): Promise<string[]> {
  function sleep(ms: number): Promise<void> {
    return new Promise(resolve => setTimeout(resolve, ms));
  }

  sleep(1000);
  const txids: string[] = [];
  for (const iTx of txs) {
    if (iTx instanceof VersionedTransaction) {
      // Sign the VersionedTransaction
      iTx.sign([payer]);
      txids.push(await connection.sendTransaction(iTx));
    }
  }
  return txids;
}

That code is mainly from raydium sdk V1 demo from github.

1 Answer 1

3

Generally speaking, this isn't related to Solana itself, but to your RPC provider: You mention using "Solana's API", which I'm guessing you're using the https://api.mainnet-beta.solana.com/ endpoint. This endpoint is very much rate-limited which is probably what is causing you issues. I suggest upgrading to a different RPC provider, for example Quicknode and Helius both have better free plans.

Update: Thanks to your updates we can see where the issue lies. The buildSimpleTx function builds a transaction without priority fees. This means your transaction either will take extremely long to go through, or, more likely, never go through at all. I'm not sure how to add these in Raydium SDK v1, but in Raydium SDK v2 it's just another parameter you can pass, so I'd suggest switching to that and passing them in there.

6
  • i tried using alchemy and shyft. here are links im using as rpc: solana-mainnet.g.alchemy.com/v2 rpc.shyft.to?api_key= Commented Jul 9 at 12:07
  • I've extended my answer. Let me know if this answers your question and if not please edit your question with the code for buildAndSendTx.
    – Ahri
    Commented Jul 10 at 9:01
  • I added code for buildAndSendTx, if i specify that i want to wait for transaction to be confirmed i dont get any response ever, even when transaction is done Commented Jul 10 at 17:33
  • Thank you. Updated my answer once more.
    – Ahri
    Commented Jul 11 at 9:10
  • thanks for suggestion, i was thinking about doing that so i will look into that next. However i would really like to know if there is any official way on how to check if transaction has landed or not. Commented Jul 13 at 14:45

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.