pragmasolidity <= 0.5.4;contractOwnable{
addressprivate _owner;
eventOwnershipTransferred(addressindexed previousOwner, addressindexed newOwner);
constructor() internal{
_owner =msg.sender;
emit OwnershipTransferred(address(0), _owner);
}
functionowner() publicviewreturns (address) {
return _owner;
}
functionisOwner() publicviewreturns (bool) {
returnmsg.sender== _owner;
}
modifieronlyOwner() {
require(msg.sender== _owner, "Ownable: caller is not the owner");
_;
}
functiontransferOwnership(address newOwner) publiconlyOwner{
require(newOwner !=address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
Contract Source Code
File 4 of 5: SafeMath.sol
pragmasolidity ^0.5.0;/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/librarySafeMath{
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/functionadd(uint256 a, uint256 b) internalpurereturns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/functionsub(uint256 a, uint256 b) internalpurereturns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/functionsub(uint256 a, uint256 b, stringmemory errorMessage) internalpurereturns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/functionmul(uint256 a, uint256 b) internalpurereturns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the// benefit is lost if 'b' is also tested.// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522if (a ==0) {
return0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/functiondiv(uint256 a, uint256 b) internalpurereturns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/functiondiv(uint256 a, uint256 b, stringmemory errorMessage) internalpurereturns (uint256) {
// Solidity only automatically asserts when dividing by 0require(b >0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't holdreturn c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/functionmod(uint256 a, uint256 b) internalpurereturns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/functionmod(uint256 a, uint256 b, stringmemory errorMessage) internalpurereturns (uint256) {
require(b !=0, errorMessage);
return a % b;
}
}
Contract Source Code
File 5 of 5: TristersLightCoin.sol
pragmasolidity <= 0.5.4;import'SafeMath.sol';
import'Ownable.sol';
import'Address.sol';
import'IERC20.sol';
contractTristersLightCoinisOwnable, IERC20{
usingSafeMathforuint256;
usingAddressforaddress;
stringpublicconstant name ='Trister’s Light Coin';
stringpublicconstant symbol ='Trister';
uint256publicconstant decimals =18;
uint256publicconstant totalSupply =8000*10000*10** decimals;
uint256publicconstant FounderAllocation =500*10000*10** decimals;
uint256publicconstant FounderLockupAmount =300*10000*10** decimals;
uint256publicconstant FounderLockupCliff =180days;
uint256publicconstant FounderReleaseInterval =30days;
uint256publicconstant FounderReleaseAmount =50*10000*10** decimals;
addresspublic founder =address(0);
uint256public founderLockupStartTime =0;
uint256public founderReleasedAmount =0;
mapping (address=>uint256) private _balances;
mapping (address=>mapping (address=>uint256)) private _allowances;
eventTransfer(addressindexedfrom, addressindexed to, uint256 value);
eventApproval(addressindexedfrom, addressindexed to, uint256 value);
eventChangeFounder(addressindexed previousFounder, addressindexed newFounder);
eventSetMinter(addressindexed minter);
constructor(address _founder, address _operator) public{
require(_founder !=address(0), "TristersLightCoin: founder is the zero address");
require(_operator !=address(0), "TristersLightCoin: operator is the zero address");
founder = _founder;
founderLockupStartTime =block.timestamp;
_balances[address(this)] = totalSupply;
_transfer(address(this), _operator, FounderAllocation.sub(FounderLockupAmount));
}
functionrelease() public{
uint256 currentTime =block.timestamp;
uint256 cliffTime = founderLockupStartTime.add(FounderLockupCliff);
if (currentTime < cliffTime) return;
if (founderReleasedAmount >= FounderLockupAmount) return;
uint256 month = currentTime.sub(cliffTime).div(FounderReleaseInterval);
uint256 releaseAmount = month.mul(FounderReleaseAmount);
if (releaseAmount > FounderLockupAmount) releaseAmount = FounderLockupAmount;
if (releaseAmount <= founderReleasedAmount) return;
uint256 amount = releaseAmount.sub(founderReleasedAmount);
founderReleasedAmount = releaseAmount;
_transfer(address(this), founder, amount);
}
functionbalanceOf(address account) publicviewreturns (uint256) {
return _balances[account];
}
functiontransfer(address to, uint256 amount) publicreturns (bool) {
_transfer(msg.sender, to, amount);
returntrue;
}
functionallowance(addressfrom, address to) publicviewreturns (uint256) {
return _allowances[from][to];
}
functionapprove(address to, uint256 amount) publicreturns (bool) {
_approve(msg.sender, to, amount);
returntrue;
}
functiontransferFrom(addressfrom, address to, uint256 amount) publicreturns (bool) {
uint256 remaining = _allowances[from][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance");
_transfer(from, to, amount);
_approve(from, msg.sender, remaining);
returntrue;
}
function_transfer(addressfrom, address to, uint256 amount) private{
require(from!=address(0), "ERC20: transfer from the zero address");
require(to !=address(0), "ERC20: transfer to the zero address");
_balances[from] = _balances[from].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[to] = _balances[to].add(amount);
emit Transfer(from, to, amount);
}
function_approve(addressfrom, address to, uint256 amount) private{
require(from!=address(0), "ERC20: approve from the zero address");
require(to !=address(0), "ERC20: approve to the zero address");
_allowances[from][to] = amount;
emit Approval(from, to, amount);
}
functionchangeFounder(address _founder) publiconlyOwner{
require(_founder !=address(0), "TristersLightCoin: founder is the zero address");
emit ChangeFounder(founder, _founder);
founder = _founder;
}
functionsetMinter(address minter) publiconlyOwner{
require(minter !=address(0), "TristersLightCoin: minter is the zero address");
require(minter.isContract(), "TristersLightCoin: minter is not contract");
_transfer(address(this), minter, totalSupply.sub(FounderAllocation));
emit SetMinter(minter);
}
}