0

I am following the docs for "estimateGas" and it instructs me to import "parseEther" from alchemy-sdk. However, when I run the function I get an error stating that "TypeError: (0, _alchemySdk.parseEther) is not a function."

Is this a bug currently or are the docs out of date?

import { Network, Alchemy, Wallet, TokenBalanceType, Utils, fromHex, parseEther } from 'alchemy-sdk';

export const estimateGasFees = async (toAddress, fromAddress, amount) => {
    const estimate = await alchemy.core.estimateGas({
        to: toAddress,
        from: fromAddress,
        value: parseEther(amount),
    });
    return estimate;
}

My "amount" variable is a string ("0.001")

Yilmaz
  • 35,338
  • 10
  • 157
  • 202
Jake Mulhern
  • 660
  • 5
  • 13

1 Answers1

1

Looks like parseEther is not a function. Based on example here

const { Alchemy, Network, Wallet, Utils } = require("alchemy-sdk");

value: Utils.parseEther("0.001"),
Yilmaz
  • 35,338
  • 10
  • 157
  • 202
  • I actually just found this when looking through the docs to set up an actual transaction. I contacted Alchemy to let them know to change this in the docs. – Jake Mulhern Dec 27 '22 at 18:39