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!

  • 1
    The error printout is misleading (you), because a view function 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). Commented Dec 25, 2018 at 12:23
  • 1
    I suggest that in your contract, check if contract2 is initialized correctly. Commented Dec 25, 2018 at 12:24
  • 1
    @goodvibration thank you for your reply. It's also in the main network and I have already tried to call it's functions, so the problem in this one only. Checked it in etherscan, it's also there, so that function exists and it's view one there Commented Dec 25, 2018 at 12:28
  • 1
    Make sure that you are calling the function checkFunds() other contract, not of contract2. Commented Dec 25, 2018 at 12:28
  • 1
    Well, is contract2 deployed on the main network? Commented Dec 25, 2018 at 12:28

2 Answers 2


You're doing a call(), without setting the msg.sender. Try to add the addr as a param to the checkFunds() function, modify the web3 call accordingly and see if that fixes it.

  from: 0x123...
}).then((refunds) => {
  return refunds;

input address in call()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.