I'm using the Zeppelin ERC20 code and I can't seem to transfer
more than 9007000000000000 token "cents" at a time.
Address a
has a balanceOf
1000000000000000000000000 (10 million tokens * 1000000000000000000 (because I'm using 18 decimals)). However, when I transfer('b', 1000000000000000000000000)
from account a
, Remix says: Error encoding arguments: Error: Assertion failed
.
It gives me the same error for 100000000000000000000000, 10000000000000000000000, 1000000000000000000000, all the way down to 9007000000000000 (which it lets me transfer; it fails with slightly more (9008000000000000)).
balanceOf
for both accounts checks out correctly afterwards.
Also, when I comment out the assert
lines in SafeMath
, Remix gives me the same error. There are no other assert
ions in the code.
What's going wrong here?
pragma solidity ^0.4.15;
library SafeMath {
function sub(uint256 a, uint256 b) internal constant returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
using SafeMath for uint;
mapping(address => uint256) balances;
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
function transfer(address _to, uint256 _value) returns (bool) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}