aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenton Liu <liu.denton+github@gmail.com>2016-08-17 22:53:21 +0800
committerDenton Liu <liu.denton+github@gmail.com>2016-08-19 22:34:50 +0800
commit04ffff3cac99690dff79755e9c746c009fab5706 (patch)
treeeca3f4db2d1bb55d9c600e2d716e8aeeb2e69baa
parentfd578f0ed55c4d08f0292915c3cf4595558d4f06 (diff)
downloaddexon-solidity-04ffff3cac99690dff79755e9c746c009fab5706.tar
dexon-solidity-04ffff3cac99690dff79755e9c746c009fab5706.tar.gz
dexon-solidity-04ffff3cac99690dff79755e9c746c009fab5706.tar.bz2
dexon-solidity-04ffff3cac99690dff79755e9c746c009fab5706.tar.lz
dexon-solidity-04ffff3cac99690dff79755e9c746c009fab5706.tar.xz
dexon-solidity-04ffff3cac99690dff79755e9c746c009fab5706.tar.zst
dexon-solidity-04ffff3cac99690dff79755e9c746c009fab5706.zip
Add ExampleToken
-rw-r--r--std/ExampleToken55
1 files changed, 55 insertions, 0 deletions
diff --git a/std/ExampleToken b/std/ExampleToken
new file mode 100644
index 00000000..6d617199
--- /dev/null
+++ b/std/ExampleToken
@@ -0,0 +1,55 @@
+import "./Token";
+
+contract ExampleToken is Token {
+ uint256 tokenSupply;
+ mapping (address => uint256) balances;
+ mapping (address =>
+ mapping (address => uint256)) approvedTransfers;
+
+ function ExampleToken(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];
+ }
+}