TX fails in private blockchain when trying to access an ERC20 contract from another contract

by Patricio   Last Updated May 15, 2019 14:28 PM - source

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"
}

Thanks!



Related Questions


Sending Ether from private Geth node to Mist Account

Updated February 14, 2019 07:28 AM

How do I connect a blockchain system to a cloud database

Updated September 28, 2017 01:28 AM


How are blockchain apps secured?

Updated July 09, 2017 07:28 AM

Private Ethereum Chain and Web3 js API

Updated April 20, 2018 18:28 PM