web3.js icon indicating copy to clipboard operation
web3.js copied to clipboard

Web3 1.0.0-beta.38 TypeError: Invalid attempt to spread non-iterable instance

Open patidarmanoj10 opened this issue 7 years ago • 5 comments

Getting below error when calling myContract.methods.myMethod().call()

TypeError: Invalid attempt to spread non-iterable instance

This this was working fine in previous beta versions 37, 36 etc. When I upgraded to beta.38 I started getting above error.

patidarmanoj10 avatar Jan 27 '19 05:01 patidarmanoj10

I've tested it on my local environment and couldn't replicate this issue. Could you please use the issue template and provide all the information.

nivida avatar Jan 27 '19 09:01 nivida

I got same trouble, too. my contract methods using openzeppelin-solidity(v2.1.2) failed even if contract.methods.totalSupply().call(). my enviroment is here.

Truffle v5.0.2 (core: 5.0.2)
Solidity v0.5.0 (solc-js)
Node v10.14.2
solc: Version: 0.5.2+commit.1df8f40c.Darwin.appleclang

studioTeaTwo avatar Jan 27 '19 10:01 studioTeaTwo

Tested it again and got the same error. It was because of the deep cloning of the arguments. (fixed in #2232)

nivida avatar Jan 27 '19 14:01 nivida

@nivida This seems to be working fine now. Thanks for providing quick fix.

patidarmanoj10 avatar Jan 28 '19 17:01 patidarmanoj10

I am getting the same error in this function:

const balanceOf = (application, web3, address) => {
  return application.contract.methods.balanceOf(address).call()
    .then(balance => {
      console.log(`[TOKEN] Balance of '${address}' is ${balance}.`);
      return { balance };
    });
};

arm531 avatar Jan 29 '19 00:01 arm531