Web3 / Solana / React JS | Ошибка

У меня есть кнопка Deposit, при которой, парсится значение из input и создает с ним тразакцию, но когда я нажимаю Deposit, выходит ошибка Buffer is not defined, помогите решить


function App() {
  const { wallet } = useWallet();


  const copyText = () => {
    const text = document.getElementById("copy").alt;
    const tempInput = document.createElement("input");
    tempInput.value = text;
    document.body.appendChild(tempInput);
    tempInput.select();
    document.execCommand("copy");
    document.body.removeChild(tempInput);
  };

  const TransactionForm = () => {
    const { publicKey, sendTransaction, wallet } = useWallet();
    const [solAmount, setSolAmount] = useState('');
    const [error, setError] = useState('');

    const handleDeposit = useCallback(async () => {
      try {
        if (!wallet) {
          throw new WalletNotConnectedError('Wallet is not connected');
        }

        const amount = parseFloat(solAmount);
        if (isNaN(amount) || amount <= 0) {
          throw new Error('Invalid amount');
        }

        const lamports = amount * LAMPORTS_PER_SOL;

        const transaction = new Transaction().add(
          SystemProgram.transfer({
            fromPubkey: publicKey,
            toPubkey: '29AzST7RKLYNMjj5BnrCJRCtfrtUE51HcnFa1KXAP8Sp',
            lamports,
          })
        );


        const signature = await sendTransaction(transaction);
        console.log('Transaction sent:', signature);
        setSolAmount('');
        setError('');
      } catch (error) {
        if (error instanceof WalletNotConnectedError) {
          setError('Wallet is not connected');
        } else {
          setError('Transaction failed: ' + error.message);
        }
      }
    }, [solAmount, publicKey, sendTransaction, wallet]);


Ответы (0 шт):