diff options
author | Denton Liu <liu.denton+github@gmail.com> | 2016-08-19 23:21:54 +0800 |
---|---|---|
committer | Denton Liu <liu.denton+github@gmail.com> | 2016-08-19 23:21:54 +0800 |
commit | 876b39e8e55c41ffc848dbb0f0210bde62dd511d (patch) | |
tree | 85a5c789afab6bb2915373a16c6a2ed9a50b0cde /std | |
parent | 9ca4948d6aca230d524882bbcabd1d4230a3ad23 (diff) | |
download | dexon-solidity-876b39e8e55c41ffc848dbb0f0210bde62dd511d.tar dexon-solidity-876b39e8e55c41ffc848dbb0f0210bde62dd511d.tar.gz dexon-solidity-876b39e8e55c41ffc848dbb0f0210bde62dd511d.tar.bz2 dexon-solidity-876b39e8e55c41ffc848dbb0f0210bde62dd511d.tar.lz dexon-solidity-876b39e8e55c41ffc848dbb0f0210bde62dd511d.tar.xz dexon-solidity-876b39e8e55c41ffc848dbb0f0210bde62dd511d.tar.zst dexon-solidity-876b39e8e55c41ffc848dbb0f0210bde62dd511d.zip |
Fix StandardToken
Diffstat (limited to 'std')
-rw-r--r-- | std/StandardToken.sol | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/std/StandardToken.sol b/std/StandardToken.sol index 25d0bd38..d2567fec 100644 --- a/std/StandardToken.sol +++ b/std/StandardToken.sol @@ -1,28 +1,20 @@ import "./Token.sol"; contract StandardToken is Token { - uint256 tokenSupply; - mapping (address => uint256) balances; + uint256 public totalSupply; + mapping (address => uint256) public balanceOf; mapping (address => - mapping (address => uint256)) approvedTransfers; + mapping (address => uint256)) public allowance; function StandardToken(address _initialOwner, uint256 _supply) { - tokenSupply = _supply; - balances[_initialOwner] = _supply; - } - - function totalSupply() constant returns (uint256 supply) { - return tokenSupply; - } - - function balanceOf(address _owner) constant returns (uint256 balance) { - return balances[_owner]; + totalSupply = _supply; + balanceOf[_initialOwner] = _supply; } function transfer(address _to, uint256 _value) returns (bool success) { - if (balances[msg.sender] >= _value) { - balances[msg.sender] -= _value; - balances[_to] += _value; + if (balanceOf[msg.sender] >= _value) { + balanceOf[msg.sender] -= _value; + balanceOf[_to] += _value; Transfer(msg.sender, _to, _value); return true; } @@ -32,9 +24,9 @@ contract StandardToken is Token { } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { - if (approvedTransfers[_from][msg.sender] >= _value) { - approvedTransfers[_from][msg.sender] -= _value; - balances[_to] += _value; + if (allowance[_from][msg.sender] >= _value) { + allowance[_from][msg.sender] -= _value; + balanceOf[_to] += _value; Transfer(_from, _to, _value); return true; } @@ -44,12 +36,8 @@ contract StandardToken is Token { } function approve(address _spender, uint256 _value) returns (bool success) { - approvedTransfers[msg.sender][_spender] = _value; + allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } - - function allowance(address _owner, address _spender) constant returns (uint256 remaining) { - return approvedTransfers[_owner][_spender]; - } } |