I would like to create a token contract and an implementation of that token contract, to be able to replace the implementation if I ever need to.
The constant functions work fine but the functions which modify the state do not.
Here is the code. I stripped some functions to make the code shorter
contract CoinImplementation is Owned, Token {
mapping (address => uint256) balances; // each address in this contract may have tokens.
bytes8 _name = "Soarcoin"; // name of this contract and investment fund
bytes4 _symbol = "SOAR"; // token symbol
uint8 _decimals = 6; // decimals (for humans)
uint256 _totalSupply;
uint8 flag = 0;
function CoinImplementation(uint256 initialMint) {
_totalSupply = initialMint;
balances[msg.sender] = initialMint;
}
// transfer tokens from one address to another
function transfer(address _to, uint256 _value) returns (bool success)
{
if (_value <= 0) throw;
// Check send token value > 0;
if (balances[msg.sender] < _value) return true;
// Check if the sender has enough
if (balances[msg.sender] < _value) return false;
// Check for overflows
balances[msg.sender] -= _value;
// Subtract from the sender
balances[_to] += _value;
// Add the same to the recipient, if it's the contact itself then it signals a sell order of those tokens
Transfer(msg.sender, _to, _value);
// Notify anyone listening that this transfer took place
return true;
}
}
and then I have the calling contract
contract Coin is Owned, Token {
Token implementation;
function Coin(Token _implementation) {
implementation = _implementation;
}
function transfer(address _to, uint256 _value) returns (bool success) {
return implementation.transfer(_to, _value);
}
}
if the transfer is called directly on the implementation it works but if the transfer on the Coin contract is called nothing happens.