-
Notifications
You must be signed in to change notification settings - Fork 1
/
IownToken.sol
106 lines (92 loc) · 3.6 KB
/
IownToken.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
pragma solidity ^0.5.7;
import "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "./UpgradeableToken.sol";
import "./TokenTreasury.sol";
import "./TransfererRole.sol";
/**
* @title IownToken
* @dev IownToken is a Utility Token for iOWN,
* the contract contains standard ERC20 Token functionality with some extra functionality specific to project
* to serve as a way to participate in iOWN Platform services
*/
contract IownToken is ERC20Detailed, UpgradeableToken, TransfererRole {
using SafeMath for uint256;
/** The date before which release must be triggered or token MUST be upgraded. */
uint private _releaseDate;
/** Token release switch. */
bool private _released = false;
/** Holds the ODR address: where remainder of hard cap goes*/
address private _odrAddress;
/** Holds the address of the treasury smart contract */
address private _treasuryAddress;
/** Occurs when someone puts tokens into iOWN Private Treasury */
event TreasuredTokens(address owner, uint256 amount, uint until);
/** Occurs when owner updates the address of the iOWN Treasury */
event TreasuryReconfigured(address newTreasury);
modifier whenNotReleased() {
require(_released == false, "Token is already released");
}
constructor(
string memory name,
string memory symbol,
uint totalSupply,
uint8 decimals,
uint releaseDate
)
ERC20()
ERC20Detailed(name, symbol, decimals)
MinterRole()
CappedBurnableToken(totalSupply)
PauserRole()
Pausable()
ERC20Pausable()
Ownable()
UpgradeableToken()
TransfererRole()
public
{
_releaseDate = releaseDate;
}
/**
* @dev Function to transfer ownership of contract to another address
* Does not remove original owner from roles "pauser" and "minter"
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0), "Invalid new owner address");
require(tx.origin == msg.sender, "Can not set owner as a smart contract");
//Give the newOwner address full control
addMinter(newOwner);
addPauser(newOwner);
addTransferer(newOwner);
super.transferOwnership(newOwner);
}
/**
* @dev Function to mark the token as released and allow transfers
*/
function releaseTokenTransfer() external onlyOwner returns (bool isSuccess) {
require(_odrAddress != address(0), "ODR Address must be set before releasing token");
uint256 remainder = cap().sub(totalSupply());
if(remainder > 0) mint(_odrAddress, remainder); //Mint remainder of tokens to ODR wallet
_released = true;
return _released;
}
/**
* @dev Allows Owner to set the ODR address which will hold the remainder of the tokens on release
* @param odrAddress The address of the ODR wallet
*/
function setODR(address odrAddress) external onlyOwner returns (bool isSuccess) {
require(odrAddress != address(0), "Invalid ODR address");
_odrAddress = odrAddress;
return true;
}
/**
* @dev Mint tokens: restricted only when token not released
* @param to The address that will receive the minted tokens.
* @param value The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address to, uint256 value) public whenNotReleased onlyMinter returns (bool) {
return super.mint(to, value);
}
}