My front + smart contract is working on localhost. Now, I deployed at Rinkeby and all functions that has external calls are not working. Metamask says there will an exception even before the submission

"Transaction Error. Exception thrown in contract code."

So, I tried to execute any of these functions on Remix. I also could not execute them. Remix says that there is an error during gas estimation:

"Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? Error: gas required exceeds allowance or always failing transaction at chrome-....".

In fact, Remix is warning about gas estimation during compilation:

"Gas requirement of function TradeableContract.makeUntrustedWithdrawalOfTokens(address,uint256) high: infinite. If the gas requirement of a function is higher than the block gas limit, it cannot be executed. Please avoid loops in your functions or actions that modify large areas of storage (this includes clearing or copying arrays in storage)."

There is an example of such a function below. Does anyone has a clue?

function makeUntrustedWithdrawalOfTokens (address tokenAddr, uint256 value) public onlyOwner returns (bool) {

    bool b = IERC20Token(tokenAddr).transfer(owner,value);

    emit WithdrawTokensEvent(tokenAddr, owner, value, b);

    return b;


I am using web3 1.0 in the front end, but this error seems to be not related to that, since it also happens on Remix.

  • Is tokenAddr an address of a deployed ERC20 token contract? Does the contract making the call (the one makeUntrustedWithdrawalOfTokens is in) have a sufficient balance of the token to cover a transfer with the amount value? – smarx Aug 23 '18 at 20:38
  • I is a deployed contract in Rinkeby. I am passing value=0 (to avoid this issue of do not have funds). Also, I can call the ERC20 transfer directly using Remix. I developed this ERCToken and it works with 0. Finally, I did not set gas limit in the js code (in the function that invokes the smart contract via web3) since it is optional and Metamask proposes a big number (maybe the block limit?). I think it is due to the fact that Metamask could not estimate the gas limit. – Suzana Maranhão Aug 23 '18 at 21:17
  • If you get an infinite number as gas limit in the erorr message then most likely you are passing the gas limit parameter to transaction the wrong way. – Nulik Aug 23 '18 at 21:41
  • @Nulik I don't believe that's true. An infinite gas warning from the compiler indicates that the compiler didn't know how much gas you would need. (That's going to be true any time you make a call to another contract.) And the gas estimation failure just means that the transaction is going to revert. (When a node tries to estimate gas, it runs the transaction locally, discarding the result, and then tells you how much gas it took. If it reverts or asserts, that's a failure in gas estimation and just means the transaction won't work.) – smarx Aug 23 '18 at 22:16
  • @SuzanaMaranhão Could you share a link to a failed transaction? That way we can see both contracts involved. (Bonus points if you've verified the source code on Etherscan so we can also see the full source code for both.) – smarx Aug 23 '18 at 22:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.