having a problem with calling a method of my deployed contract in the main Ethereum network.
I have a 'view' function which returns user's refund balance, everything worked fine in my local blockchain (Ganache), but doesn't work in the main network :(
So here I call that method from web3:
this.myContract.methods.checkFunds().call().then((refunds) => { return refunds; }); this is my contract function and here I call another contract function:
mapping(address => uint256) private funds; function checkFunds() external view returns(uint256) { return contract2.checkFunds(msg.sender); } here is that contract2:
function checkFunds(address _owner) public view returns(uint256) { return funds[_owner]; } if user doesn't have funds then it should return 0 and it's uint256, then it should be ok, but I get such an error:
Uncaught (in promise) Error: Returned values aren't valid, did it run Out of Gas? at ABICoder.decodeParameters (app.js:37038) at Contract._decodeMethodReturn (app.js:36366) at Method.outputFormatter (app.js:36719) at Method.formatOutput (app.js:9201) at sendTxCallback (app.js:9511) at app.js:96628 at inpage.js:1 at inpage.js:1 at o (inpage.js:1) at inpage.js:1 and I have the latest version of web3 btw:"react-web3": "1.2.0",
Do view functions cost gas ? That's strange, because I call another method of that contract to read items and it doesn't cost anything.
thank you!
viewfunction does not require any gas in order to execute it. It is merely a "peek" into the blockchain data (i.e., no mining is performed).contract2is initialized correctly.checkFunds()other contract, not of contract2.contract2deployed on the main network?