Skip to content

Commit e940a2d

Browse files
authored
Merge pull request #333 from PolymathNetwork/faucet-fix
Faucet fix
2 parents 1dd8191 + 1bde6b3 commit e940a2d

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

contracts/mocks/PolyTokenFaucet.sol

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import "openzeppelin-solidity/contracts/math/SafeMath.sol";
1010
contract PolyTokenFaucet {
1111

1212
using SafeMath for uint256;
13-
uint256 totalSupply_ = 1000000;
13+
uint256 totalSupply_;
1414
string public name = "Polymath Network";
15-
uint8 public decimals = 18;
15+
uint8 public decimals;
1616
string public symbol = "POLY";
1717

1818
mapping(address => uint256) balances;
@@ -21,10 +21,19 @@ contract PolyTokenFaucet {
2121
event Transfer(address indexed _from, address indexed _to, uint256 _value);
2222
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
2323

24+
constructor() public {
25+
decimals = 18;
26+
totalSupply_ = 1000000 * uint256(10)**decimals;
27+
balances[msg.sender] = totalSupply_;
28+
emit Transfer(address(0), msg.sender, totalSupply_);
29+
}
30+
2431
/* Token faucet - Not part of the ERC20 standard */
2532
function getTokens(uint256 _amount, address _recipient) public returns (bool) {
26-
balances[_recipient] += _amount;
27-
totalSupply_ += _amount;
33+
require(_amount <= 1000000 * uint256(10)**decimals, "Amount can not be more than 1 million");
34+
require(_recipient != address(0), "Recipient address can not be empty");
35+
balances[_recipient] = balances[_recipient].add(_amount);
36+
totalSupply_ = totalSupply_.add(_amount);
2837
emit Transfer(address(0), _recipient, _amount);
2938
return true;
3039
}

0 commit comments

Comments
 (0)