Ethers.js: TypeError: Cannot read property 'from' of undefined when using BigNumber.from("1");

Created on 1 Oct 2020  路  4Comments  路  Source: ethers-io/ethers.js

Hi, I'm getting the error above when running the following:

const { utils } = require("ethers");
console.log(utils.BigNumber.from(chg_number));
discussion

Most helpful comment

I think you are using ethers v4. In ethers v4, the method was ethers.utils.bigNumberify. Now it is recommended to upgrade to ethers v5.

In ethers v5, BigNumber moved to top

const { BigNumber } = require('ethers')
BigNumber.from(chg_number)

All 4 comments

I think you are using ethers v4. In ethers v4, the method was ethers.utils.bigNumberify. Now it is recommended to upgrade to ethers v5.

In ethers v5, BigNumber moved to top

const { BigNumber } = require('ethers')
BigNumber.from(chg_number)

Hmmm is there a way to import * from ethers in es5?

import { ethers } from 'ethers'

This one works when u want to import everything

I think @zemse answered the OP, so I'm going to close this? If I'm mistaken though, please re-open.

Thanks! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

282931 picture 282931  路  42Comments

Tower450 picture Tower450  路  25Comments

elenadimitrova picture elenadimitrova  路  28Comments

bpierre picture bpierre  路  43Comments

MicahZoltu picture MicahZoltu  路  24Comments