I am building a very basic smart contract, 'CheckAllowance', on top of the 'FiatTokenV1' ERC20 token in the Remix Web3 Provider IDE. When I try to check an address's allowance in the 'FiatTokenV1' token contract from my smart contract, I get an estimateGas error.

Here are the steps I take:

  1. Initiate testrpc connection via MacBook terminal
  2. Deploy 'CheckAllowance' smart contract in Remix Web3 Provider IDE
  3. Deploy 'FiatTokenV1' ERC20 token contract in Remix Web3 Provider IDE (https://github.com/centrehq/centre-tokens/blob/master/contracts/FiatTokenV1.sol)
  4. Initialize, configure minter, mint 1000000 coins in token contract, then approve 'CheckAllowance' contract with 200000 allowance.
  5. Call checkAllowance function in 'CheckAllowance' contract with _tokenAdress = 'FiatTokenV1' address and _amount = 200000.
  6. Get "transact to CheckAllowance.checkAllowance errored: Error: VM Exception while executing eth_estimateGas: invalid opcode" error

I manually confirmed that there is a 200000 allowance for 'CheckAllowance' address as spender and 'FiatTokenV1' address as owner, so I don't understand the error.

Note that this exact process works fine in Remix Javascript VM! Any feedback is greatly appreciated.

pragma solidity ^0.4.24;

import 'openzeppelin-solidity/contracts/token/ERC20/ERC20.sol';

contract CheckAllowance {

    ERC20 public ERC20Interface;

    function checkAllowance(address _tokenAddress, uint _amount) public returns (bool) {
        ERC20Interface = ERC20(_tokenAddress);
        require(ERC20Interface.allowance(msg.sender, this) >= _amount);
        return true;

1 Answer 1


It seems probable you are incurring in a known current problem of ganache, which has a bug exactly in the evaluation of gas requirements when multicontract architecture is implemented.

Just deploy on a test network (ropsten is fine): if the error disappears again (as it does in JavaScript VM), your code is ok.

There is currently an open issue on the github of ganache, marked as “high priority bug”:


You can follow the issue. They will fix it ASAP.

  • Rick, just to clarify, this is happening to me in the Remix environment. It is my understanding that Remix and Ganache are separate testing environments. @rick-park
    – John Davis
    Commented Jan 15, 2019 at 4:35
  • Ganache is a local testnet only. I supposed you used ganache as local testnet in one of its various versions: ganache-cli, testrpc, etc. isn’t it? (“I initiate testrpc connection...”). Testrpc is the truffle name for ganache-cli. @JohnDavis
    – Rick Park
    Commented Jan 15, 2019 at 4:51
  • truffleframework.com/blog/testrpc-is-now-ganache
    – Rick Park
    Commented Jan 15, 2019 at 8:42
  • I tried running my process on the Ropsten test network as you suggested. Now I am getting the same error, but earlier in my process (step 4 above), when I run the mint() function from the erc20 token (github.com/centrehq/centre-tokens/blob/master/contracts/…). I guess I'm stuck with Javascript VM for now? I'm not sure how to test a user interface if Javascript VM is currently my only option.
    – John Davis
    Commented Jan 17, 2019 at 3:35
  • I can say that the main difference with JavaScript VM is the gas available: limited to that you wrote in the gas limit box in the “run” tab of Remix, 4.700.000 or so in Ropsten, 8.000.000 or so on rinkeby. What are the gas limit in your remix run tab?
    – Rick Park
    Commented Jan 17, 2019 at 10:04

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.