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

× Unhandled Rejection (TypeError): Cannot read property 'toString' of null #7

Open
Madssimo opened this issue Jul 12, 2021 · 7 comments

Comments

@Madssimo
Copy link

`
const networkId = await web3.eth.net.getId()

const tokenData = Token.networks[networkId]
if(tokenData) {
  const token = new web3.eth.Contract(Token.abi, tokenData.address)
  this.setState({ token })
  let tokenBalance = await token.methods.balanceOf(this.state.account).call()
  this.setState({ tokenBalance: tokenBalance.toString() })
} else {
  window.alert('Token contract not deployed to detected network.')
}`
@upanshu1310
Copy link

Yes I am having the same problem. Someone please help

@Barrendero
Copy link

Barrendero commented Sep 7, 2021

Bros, just try this
Balance: {this.props.ethBalance ? window.web3.utils.fromWei(this.props.ethBalance.toString(), 'Ether') : ''}

@Simba0427
Copy link

@Madssimo, please try to migrate again.
truffle migrate --reset
That helped me.

@codingDr
Copy link

@Madssimo, please try to migrate again. truffle migrate --reset That helped me.

This is what I had to do as well. The reason this happened (for me) was that I was using the Quick Start Ganache chain instead of creating a workspace. After a PC reboot, the quick start chain was wiped. I recommend making a persistent workspace in Ganache, which will require reimporting the account into Metamask as well. Then migrate your contracts to the persistent chain as Simba0427 stated and you should be good to go.

@JoshuaDB
Copy link

@Simba0427

@Madssimo, please try to migrate again.
truffle migrate --reset
That helped me.

Thanks, that helped me as well.

@ameetmund
Copy link

@Madssimo, please try to migrate again. truffle migrate --reset That helped me.

Thanks @Simba0427 ... this helped me.

@wjlai1234
Copy link

same it's work!

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

8 participants