aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src/1.0.0/ERC20Token
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts/src/1.0.0/ERC20Token')
-rw-r--r--packages/contracts/src/1.0.0/ERC20Token/ERC20Token_v1.sol44
1 files changed, 44 insertions, 0 deletions
diff --git a/packages/contracts/src/1.0.0/ERC20Token/ERC20Token_v1.sol b/packages/contracts/src/1.0.0/ERC20Token/ERC20Token_v1.sol
new file mode 100644
index 000000000..e05ee2d5e
--- /dev/null
+++ b/packages/contracts/src/1.0.0/ERC20Token/ERC20Token_v1.sol
@@ -0,0 +1,44 @@
+pragma solidity ^0.4.11;
+
+import { Token_v1 as Token } from "../Token/Token_v1.sol";
+
+contract ERC20Token_v1 is Token {
+
+ function transfer(address _to, uint _value) returns (bool) {
+ //Default assumes totalSupply can't be over max (2^256 - 1).
+ if (balances[msg.sender] >= _value && balances[_to] + _value >= balances[_to]) {
+ balances[msg.sender] -= _value;
+ balances[_to] += _value;
+ Transfer(msg.sender, _to, _value);
+ return true;
+ } else { return false; }
+ }
+
+ function transferFrom(address _from, address _to, uint _value) returns (bool) {
+ if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value >= balances[_to]) {
+ balances[_to] += _value;
+ balances[_from] -= _value;
+ allowed[_from][msg.sender] -= _value;
+ Transfer(_from, _to, _value);
+ return true;
+ } else { return false; }
+ }
+
+ function balanceOf(address _owner) constant returns (uint) {
+ return balances[_owner];
+ }
+
+ function approve(address _spender, uint _value) returns (bool) {
+ allowed[msg.sender][_spender] = _value;
+ Approval(msg.sender, _spender, _value);
+ return true;
+ }
+
+ function allowance(address _owner, address _spender) constant returns (uint) {
+ return allowed[_owner][_spender];
+ }
+
+ mapping (address => uint) balances;
+ mapping (address => mapping (address => uint)) allowed;
+ uint public totalSupply;
+}