0

I'm trying to send swap transaction in Raydium using Raydium SDK, I made exactly as their demo, and at first when I tried with private RPC it worked and after I wanted to go production and bought expensive RPC those that considered the best, I constantly get error: "Error failed to send transaction: Transaction signature verification failure"

Only the first "if" condition is relevant because it never gets into the "else" condition.

if (iTx instanceof VersionedTransaction) {
    iTx.sign([payer]);
    const hashInfo = (await connection.getLatestBlockhashAndContext()).value;
    iTx.message.recentBlockhash = hashInfo.blockhash;
    txids.push(await connection.sendTransaction(iTx, {skipPreflight: false}));
} else {
    const hashInfo = (await connection.getLatestBlockhashAndContext()).value;
    iTx.message.recentBlockhash = hashInfo.blockhash;
    txids.push(await connection.sendTransaction(iTx, [payer], {
        maxRetries: 0,
        preflightCommitment: "processed"
    }));
}

Here is the "payer" variable, the walletPrivateKey is always exists and correct, validated it. Also I printed the "payer" publicKey (wallet address) and it was correct.

const wallet = Keypair.fromSecretKey(bs58.decode(walletPrivateKey || ''));

I'm trying to figure it out what could be the reason but I don't know, also the RPC providers can't understand why it works on 1 RPC and on the 2 other it doesn't work. Will be glad for any assistance to figure it out.

Thanks

1 Answer 1

1

You should fetch a blockhash before signing, since the blockhash is part of the signed message. If you sign a message and then change the blockhash, you invalidate the previous signature. Try doing this:

    const hashInfo = (await connection.getLatestBlockhashAndContext()).value;
    iTx.message.recentBlockhash = hashInfo.blockhash;
    iTx.sign([payer]);

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.