Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web3.utils.toWei read property 'toWei' of undefined #1469

Closed
helxsz opened this issue Mar 16, 2018 · 2 comments
Closed

web3.utils.toWei read property 'toWei' of undefined #1469

helxsz opened this issue Mar 16, 2018 · 2 comments

Comments

@helxsz
Copy link

helxsz commented Mar 16, 2018

my web3 version is version: '1.0.0-beta.20',I am loading the web3 using the angular 4.

  import * as Web3 from 'web3';
  this.web3 = new Web3(window.web3.currentProvider);
  console.log(this.web3);
  this.web3.utils.toWei(value_eth+"", 'ether');

the code gives me an error saying: web3.utils.toWei read property 'toWei' of undefined

printing out web3 shows that web3 has no utils as shown in the picture below, it is very strange.

screen shot 2018-03-16 at 13 33 19

@anthonymq
Copy link

Hi,
You should try window.web3.toWei(1, 'ether')

@jordanmurkin
Copy link

jordanmurkin commented Mar 21, 2018

You said that you are using version '1.0.0-beta.20', but your output is showing that web3 is using api version 0.20.3. Make sure that the correct version of web3 has been installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants