Remix behaves differently when running Javascript VM and web3 provider mode.
I have two contracts:
contract ERC20Basic {
function totalSupply() public view returns (uint256){}
function balanceOf(address who) public view returns (uint256){}
function transfer(address to, uint256 value) public returns (bool){}
event Transfer(address indexed from, address indexed to, uint256 value);
}
and AegisMarketing contract which is calling functions from ERC20Basic.
I have a problem calling AegisMarketing GetBalanceTest function.
function GetBalanceTest() public constant returns (uint256)
{
return token.balanceOf(address(this));
}
which in ERC20Basic is defined as follows:
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
If I compile and deploy those contract in Remix in Javascript VM mode then everything works fine. I get correct value running both AegisMarketing.GetBalanceTest() and also ERC20Basic.balanceOf() function.
When I deploy in my truffle to local geth or via Remix Web3 provider to my local geth AegisMarketing.GetBalanceTest always returns 0,but when I check balance of AegisMarketing contract in ERC20Basic itself I get correct value.
General idea is that AegisMarketing contract is using ERC20Basic token contract to airdrop tokens to some accounts. AegisMarketing contract must have some positive balance in ERC20Basic contract to be able to aidrop those tokens and this is what I am trying to check.
The whole project is here: https://github.com/robertmagier/AegisMarketing
AegisMarketing contract is in contracts/AegisMarketing.sol
ERC20Basic token is in contracts/Token.sol
This is how it looks in Remix. I checked many times that I am checking correct Contract address in balanceOf function. And it works in Javascript VM mode in Remix.
GetBalanceTest()
since thebalanceOf
function of the ERC20 token is public.