Uncaught (in promise) Error: Transaction fee payer required

1.3k Views Asked by At

I get this error when I try to execute this using phantom wallet and react app


  const transferTransaction = new Transaction()
  .add(SystemProgram.transfer({
    fromPubkey: alice.publicKey,
    toPubkey: feePayer.publicKey,
    lamports: lamportsToSend
  }))
  
  const network = "https://api.devnet.solana.com";
const connection = new Connection(network);
const transaction = new Transaction();
transferTransaction.recentBlockhash = (await connection.getRecentBlockhash()).blockhash;

const { signature } = await window.solana.signAndSendTransaction(transferTransaction);
await connection.confirmTransaction(signature);

enter image description here

1

There are 1 best solutions below

2
On

transferTransaction.feePayer = alice.publicKey