aboutsummaryrefslogtreecommitdiffstats
path: root/std/StandardToken.sol
diff options
context:
space:
mode:
Diffstat (limited to 'std/StandardToken.sol')
-rw-r--r--std/StandardToken.sol44
1 files changed, 30 insertions, 14 deletions
diff --git a/std/StandardToken.sol b/std/StandardToken.sol
index 4ff1b8f9..4dad8541 100644
--- a/std/StandardToken.sol
+++ b/std/StandardToken.sol
@@ -3,31 +3,43 @@ pragma solidity ^0.4.0;
import "./Token.sol";
contract StandardToken is Token {
- uint256 public totalSupply;
- mapping (address => uint256) public balanceOf;
+ uint256 supply;
+ mapping (address => uint256) balance;
mapping (address =>
- mapping (address => uint256)) public allowance;
+ mapping (address => uint256)) m_allowance;
function StandardToken(address _initialOwner, uint256 _supply) {
- totalSupply = _supply;
- balanceOf[_initialOwner] = _supply;
+ supply = _supply;
+ balance[_initialOwner] = _supply;
+ }
+
+ function balanceOf(address _account) constant returns (uint) {
+ return balance[_account];
+ }
+
+ function totalSupply() constant returns (uint) {
+ return supply;
}
function transfer(address _to, uint256 _value) returns (bool success) {
- if (balanceOf[msg.sender] >= _value && balanceOf[_to] + _value >= balanceOf[_to]) {
- balanceOf[msg.sender] -= _value;
- balanceOf[_to] += _value;
- Transfer(msg.sender, _to, _value);
+ return doTransfer(msg.sender, _to, _value);
+ }
+
+ function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
+ if (m_allowance[_from][msg.sender] >= _value) {
+ if (doTransfer(_from, _to, _value)) {
+ m_allowance[_from][msg.sender] -= _value;
+ }
return true;
} else {
return false;
}
}
- function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
- if (allowance[_from][msg.sender] >= _value && balanceOf[_to] + _value >= balanceOf[_to]) {
- allowance[_from][msg.sender] -= _value;
- balanceOf[_to] += _value;
+ function doTransfer(address _from, address _to, uint _value) internal returns (bool success) {
+ if (balance[_from] >= _value && balance[_to] + _value >= balance[_to]) {
+ balance[_from] -= _value;
+ balance[_to] += _value;
Transfer(_from, _to, _value);
return true;
} else {
@@ -36,8 +48,12 @@ contract StandardToken is Token {
}
function approve(address _spender, uint256 _value) returns (bool success) {
- allowance[msg.sender][_spender] = _value;
+ m_allowance[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
+
+ function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
+ return m_allowance[_owner][_spender];
+ }
}