@@ -58,12 +58,7 @@ contract ERC20 is IERC20 {
58
58
* @param value The amount to be transferred.
59
59
*/
60
60
function transfer (address to , uint256 value ) public returns (bool ) {
61
- require (value <= _balances[msg .sender ]);
62
- require (to != address (0 ));
63
-
64
- _balances[msg .sender ] = _balances[msg .sender ].sub (value);
65
- _balances[to] = _balances[to].add (value);
66
- emit Transfer (msg .sender , to, value);
61
+ _transfer (msg .sender , to, value);
67
62
return true ;
68
63
}
69
64
@@ -98,14 +93,10 @@ contract ERC20 is IERC20 {
98
93
public
99
94
returns (bool )
100
95
{
101
- require (value <= _balances[from]);
102
96
require (value <= _allowed[from][msg .sender ]);
103
- require (to != address (0 ));
104
97
105
- _balances[from] = _balances[from].sub (value);
106
- _balances[to] = _balances[to].add (value);
107
98
_allowed[from][msg .sender ] = _allowed[from][msg .sender ].sub (value);
108
- emit Transfer (from, to, value);
99
+ _transfer (from, to, value);
109
100
return true ;
110
101
}
111
102
@@ -157,6 +148,21 @@ contract ERC20 is IERC20 {
157
148
return true ;
158
149
}
159
150
151
+ /**
152
+ * @dev Transfer token for a specified addresses
153
+ * @param from The address to transfer from.
154
+ * @param to The address to transfer to.
155
+ * @param value The amount to be transferred.
156
+ */
157
+ function _transfer (address from , address to , uint256 value ) internal {
158
+ require (value <= _balances[from]);
159
+ require (to != address (0 ));
160
+
161
+ _balances[from] = _balances[from].sub (value);
162
+ _balances[to] = _balances[to].add (value);
163
+ emit Transfer (from, to, value);
164
+ }
165
+
160
166
/**
161
167
* @dev Internal function that mints an amount of the token and assigns it to
162
168
* an account. This encapsulates the modification of balances such that the
0 commit comments