ReferenceError: Buffer.from is not a function at toBufferLE #158
Replies: 2 comments
-
Hello @theking200794, I would recommend reviewing the answer in this Stack Exchange Question. The issue seems similar. The other thing I noticed is that using the same variable name on either side of the assignment statement may be causing issues. |
Beta Was this translation helpful? Give feedback.
-
Thx for replying @adamdelphantom. My env is JS not react or node.js maybe that's why web3 is throwing exception like |
Beta Was this translation helpful? Give feedback.
-
Summary
Hello when i am calling this after connecting to the wallet using
resp = window.solana.connect()
and getting publicKeyin my frontend i am using simple javascript, I am getting an error
Buffer.from is not a function at toBufferLE. I tried using CDN but got almost the same error as Buffer.from is not defined on line
lamports: solanaWeb3.LAMPORTS_PER_SOL * lamports,
I included cdn of the buffer too
<script src="https://cdn.jsdelivr.net/npm/[email protected]/index.min.js"></script>
I also tried including
window.Buffer = Buffer;
Also tried to pass lamports using
BigInt
andnew Uint8Array
but no success.I am integrating phantom in frontend using JavaScript in my flask website for doing solana transaction with the help of phantom wallet. I am using web3 cdn for solanaWeb3 which is
<script src="https://unpkg.com/@solana/web3.js@latest/lib/index.iife.js"></script>
Need help thx
Example
No response
Steps to Reproduce
1- Connect to phantom wallet using
const resp = await window.solana.connect();
2- Inside SystemProgram.transfer method will through an error like "buffer is not defined" on line
lamports: solanaWeb3.LAMPORTS_PER_SOL * lamports,
I am integrating in frontend using JavaScript in my flask website.
Phantom Version
23.19.0
Is there an existing discussion for this?
Beta Was this translation helpful? Give feedback.
All reactions