Uncaught Error: Returned values aren't valid, did it run Out of Gas?

让人想犯罪 __ 提交于 2021-01-27 05:54:10

问题


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?


回答1:


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




回答2:


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.




回答3:


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.




回答4:


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.




回答5:


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.




回答6:


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!



来源:https://stackoverflow.com/questions/52956509/uncaught-error-returned-values-arent-valid-did-it-run-out-of-gas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!