I wrote one contract to call a function from another contract like below

pragma solidity ^0.5.1;

contract test3 {       
    address watch_addr = address(0x1234567963); //deployed contract address

    function balanceOf(address owner) public {
        watch_addr.call(abi.encodeWithSignature("balanceOf(address)", owner));
        return balanceOf(owner);

I want to call a balanceOf function in deployed contract.Now I deployed the new contract successfully but I am getting the following error while calling the balanceOf function

error:"Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? "

Can any one please tell me the solution? --Thanks

  • 1
    balanceOf calls itself every time, so you have an infinite loop.
    – user19510
    Commented Jan 25, 2019 at 9:51

1 Answer 1


You are calling balanceOf inside balanceOf , so it will be executed infinitely. Real estimation of gas for such actions are not possible or infinite. That's why you are getting this error. With smart contract, be damn sure with your logic.

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.