'Uncaught (in promise) Error: Transaction fee payer required

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



Solution 1:[1]

transferTransaction.feePayer = alice.publicKey

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sorin Hadjiu