I'm trying to call the transfer() function on an ERC20 token through the use of delegatecall, my proxy contract however returns false from delegatecall.
When I try to call view functions like balanceOf() my proxy contract returns true. However since there are no possible exceptions in the balanceOf function I would also get 'true' even when returned "0" instead of "100000"
Token contract gets deployed through the constructor of the proxy contract. The owner of the token contract is the proxy contract. When deployed the proxy contract will mint 10000 tokens for the creator.
The imported token.sol contract is from open-zeppelin and works on its own.
pragma solidity ^0.4.20;
import './token.sol';
contract Test {
Token public token;
constructor () {
token = new Token("Test", "TST", 18);
token.mint(msg.sender, 10000);
}
function call(address _to, uint256 _value) returns (bool) {
return address(token).delegatecall(bytes4(sha3('transfer(address, uint256)')), _to, _value);
}
}
status 0x1 Transaction mined and execution succeed
decoded input {
"address _to": "0x14723A09ACff6D2A60DcdF7aA4AFf308FDDC160C",
"uint256 _value": "50"
}
decoded output {
"0": "bool: false"
}