'Solana web3 js keep gives Cannot read properties of undefined (reading 'negative') while trying to confirm transaction
I'm trying to sign a transaction with connected user's wallet, through phantom but I keep getting this error message
Cannot read properties of undefined (reading 'negative')
below is my transaction function
async SendTransaction(from,to){
console.log(from);
// const f = JSON.stringify(from)
// console.log(f);
const transaction = new Transaction().add(
SystemProgram.transfer({
fromPubkey: new PublicKey(from.publicKey),
toPubkey: new PublicKey(to),
lamports: LAMPORTS_PER_SOL / 100,
}),
);
let blockhash = (await connection.getLatestBlockhash("finalized")).blockhash;
transaction.recentBlockhash = blockhash
transaction.feePayer = from
// Sign transaction, broadcast, and confirm
const signature = await sendAndConfirmTransaction(
connection,
transaction,
[from],
);
console.log(signature);
return transaction
},
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|