I've created a simple app to figure out how to use a Phantom wallet to make Solana transactions. I'm trying to follow SolDev course: https://soldev.app/course/interact-with-wallets.
When I test the app and I press the button to send Solana to another account I got the following error: Uncaught ReferenceError: Buffer is not defined
This is my Code:
const sendSol = event => {
event.preventDefault()
const transaction = new Web3.Transaction()
const to = Web3.Keypair.generate();
const sendSolInstruction = Web3.SystemProgram.transfer({
fromPubkey: publicKey,
toPubkey: to.publicKey,
lamports: LAMPORTS_PER_SOL * 0.1
})
transaction.add(sendSolInstruction);
sendTransaction(transaction, connection).then(sig => {
console.log(sig)
})
}
I got the error in the line toPubkey: to.publicKey,
Aditional info: I got this warning in the console:
WARNING in ./node_modules/@solana/buffer-layout/lib/Layout.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'D:\Solana\SolanaCourse\solanacourse1\node_modules\@solana\buffer-layout\src\Layout.ts' file: Error: ENOENT: no such file or directory, open 'D:\Solana\SolanaCourse\solanacourse1\node_modules\@solana\buffer-layout\src\Layout.ts'
Hope somebody could help me. If you need extra information please tell me. Thanks!