-
Notifications
You must be signed in to change notification settings - Fork 427
/
ERC20Capped.sol
52 lines (41 loc) · 992 Bytes
/
ERC20Capped.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
pragma solidity ^0.4.24;
import "zos-lib/contracts/Initializable.sol";
import "./ERC20Mintable.sol";
/**
* @title Capped token
* @dev Mintable token with a token cap.
*/
contract ERC20Capped is Initializable, ERC20Mintable {
uint256 private _cap;
function initialize(uint256 cap, address sender)
public
initializer
{
ERC20Mintable.initialize(sender);
require(cap > 0);
_cap = cap;
}
/**
* @return the cap for the token minting.
*/
function cap() public view returns(uint256) {
return _cap;
}
/**
* @dev Function to mint tokens
* @param to The address that will receive the minted tokens.
* @param amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(
address to,
uint256 amount
)
public
returns (bool)
{
require(totalSupply().add(amount) <= _cap);
return super.mint(to, amount);
}
uint256[50] private ______gap;
}