0

I am facing the issue while swapping the tokens using Jupiter API, I want to swap from other and feepayer will be another account. while swapping the feepayer account error show:

Error Swap: Cannot sign with non signer key HAD84928941Nt*****

const userWalletAddress = userWallet.payer.publicKey.toString();
const payerWalletAddress = payerWallet.payer.publicKey.toString();

const swapTransaction = await (
      await fetch("https://quote-api.jup.ag/v6/swap", {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          quoteResponse,
          userPublicKey: userWalletAddress,
          wrapUnwrapSOL: wrapUnwrapSOL,
          dynamicComputeUnitLimit: true,
          prioritizationFeeLamports: "auto",
        }),
      })
    ).json();
    const swapTransactionBuf = Buffer.from(
      swapTransaction.swapTransaction,
      "base64"
    );
    var transaction = VersionedTransaction.deserialize(swapTransactionBuf);
    const getblockhash = await connection.getLatestBlockhash("finalized");
    transaction.recentBlockhash = getblockhash.blockhash;
    transaction.feePayer = payerWallet.payer.publicKey;
    transaction.sign([userWallet.payer , payerWallet.payer]);
    const rawTransaction = transaction.serialize();
    const txid = await connection.sendRawTransaction(rawTransaction, {
      skipPreflight: true,
      maxRetries: 20,
      preflightCommitment: "processed",
    });
    await connection.confirmTransaction(txid, "finalized");
    console.log(`https://solscan.io/tx/${txid}`);
3
  • Please edit your code to show how you're getting userWalletAddress
    – McBain
    Commented Jul 3 at 14:44
  • userWalletAddress is basically userWallet.payer.publickey.
    – Bobz
    Commented Jul 3 at 17:02
  • @Ahri - Check Now
    – Bobz
    Commented Jul 3 at 17:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.