Skip to main content
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 ...
acheron's user avatar
  • 2,909
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....
C.OG's user avatar
  • 2,907
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 ...
trent.sol's user avatar
  • 4,585
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 "...
Mario Enrique Yahuarcani Salin's user avatar
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 ...
Jon C's user avatar
  • 19.6k
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 ...
vicyyn's user avatar
  • 4,295
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 ...
Solandy's user avatar
  • 511
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 ...
Dapper's user avatar
  • 36
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 ...
steveluscher's user avatar
  • 3,153
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....
Jon C's user avatar
  • 19.6k
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 ...
austbot's user avatar
  • 56
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 ...
Jimii's user avatar
  • 7,672
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 =...
Sasha Shpota's user avatar
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.
Jonas H.'s user avatar
  • 7,209
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('...
Callum M's user avatar
  • 3,775
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 ...
Jon C's user avatar
  • 19.6k
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 =...
Lennox 's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible