0

When I launch the app with with react.. this error occur when my exchange contract is loaded.. Here is the code i wrote to talk to the blockchain:

export const loadBalances = async (dispatch, web3, exchange, token, account) => {
  const etherBalance = await web3.eth.getBalance(account)
  dispatch(etherBalanceLoaded(etherBalance))

  const tokenBalance = await token.methods.balanceOf(account).call()
  dispatch(tokenBalanceLoaded(tokenBalance))

  const exchangeEtherBalance = await exchange.methods.balanceOf(ETHER_ADDRESS, account).call()
  dispatch(exchangeEtherBalanceLoaded(exchangeEtherBalance))

  const exchangeTokenBalance = await exchange.methods.balanceOf(token.options.address, account).call()
  dispatch(exchangeTokenBalanceLoaded(exchangeTokenBalance))

  dispatch(balancesLoaded())
}

web3 v1.0.0 beta46 Truffle v5.0.5 (core: 5.0.5) Solidity v0.5.0 (solc-js) Node v9.10.0

Here is the error when i use the debugger enter image description here

Update: The error i get when i update to web3 v1.2.1 enter image description here

  • Your call stack is incomplete, but it appears to be a problem with loadBalances function and not loadExchange. – Ismael Sep 12 at 1:53
  • Hi Ismael.. This error occur after the loadExchange function.. This is the only function that suck on the "interaction.js" script.. (i'm using Redux) – Alioune Badara DIAKHATE Sep 12 at 2:32
  • The call stack is incomplete so take what I say with caution but if you look at the bottom there is a loadBalances at interactions.js:130, and everything above it seems related to balances. Without debugging the source code is hard to say anything else. – Ismael Sep 12 at 3:17
  • Hi Ismael. I saw the loadBalances at interactions.js:130 But now how can i complete the call stack?? Because before that there was not this problem at this level I do not know why it started to make bugs.. And i'm a beginner in the dApp development.. – Alioune Badara DIAKHATE Sep 12 at 13:32
  • You can try to set a breakpoint there and examine the parameters values. Add more debug code around there is no magic you have to debug it like any other webapp. – Ismael Sep 12 at 14:30
1

You declared you function as async but never used the async/await pattern. I added the await at the correct position for you.

Try this:

export const loadExchange = async (web3, networkId, dispatch) => {
  try {
    const exchange = await web3.eth.Contract(Exchange.abi, Exchange.networks[networkId].address)
    dispatch(await exchangeLoaded(exchange))
    return exchange
  } catch (error) {
    console.log('Contract not deployed to the current network. Please select another network with Metamask.')
    return null
  }
}
  • Hi Niklas the result still the same with the keyword "await".. – Alioune Badara DIAKHATE Sep 11 at 19:54
  • Try adding in the second await as well. (I'm not certain if it works that way) – Niklas Feurstein Sep 11 at 20:02
  • Same thing.. I added the second await on the dispatch function.. – Alioune Badara DIAKHATE Sep 11 at 20:06
  • Please provide the output of Exchange.networks[networkId].address I think its empty – Niklas Feurstein Sep 11 at 20:19
  • You can see the address objet on the screenshot.. – Alioune Badara DIAKHATE Sep 11 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.