@@ -34,6 +34,11 @@ contract StandardToken is ERC20 {
34
34
mapping (address => uint256 ) public balances;
35
35
mapping (address => mapping (address => uint256 )) public allowed;
36
36
37
+ /**
38
+ * @dev transfer token for a specified address
39
+ * @param _to The address to transfer to.
40
+ * @param _value The amount to be transferred.
41
+ */
37
42
function transfer (address _to , uint256 _value ) returns (bool success ) {
38
43
require (balances[msg .sender ] >= _value && balances[_to] + _value > balances[_to]);
39
44
balances[msg .sender ] = balances[msg .sender ].sub (_value);
@@ -42,6 +47,12 @@ contract StandardToken is ERC20 {
42
47
return true ;
43
48
}
44
49
50
+ /**
51
+ * @dev Transfer tokens from one address to another
52
+ * @param _from address The address which you want to send tokens from
53
+ * @param _to address The address which you want to transfer to
54
+ * @param _value uint256 the amout of tokens to be transfered
55
+ */
45
56
function transferFrom (address _from , address _to , uint256 _value ) returns (bool success ) {
46
57
require (balances[_from] >= _value && allowed[_from][msg .sender ] >= _value && balances[_to] + _value > balances[_to]);
47
58
balances[_to] = balances[_to].add (_value);
@@ -51,16 +62,37 @@ contract StandardToken is ERC20 {
51
62
return true ;
52
63
}
53
64
65
+ /**
66
+ * @dev Gets the balance of the specified address.
67
+ * @param _owner The address to query the the balance of.
68
+ * @return An uint256 representing the amount owned by the passed address.
69
+ */
54
70
function balanceOf (address _owner ) constant returns (uint256 balance ) {
55
71
return balances[_owner];
56
72
}
57
73
74
+ /**
75
+ * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender.
76
+ * @param _spender The address which will spend the funds.
77
+ * @param _value The amount of tokens to be spent.
78
+ */
58
79
function approve (address _spender , uint256 _value ) returns (bool success ) {
80
+ // To change the approve amount you first have to reduce the addresses`
81
+ // allowance to zero by calling `approve(_spender, 0)` if it is not
82
+ // already 0 to mitigate the race condition described here:
83
+ // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
84
+ require ((_value == 0 ) || (allowed[msg .sender ][_spender] == 0 ));
59
85
allowed[msg .sender ][_spender] = _value;
60
86
Approval (msg .sender , _spender, _value);
61
87
return true ;
62
88
}
63
89
90
+ /**
91
+ * @dev Function to check the amount of tokens that an owner allowed to a spender.
92
+ * @param _owner address The address which owns the funds.
93
+ * @param _spender address The address which will spend the funds.
94
+ * @return A uint256 specifing the amount of tokens still available for the spender.
95
+ */
64
96
function allowance (address _owner , address _spender ) constant returns (uint256 remaining ) {
65
97
return allowed[_owner][_spender];
66
98
}
0 commit comments