What i am trying to do this create a transcation on backend( which have pk for my wallet ) set frontend wallet as fee payer sign that transcation and send it to frontend and only if end user signs the wallet , confirm the tx and send to blockchain, This is what i have tried so far:

  const walletToSendSol = new PublicKey(wallet);
const transferTransaction = new Transaction().add(
    fromPubkey: payer.publicKey,
    toPubkey:walletToSendSol ,
    lamports: LAMPORTS_PER_SOL / 80,
transferTransaction.recentBlockhash = (
  await connection.getLatestBlockhash()
transferTransaction.feePayer = walletToSendSol;
return new NextResponse(
    tx: base58.encode(
        requireAllSignatures: false,

End user:

 const fetchTx = await fetch(`/api/getTx?wallet=${publicKey}`);
const { tx } = await fetchTx.json();
const decodedTx = base58.decode(tx);
const transcation = Transaction.from(decodedTx);
transcation.feePayer = publicKey;
const signature = await signTransaction(transcation);

but once click approve on phantom wallet nothing happens

1 Answer 1


It doesn't appear that you're sending the transaction, just signing it. You can use sendTransaction(transaction, connection) from the useWallet() hook in wallet adapter to handle the flow of signing and sending with a user's wallet.

After sendTransaction() is called, it's good practice to run a confirmation to ensure it landed. You can do this with the following:

const signature = await sendTransaction(transaction, connection);

await connection.confirmTransaction(signature, "confirmed");

// can also do this
const block = await connection.getLatestBlockhash("confirmed");
const result = await connection.confirmTransaction(

const error = result.value.err;
if (error) {
   throw Error(error.toString());
  • yea seems like that i was missing i thought transcation are automatically sent when i click approve on my wallet , thanks for clearing my doubt
    – Rowan
    Commented May 19 at 16:23

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.