aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2017-01-21 02:41:25 +0800
committerchriseth <c@ethdev.com>2017-01-21 02:50:25 +0800
commitc6207e27613f9664c0d79a7c7d91048ec6fc8bfc (patch)
treedcca6f404f5c63e857e3f680169842715f9c84a8
parent61a15bb92efd24b54dfa982d42a600b075ebad38 (diff)
downloaddexon-solidity-c6207e27613f9664c0d79a7c7d91048ec6fc8bfc.tar
dexon-solidity-c6207e27613f9664c0d79a7c7d91048ec6fc8bfc.tar.gz
dexon-solidity-c6207e27613f9664c0d79a7c7d91048ec6fc8bfc.tar.bz2
dexon-solidity-c6207e27613f9664c0d79a7c7d91048ec6fc8bfc.tar.lz
dexon-solidity-c6207e27613f9664c0d79a7c7d91048ec6fc8bfc.tar.xz
dexon-solidity-c6207e27613f9664c0d79a7c7d91048ec6fc8bfc.tar.zst
dexon-solidity-c6207e27613f9664c0d79a7c7d91048ec6fc8bfc.zip
Make token constructible.
-rw-r--r--std/StandardToken.sol36
1 files changed, 24 insertions, 12 deletions
diff --git a/std/StandardToken.sol b/std/StandardToken.sol
index 4ff1b8f9..f59e04ac 100644
--- a/std/StandardToken.sol
+++ b/std/StandardToken.sol
@@ -3,20 +3,28 @@ 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;
+ if (balance[msg.sender] >= _value && balance[_to] + _value >= balance[_to]) {
+ balance[msg.sender] -= _value;
+ balance[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
} else {
@@ -25,9 +33,9 @@ contract StandardToken is Token {
}
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;
+ if (m_allowance[_from][msg.sender] >= _value && balance[_to] + _value >= balance[_to]) {
+ m_allowance[_from][msg.sender] -= _value;
+ balance[_to] += _value;
Transfer(_from, _to, _value);
return true;
} else {
@@ -36,8 +44,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];
+ }
}