16
votes
Accepted
Uncaught ReferenceError: Buffer is not defined. Using Phantom Wallet, Solana and React to make a transaction
This is happening because the default bundler that comes with create react app(webpack 5) does not polyfill Buffer. The easiest way to fix this is including this code in your app:
import * as buffer ...
5
votes
Accepted
How can I get parse a public key from Buffer?
You can get the correct key by calling new PublicKey(buffer).
The constructor for PublicKey takes a number of different types: number | string | Buffer | Uint8Array | number[]
https://solana-labs....
5
votes
Accepted
How to write a factory pattern contracts in solana
This is an anti-pattern on Solana. Program code and data are stored separately, so there is no need to redeploy the code for each instance of the program. It is sufficient to organize program data ...
3
votes
Uncaught ReferenceError: Buffer is not defined. Using Phantom Wallet, Solana and React to make a transaction
Thanks for trying to help me.
I managed to get my code working finally. I've to do a couple of things I want to share:
FIRST: Make sure you've all these dev dependencies installed
"...
3
votes
Accepted
How to safely close program buffers?
To give a quick rundown, a program account is actually just data for a pubkey pointing towards the account that actually contains the program executable data.
The program executable data account ...
3
votes
how to decode data of specific account
If you're using Anchor (which I recommend), you can use fetch to decode account data easily.
If you're not using Anchor you need to specify the structure and decode it using something like borsh.
Here ...
2
votes
Decoding data buffer of an account - @solana/buffer-layout - Rust u64 to Typescript Number conversion
Did you know that the Buffer has convenient methods to read numbers?
for instance you could use readBigInt64LE for the supply like this:
let supply = usdcAcctInfo.data.readBigInt64LE(36);
Then you ...
2
votes
Accepted
Buffer is not defined
You don't "have to" use Node. I'm running a handful of dApps on Apache using bundled modules. But currently it is 100% a headache to do so.
What you have to do is use a tool like esbuild or ...
2
votes
Accepted
Just using the Browser bundle, how can I send a transaction (ReferenceError: Buffer is not defined)?
Buffer is available in Node.js runtimes, but not in browsers.
Without knowing the exact shape of your build system I can only give general advice, which is that you'll need to install a Buffer ...
2
votes
Borsh Deserialization error: Trying to access beyond buffer length
Since your struct has variable-length fields (strings), using the struct type will be very difficult, since it can't calculate the size of each field statically.
There should be an easier way, however....
2
votes
Accepted
Verify Merkle tree in JS - Candy Machine v3
the issue is that you were doing this
validMerkleProof.map((e) => Buffer.from(keccak_256(e))),
This was re hashing the already hashed proofs from the merkleProof function.
With the following code ...
1
vote
How to verify written solana program buffer account data and uploaded program build file with checksum?
I am not familiar with checksum, but if you want to verify solana programs, check out the verifiable build CLI tool.
You can use the anchor CLI for building verifiable programs and documented here
...
1
vote
Error fetching Account Info on Android Kotlin `java.nio.BufferUnderflowException`
Try out sol4k for this. Getting account info can be done like this:
val usdc = PublicKey("Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr")
val connection = Connection(rpcUrl)
val accountInfo =...
1
vote
Error fetching Account Info on Android Kotlin `java.nio.BufferUnderflowException`
Hard to tell what the problem is, but maybe you need to use another Serializer. What kind of account is it? Anchor?
Then maybe
SolanaAccountSerializer
is what you are searching for.
1
vote
Accepted
error while sending transaction with solanaweb3, [ReferenceError: Property 'Buffer' doesn't exist] in react native
This happens because react-native doesn't have window.Buffer defined by default, which the web3.js library is trying to use.
You can fix it by adding to the top of your app:
global.Buffer = require('...
1
vote
Serialize float, int, Pubkey data using web3 js
Each data type is serialized differently into the buffer, but they're all possible.
For u8, you can do instructionBuffer.writeUInt8(value), be sure to allocate 1 byte for it.
For f64, you can do ...
1
vote
Uncaught ReferenceError: Buffer is not defined. Using Phantom Wallet, Solana and React to make a transaction
if you are using Sveltekit after importing the import { Buffer } from 'buffer'; you need to load it in the browser by importing
import { browser } from '$app/environment';
if(browser){
window.Buffer =...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
buffer × 15transactions × 3
solana-program × 3
anchor × 2
metaplex × 2
javascript × 2
deploy × 2
decode × 2
web3.js × 2
account-data × 2
rust × 1
react × 1
testing × 1
getprogramaccounts × 1
candymachine × 1
html × 1
borsh × 1
serialization × 1
sendtransactionerror × 1
buffer-layout × 1
transaction-instructions × 1
transaction × 1
close × 1