I have an ERC20 contract and I am trying to access it from another contract, which is a Faucet. In the Faucet I have a function to query an account's balance, and another one to transfer some tokens to an account.

When I test everything in Ganache or Ropsten, it works normally. When I test this in a private local Geth network, this happens:

  • I am able to deploy both contracts.
  • I am able to transfer some tokens from the ERC20 to the Faucet.
  • When I try to query the balance of an account by sending a transaction to the Faucet I get: "Error: Returned values aren't valid, did it run Out of Gas?"
  • When I try to do a transfer by calling the Faucet, the transaction fails (it is mined, I get a transaction hash, but it fails and consumes all the gas).

What could I be missing? This doesn't seem like a problem in the contracts.

This is the Faucet's code:

pragma solidity 0.5.0;

import "./Token/ERC20Basic.sol";
import "./Token/SafeERC20.sol";

contract Faucet {
    event AccountFunded(address account);

    address public tokenAddress;

    constructor(address _tokenAddress) public payable {
        tokenAddress = _tokenAddress;

    function () external payable {}

    function testBalance(address account) public view returns (uint) {
        return ERC20Basic(tokenAddress).balanceOf(account);

    function transfer(address account) public {
        SafeERC20.safeTransfer(ERC20Basic(tokenAddress), account, 10);
        emit AccountFunded(account);

I am deploying and calling the contracts with Truffle. I tried different gas limits for the private geth network. This is the genesis file:

  "config": {
        "chainId": 1337,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
  "alloc"      : {},
  "coinbase"   : "0x0000000000000000000000000000000000000000",
  "difficulty" : "0x100",
  "extraData"  : "",
  "gasLimit"   : "0x700000000",
  "nonce"      : "0x0000000000000042",
  "mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp"  : "0x00"


  • 2
    Are you using solc v0.5? Since solc v0.5 uses new constantinople & petersburg opcodes perhaps the issue is that your private blockchain doesn't have them enabled. That should generate invalid opcode error message and consume all gas available.
    – Ismael
    May 15 '19 at 17:39

While I don't know if ERC20Basic uses the require opcode or some other opcode that was introduced later in development, I would try changing your genesis.json's "config" object to look something like this:

"homesteadBlock": 0,
"eip155Block": 0,
"eip150Block": 0,
"eip160Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0

It is most probably an issue with byzantiumBlock not being set.

Edit: Taking Ismael's point into account, I've added constantinopleBlock and petersburgBlock to config.


Your Answer

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

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