Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Alchemy API returning error when using parseEther

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")

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

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

value: Utils.parseEther("0.001"),
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading