Uncaught Error: Returned values aren't valid, did it run Out of Gas?
Solution 1
Try the command truffle migrate --reset
so that all the previous values are reset to their original value
Solution 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.
Solution 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.
Solution 4
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.
Solution 5
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!
Comments
-
Ferit almost 2 years
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?
-
TheFrozenOne about 5 yearsThat was it, thanks a lot. Checked anything else first: inheritance problems, gas limits... after renaming all ERC721 events the problem disappeared.
-
Lead Developer almost 5 yearsThis helped me when I use Truffle Suite and Ganache. thanks.
-
Ruham over 4 yearsIf I'm using Truffle suite, where do I have to add this code?
-
nprz over 2 yearsThank you! This was the case for me as well.