0

I am using the Raydium script to swap transactions, and I'm currently testing on the mainnet. I tried to swap a small amount of 0.001 SOL, but each time I do this, I receive a transaction hash. However, when I copy and paste this hash for verification, it shows nothing. Additionally, no tokens appear in my wallet, nor is any SOL deducted. When I run the script again with the same code, it attempts to swap again. Could this issue be due to the low amount I am swapping, or is there another problem?

https://solscan.io/tx/2fy1tsER1KbcYp6hPeWQGxmvipFV7kyEZHprug5VhcesvyBMBiEL8TJ1dLuj6hu62criv9t9qm6Xuv4qzJneHf5X


    const swapTransaction = await Liquidity.makeSwapInstructionSimple({
      connection: this.connection,
      makeTxVersion: useVersionedTransaction ? 0 : 1,
      poolKeys: {
        ...poolKeys,
      },
      userKeys: {
        tokenAccounts: userTokenAccounts,
        owner: this.wallet.publicKey,
      },
      amountIn: amountIn,
      amountOut: minAmountOut,
      fixedSide: fixedSide,
      config: {
        bypassAssociatedCheck: false,
      },
    });
    const recentBlockhashForSwap = await this.connection.getLatestBlockhash();
    const instructions =
      swapTransaction.innerTransactions[0].instructions.filter(Boolean);
    if (useVersionedTransaction) {
      const versionedTransaction = new VersionedTransaction(
        new TransactionMessage({
          payerKey: this.wallet.publicKey,
          recentBlockhash: recentBlockhashForSwap.blockhash,
          instructions: instructions,
        }).compileToV0Message()
      );
      versionedTransaction.sign([this.wallet]);
      return versionedTransaction;
    }

    const legacyTransaction = new Transaction({
      blockhash: recentBlockhashForSwap.blockhash,
      lastValidBlockHeight: recentBlockhashForSwap.lastValidBlockHeight,
      feePayer: this.wallet.publicKey,
    });

    legacyTransaction.add(...instructions);
    return legacyTransaction;
  }
7
  • 1
    It looks like your transaction might not be landing on-chain if there's no record anywhere. Try adding some priority fees or trying again
    – Jon C
    Commented May 17 at 17:05
  • Is there a way to set this to ensure the transaction lands on-chain? I already added some priority fees, but it still doesn't work.
    – Bobz
    Commented May 20 at 7:05
  • Can I use Jito bundles to ensure my transaction lands on-chain?
    – Bobz
    Commented May 20 at 7:07
  • Yeah that's a possible solution
    – Jon C
    Commented May 20 at 9:46
  • 1
    You'll still need to add priority fees if you want to land on mainnet. Check out solanacookbook.com/references/… for how to add them
    – Jon C
    Commented May 20 at 11:37

1 Answer 1

0

From the code provided, and Jon's comments, it's clear that the transaction is not landing. There's a few courses of action here:

  1. If you aren't already, use a custom RPC. Helius and Quicknode should suit your needs here, and have generous free plans for you to test.
  2. If you aren't already, add priority fees, and evaluate how much you're adding. It's recommended to be above the median to get the best chance of landing in a block. The JSON RPC API and Helius APIs should provide a getRecentPriorityFees that will help determine how much to add.
  3. Use a versioned transaction when possible. I see you're already handling for this, but versioned transactions will help minimize serialized tx size, therefore helping you land at a better rate.
  4. Jito Tips & Jito Bundles can also help here. I'd recommend adding a small Jito tip to the tx to see if that helps before delving into bundling.

All of these measures combined should help to ensure you get a better landing rate.

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.