9

I'm listening to events of my deployed contract. Whenever a transaction gets completed and event is fired receiving the response causes following error:

Uncaught Error: Returned values aren't valid, did it run Out of Gas? at ABICoder.push../node_modules/web3-eth-abi/src/index.js.ABICoder.decodeParameters (index.js:227) at ABICoder.push../node_modules/web3-eth-abi/src/index.js.ABICoder.decodeLog (index.js:277)

Web3 version: 1.0.0-beta36

Metamask version: 4.16.0

How to fix it?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Ferit
  • 8,692
  • 8
  • 34
  • 59

8 Answers8

9

Try the command truffle migrate --reset so that all the previous values are reset to their original value

nick
  • 1,090
  • 1
  • 11
  • 24
Ramesh babu
  • 89
  • 2
  • 5
6

Throws the same error when inside a transaction it generates different events with the same name and the same arguments. In my case, this was the Transfer event from ERC721 and ERC20. Renaming one of them solves this problem, but of course this isn't the right way.

Ivan Zakharov
  • 173
  • 1
  • 7
  • That was it, thanks a lot. Checked anything else first: inheritance problems, gas limits... after renaming all ERC721 events the problem disappeared. – TheFrozenOne Mar 07 '19 at 22:46
4

This is a bug in web3js, discussed here.

And the following change fixes it (source):

patch-package
--- a/node_modules/web3-eth-abi/src/index.js
+++ b/node_modules/web3-eth-abi/src/index.js
@@ -280,7 +280,7 @@ ABICoder.prototype.decodeLog = function (inputs, data, topics) {


     var nonIndexedData = data;
-    var notIndexedParams = (nonIndexedData) ? this.decodeParameters(notIndexedInputs, nonIndexedData) : [];
+    var notIndexedParams = (nonIndexedData && nonIndexedData !== '0x') ? this.decodeParameters(notIndexedInputs, nonIndexedData) : [];

     var returnValue = new Result();
     returnValue.__length__ = 0;

Edit: Also downgrading to web3-1.0.0.beta33 also fixes this issue too.

Ferit
  • 8,692
  • 8
  • 34
  • 59
2

Before even checking your ABI or redeploying, check to make sure Metamask is connected to whichever network your contract is actually deployed too. I stepped away and while i was afk Metamask logged out, I guess I wasn't watching closely and I was connected to Ropsten when I working on localhost. Simple mistake, wasted an hour or so trying to figure it out. Hope this helps someone else out!

2

This happened to me on my react app.

I deployed to contract to Ropsten network, but metamask was using the Rinkeby aaccount. So make sure whichever network you deployed, metamask should be using account from that network.

Yilmaz
  • 35,338
  • 10
  • 157
  • 202
1

The solution for me was changing of provider. With Infura the error is gone, but with Alchemy is still happening.

Silvio Guedes
  • 1,134
  • 15
  • 16
0

Please check your Metamask Login, This issue is generally populated when you are either log out of the Metamask or worse case you have 0 ether left at your account.

0

This can also happen when the MNEMONIC value from Ganache is different from the one you have in your truffle.js or truffle-config.js file.