aboutsummaryrefslogtreecommitdiffstats
path: root/std/StandardToken.sol
diff options
context:
space:
mode:
authorDenton Liu <liu.denton+github@gmail.com>2016-08-19 22:51:40 +0800
committerDenton Liu <liu.denton+github@gmail.com>2016-08-19 23:13:24 +0800
commit9ca4948d6aca230d524882bbcabd1d4230a3ad23 (patch)
treeed8c42c185cf80796d886258d43f7289298a7438 /std/StandardToken.sol
parente25fcecaf4de63774b29ccabc456b4cbf38f8425 (diff)
downloaddexon-solidity-9ca4948d6aca230d524882bbcabd1d4230a3ad23.tar.gz
dexon-solidity-9ca4948d6aca230d524882bbcabd1d4230a3ad23.tar.zst
dexon-solidity-9ca4948d6aca230d524882bbcabd1d4230a3ad23.zip
CoinAdd .sol prefix to files
Diffstat (limited to 'std/StandardToken.sol')
-rw-r--r--std/StandardToken.sol55
1 files changed, 55 insertions, 0 deletions
diff --git a/std/StandardToken.sol b/std/StandardToken.sol
new file mode 100644
index 00000000..25d0bd38
--- /dev/null
+++ b/std/StandardToken.sol
@@ -0,0 +1,55 @@
+import "./Token.sol";
+
+contract StandardToken is Token {
+ uint256 tokenSupply;
+ mapping (address => uint256) balances;
+ mapping (address =>
+ mapping (address => uint256)) approvedTransfers;
+
+ 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];
+ }
+
+ function transfer(address _to, uint256 _value) returns (bool success) {
+ if (balances[msg.sender] >= _value) {
+ balances[msg.sender] -= _value;
+ balances[_to] += _value;
+ Transfer(msg.sender, _to, _value);
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ 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;
+ Transfer(_from, _to, _value);
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ function approve(address _spender, uint256 _value) returns (bool success) {
+ approvedTransfers[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];
+ }
+}