I have a public contract variable: uint public bidEnd
, and I'm getting its value using web3js like so:
new web3.eth.Contract(json, address).methods.bidEnd().call(function(err, res){
console.log("err is ", err);
console.log(res);
};
And it's printing the following in the console:
err is Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.
at require.decodeParametersWith (index.js:299)
at require.decodeParameters (index.js:286)
at Contract.global._decodeMethodReturn (index.js:471)
at Method.outputFormatter (index.js:761)
at Method.formatOutput (index.js:148)
at sendTxCallback (index.js:524)
at cb (util.js:703)
at Item.run (browser.js:154)
at drainQueue (browser.js:124)
What am I doing wrong and how to fix this?
bidEnd
outputFormatter
appears in the stack trace so it looks like something went wrong while reading the result, so either the contract reverted and returned something that doesn't match the expected output or the abi is wrong/old and web3 fails when decoding the returned output.