2

the part of code that causes const connection = new Connection('https://api.testnet.solana.com'); console.log(privateKey, '+++++++++');

  const feePayer = Keypair.fromSecretKey(bs58.decode(privateKey));
  console.log('feepair', feePayer);
  const transaction = new web3.Transaction().add(
    web3.SystemProgram.transfer({
      fromPubkey: feePayer.publicKey,
      toPubkey: data.to,
      lamports: web3.LAMPORTS_PER_SOL / 100,
    }),
  );
1
  • I am Having the same error while download the video from Url. Thanks it works for me
    – user8108
    Commented Jan 17 at 13:44

1 Answer 1

1

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('buffer').Buffer;
2
  • 1
    thanks @Callum M ,made my day
    – Mian Bilal
    Commented Mar 23, 2023 at 14:41
  • 1
    I was using another web3 lib, and encountered the same issue, your solution saved my day as well. Thank you
    – chygo
    Commented Mar 19 at 10:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.