Skip to content

Instantly share code, notes, and snippets.

@plusor
Last active August 31, 2018 02:27
Show Gist options
  • Save plusor/96c03c9bf9db4931c9ff62fa37a3e440 to your computer and use it in GitHub Desktop.
Save plusor/96c03c9bf9db4931c9ff62fa37a3e440 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=undefined&optimize=true&gist=
pragma solidity ^0.4.24;
contract AirPush {
}
pragma solidity ^0.4.24;
import "./Crowdsale.sol";
import "./SafeMath.sol";
/**
* @title AllowanceCrowdsale
* @dev Extension of Crowdsale where tokens are held by a wallet, which approves an allowance to the crowdsale.
*/
contract AllowanceCrowdsale is Crowdsale {
using SafeMath for uint256;
address public tokenWallet;
/**
* @dev Constructor, takes token wallet address.
* @param _tokenWallet Address holding the tokens, which has approved allowance to the crowdsale
*/
constructor(address _tokenWallet) public {
require(_tokenWallet != address(0));
tokenWallet = _tokenWallet;
}
/**
* @dev Checks the amount of tokens left in the allowance.
* @return Amount of tokens left in the allowance
*/
function remainingTokens() public view returns (uint256) {
return token.allowance(tokenWallet, this);
}
/**
* @dev Overrides parent behavior by transferring tokens from wallet.
* @param _beneficiary Token purchaser
* @param _tokenAmount Amount of tokens purchased
*/
function _deliverTokens(
address _beneficiary,
uint256 _tokenAmount
)
internal
{
require(token.transferFrom(tokenWallet, _beneficiary, _tokenAmount));
}
}
pragma solidity ^0.4.24;
import "./ERC20Basic.sol";
import "./SafeMath.sol";
/**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
/**
* @dev total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
}
}
pragma solidity ^0.4.24;
import "./BasicToken.sol";
import "./Ownable.sol";
contract BurnableToken is BasicToken, Ownable {
event Burn(address indexed burner, uint256 value);
/**
* @dev Burns a specific amount of tokens.
* @param _value The amount of token to be burned.
*/
function burn(uint256 _value) public onlyOwner {
_burn(msg.sender, _value);
}
function _burn(address _who, uint256 _value) internal {
require(_value <= balances[_who]);
// no need to require value <= totalSupply, since that would imply the
// sender's balance is greater than the totalSupply, which *should* be an assertion failure
balances[_who] = balances[_who].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(_who, _value);
emit Transfer(_who, address(0), _value);
}
}
pragma solidity ^0.4.24;
import "./SafeERC20.sol";
import "./SafeMath.sol";
/**
* @title Crowdsale
* @dev Crowdsale is a base contract for managing a token crowdsale,
* allowing investors to purchase tokens with ether. This contract implements
* such functionality in its most fundamental form and can be extended to provide additional
* functionality and/or custom behavior.
* The external interface represents the basic interface for purchasing tokens, and conform
* the base architecture for crowdsales. They are *not* intended to be modified / overriden.
* The internal interface conforms the extensible and modifiable surface of crowdsales. Override
* the methods to add functionality. Consider using 'super' where appropiate to concatenate
* behavior.
*/
contract Crowdsale {
using SafeMath for uint256;
using SafeERC20 for ERC20;
// The token being sold
ERC20 public token;
// Address where funds are collected
address public wallet;
// How many token units a buyer gets per wei.
// The rate is the conversion between wei and the smallest and indivisible token unit.
// So, if you are using a rate of 1 with a DetailedERC20 token with 3 decimals called TOK
// 1 wei will give you 1 unit, or 0.001 TOK.
uint256 public rate;
// Amount of wei raised
uint256 public weiRaised;
/**
* Event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
/**
* @param _rate Number of token units a buyer gets per wei
* @param _wallet Address where collected funds will be forwarded to
* @param _token Address of the token being sold
*/
constructor(uint256 _rate, address _wallet, ERC20 _token) public {
require(_rate > 0);
require(_wallet != address(0));
require(_token != address(0));
rate = _rate;
wallet = _wallet;
token = _token;
}
// -----------------------------------------
// Crowdsale external interface
// -----------------------------------------
/**
* @dev fallback function ***DO NOT OVERRIDE***
*/
function () external payable {
buyTokens(msg.sender);
}
/**
* @dev low level token purchase ***DO NOT OVERRIDE***
* @param _beneficiary Address performing the token purchase
*/
function buyTokens(address _beneficiary) public payable {
uint256 weiAmount = msg.value;
_preValidatePurchase(_beneficiary, weiAmount);
// calculate token amount to be created
uint256 tokens = _getTokenAmount(weiAmount);
// update state
weiRaised = weiRaised.add(weiAmount);
_processPurchase(_beneficiary, tokens);
emit TokenPurchase(
msg.sender,
_beneficiary,
weiAmount,
tokens
);
_updatePurchasingState(_beneficiary, weiAmount);
_forwardFunds();
_postValidatePurchase(_beneficiary, weiAmount);
}
// -----------------------------------------
// Internal interface (extensible)
// -----------------------------------------
/**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _preValidatePurchase(
address _beneficiary,
uint256 _weiAmount
)
internal
{
require(_beneficiary != address(0));
require(_weiAmount != 0);
}
/**
* @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _postValidatePurchase(
address _beneficiary,
uint256 _weiAmount
)
internal
{
// optional override
}
/**
* @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens.
* @param _beneficiary Address performing the token purchase
* @param _tokenAmount Number of tokens to be emitted
*/
function _deliverTokens(
address _beneficiary,
uint256 _tokenAmount
)
internal
{
token.safeTransfer(_beneficiary, _tokenAmount);
}
/**
* @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens.
* @param _beneficiary Address receiving the tokens
* @param _tokenAmount Number of tokens to be purchased
*/
function _processPurchase(
address _beneficiary,
uint256 _tokenAmount
)
internal
{
_deliverTokens(_beneficiary, _tokenAmount);
}
/**
* @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.)
* @param _beneficiary Address receiving the tokens
* @param _weiAmount Value in wei involved in the purchase
*/
function _updatePurchasingState(
address _beneficiary,
uint256 _weiAmount
)
internal
{
// optional override
}
/**
* @dev Override to extend the way in which ether is converted to tokens.
* @param _weiAmount Value in wei to be converted into tokens
* @return Number of tokens that can be purchased with the specified _weiAmount
*/
function _getTokenAmount(uint256 _weiAmount)
internal view returns (uint256)
{
return _weiAmount.mul(rate);
}
/**
* @dev Determines how ETH is stored/forwarded on purchases.
*/
function _forwardFunds() internal {
wallet.transfer(msg.value);
}
}
pragma solidity ^0.4.24;
import "./SafeERC20.sol";
import "./SafeMath.sol";
import "./Pausable.sol";
contract DelayTransferByMonth is Pausable {
using SafeMath for uint256;
using SafeERC20 for ERC20;
ERC20 public token;
struct Gate {
address beneficiary;
uint256 totalSupply;
uint8 rate;
uint256 startTime;
uint256 ransom;
uint256 times;
bool done;
bool paused;
}
event GateChanged(
string action,
address beneficiary,
uint256 totalSupply,
uint256 reward,
uint256 rate,
uint256 startTime,
uint256 ransom,
uint256 times,
bool done
);
event GateDestroy(
address op,
address beneficiary
);
mapping(address => Gate) public Gates;
constructor(ERC20 _token) public {
token = _token;
}
function destroyGate(address _beneficiary) public onlyOwner {
if (Gates[_beneficiary].totalSupply > 0) {
delete Gates[_beneficiary];
emit GateDestroy(msg.sender, _beneficiary);
}
}
function add(address _beneficiary, uint256 _totalSupply, uint8 _rate, uint256 _startTime) public onlyOwner {
Gate storage gate = Gates[_beneficiary];
if (gate.totalSupply > 0) {
revert();
}
require(_totalSupply > 1 ether);
require(_rate > 0);
require(_rate <= 100);
require(_startTime > block.timestamp);
require(_startTime < block.timestamp.add(3650 days));
gate.beneficiary = _beneficiary;
gate.totalSupply = _totalSupply;
gate.rate = _rate;
gate.startTime = _startTime;
gate.ransom = 0;
gate.times = 0;
gate.done = false;
gate.paused = false;
emit GateChanged('added', _beneficiary, _totalSupply, 0, _rate, _startTime, 0, 0, false);
}
function totalSupply() public view returns (uint256) {
return token.balanceOf(address(this));
}
function revoke() public onlyOwner {
token.transfer(msg.sender, totalSupply());
}
function destroyAndSend(address _recipient) onlyOwner public {
selfdestruct(_recipient);
}
function initializeToken() public {
uint256 tokenAmount = token.allowance(msg.sender, address(this));
token.transferFrom(msg.sender, address(this), tokenAmount);
}
function pauseByAddress(address _beneficiary, bool _paused) public onlyOwner {
Gate storage _gate = Gates[_beneficiary];
if (_gate.totalSupply > 0) {
_gate.paused = _paused;
}
}
function () public payable whenNotPaused {
Gate storage gate = Gates[msg.sender];
if (gate.totalSupply > 0) {
require(!gate.paused);
require(!gate.done);
require(block.timestamp > gate.startTime);
require(gate.ransom < gate.totalSupply);
require(block.timestamp >= gate.startTime.add(gate.times.mul(30 days)));
uint256 reward = gate.totalSupply.div(100).mul(gate.rate);
gate.ransom = gate.ransom.add(reward);
gate.times = gate.times.add(1);
if (gate.ransom > gate.totalSupply) {
uint256 overflow = gate.ransom.sub(gate.totalSupply);
reward = reward.sub(overflow);
gate.ransom = gate.totalSupply;
}
if (gate.ransom >= gate.totalSupply) {
gate.done = true;
}
if (reward > 0) {
require(token.transfer(gate.beneficiary, reward));
emit GateChanged('claim', msg.sender, gate.totalSupply, reward, gate.rate, gate.startTime, gate.ransom, gate.times, gate.done);
}
}
}
}
pragma solidity ^0.4.24;
contract Ownable {
address public owner;
constructor() public {
owner = msg.sender;
}
modifier onlyOwner() {
if (msg.sender == owner)
_;
}
function transferOwnership(address newOwner) public onlyOwner {
if (newOwner != address(0)) owner = newOwner;
}
}
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
}
contract Dispatcher is Ownable {
using SafeMath for uint256;
// Payroll
mapping (address => uint256) internal balances;
uint256 public totalAmount;
event Withdrawal(address beneficiary, uint256 amount);
event ClaimTransfer(address indexed staff, uint256 amount);
event Employees(address staff, uint8 state);
function () public payable {
}
function withdrawal() public onlyOwner {
uint256 balance = address(this).balance;
owner.transfer(balance);
emit Withdrawal(owner, balance);
}
/**
* @dev Get staff wage
* @param staff staff address
**/
function balance(address staff) public view onlyOwner returns (uint256) {
return balances[staff];
}
/**
* @dev Add amount to payroll;
* @param staff user address
* @param amount wage
**/
function add(address staff, uint256 amount) public onlyOwner returns (bool) {
require(amount > 0);
totalAmount = totalAmount.add(amount);
balances[staff] = amount;
emit Employees(staff, 1);
return true;
}
/**
* @dev Remove user from payroll;
* @param staff user address
**/
function remove(address staff) public onlyOwner returns (bool) {
totalAmount = totalAmount.sub(balances[staff]);
delete balances[staff];
emit Employees(staff, 0);
return true;
}
/**
* @dev Claim wage
* @param staff user address
**/
function claim(address staff) public onlyOwner returns (bool) {
require(address(this).balance > balances[staff]);
staff.transfer(balances[staff]);
emit ClaimTransfer(staff, balances[staff]);
return true;
}
function claimWithAddresses(address[] _employees) public onlyOwner {
for (uint256 i = 0; i < _employees.length; i++) {
require(claim(_employees[i]));
}
}
}
pragma solidity ^0.4.24;
import "./ERC20Basic.sol";
/**
* @title ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/20
*/
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender)
public view returns (uint256);
function transferFrom(address from, address to, uint256 value)
public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
function sender() public view returns (address) {
return msg.sender;
}
}
pragma solidity ^0.4.24;
contract ERC20Basic {
function totalSupply() public view returns (uint256);
function balanceOf(address who) public view returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
pragma solidity ^0.4.24;
import "./Crowdsale.sol";
import "./TimedCrowdsale.sol";
import "./WhitelistedCrowdsale.sol";
import "./Pausable.sol";
contract IFTCCrowdsale is Crowdsale, WhitelistedCrowdsale, TimedCrowdsale, Pausable {
using SafeMath for uint256;
mapping(address => uint256) public balances;
// Total of approved tokens
uint256 public tokensAmount;
// Total of claim tokens
uint256 public returnTokensAmount;
event ReturnToken(address indexed purchaser, address indexed beneficiary,uint256 value, uint256 amount);
constructor(address _wallet, ERC20 _token, uint256 _tokensAmount, uint256 _openingTime, uint256 _closingTime) Crowdsale(1, _wallet, _token) TimedCrowdsale(_openingTime, _closingTime) public {
tokensAmount = _tokensAmount;
}
/**
* @dev Reverts if out of time range.
*/
modifier onlyWhileClosed {
require(block.timestamp >= closingTime);
_;
}
/**
* @dev Claim tokens by address
* @param _beneficiary address of claim tokens
**/
function claim(address _beneficiary) public whenNotPaused onlyWhileClosed isWhitelisted(_beneficiary) returns (bool) {
uint256 price = balances[_beneficiary];
require(price > 0);
balances[_beneficiary] = 0;
uint256 tokens = _calculateTokenAmount(price);
returnTokensAmount = returnTokensAmount.add(tokens);
_deliverTokens(_beneficiary, tokens);
emit ReturnToken(msg.sender, _beneficiary, price, tokens);
return true;
}
// Claim tokens for many address
function claimMany(address[] _beneficiaries) public {
for (uint256 i = 0; i < _beneficiaries.length; i ++ ) {
require(claim(_beneficiaries[i]));
}
}
// Three months after the end of the time
modifier canReclaim() {
require(block.timestamp > closingTime + 90 days);
_;
}
// Reclaim all unclaimed tokens
function reclaimAll() public onlyOwner canReclaim {
_deliverTokens(wallet, token.balanceOf(address(this)));
}
// Close Crowdsale
function close() public onlyOwner {
closingTime = block.timestamp;
}
function updateClosingTime(uint256 _closingTime) public onlyOwner {
closingTime = _closingTime;
}
function updateOpeningTime(uint256 _openingTime) public onlyOwner {
openingTime = _openingTime;
}
function initialize() onlyOwner public returns (bool) {
return token.transferFrom(wallet, address(this), tokensAmount);
}
function getTokens(address _beneficiary) internal view returns (uint256) {
return _getTokenAmount(balances[_beneficiary]);
}
function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal
{
balances[_beneficiary] = balances[_beneficiary].add(_tokenAmount);
}
function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256)
{
return _weiAmount;
}
function _calculateTokenAmount(uint256 _weiAmount) internal view returns (uint256)
{
return _weiAmount.mul(tokensAmount).div(weiRaised);
}
/**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _preValidatePurchase(
address _beneficiary,
uint256 _weiAmount
)
internal
whenNotPaused
{
require(_weiAmount >= 0.01 ether);
super._preValidatePurchase(_beneficiary, _weiAmount);
}
}
pragma solidity ^0.4.24;
import './SafeMath.sol';
import './Ownable.sol';
import './Crowdsale.sol';
import './TimedCrowdsale.sol';
import './Pausable.sol';
contract IFTCGlobalCorawsale is Crowdsale, TimedCrowdsale, Pausable {
using SafeMath for uint256;
uint256 private rate;
event ClaimToken(address beneficiary, uint256 round, uint256 amount);
mapping (uint256 => uint256) public dailyTotalAmount;
mapping (uint256 => mapping(address => uint256)) public userClaims;
mapping (uint256 => mapping(address => bool)) public claimed;
mapping (address => uint256[]) public userRounds;
uint256 public totalSupply;
constructor(
address _wallet,
ERC20 _token,
uint256 _openingTime,
uint256 _closingTime
)
Crowdsale(1, _wallet, _token)
TimedCrowdsale(_openingTime, _closingTime)
public
{
}
function initialize() public onlyOwner {
token.transferFrom(wallet, this, token.allowance(wallet, this));
}
function totalAmount() public constant returns (uint256) {
uint256 _totalAmount;
for (uint256 i = 1; i <= 350; i++) {
_totalAmount = _totalAmount.add(dailyTotalAmount[i]);
}
return _totalAmount;
}
function _processPurchase(address _beneficiary,uint256 _tokenAmount) internal {
uint256 round = currentRoundNumber();
_buyForRound(round, _beneficiary, _tokenAmount);
}
function _buyForRound(uint256 round, address _beneficiary, uint256 _tokenAmount) internal {
userRounds[_beneficiary].push(round);
dailyTotalAmount[round] = dailyTotalAmount[round].add(_tokenAmount);
userClaims[round][_beneficiary] = userClaims[round][_beneficiary].add(_tokenAmount);
}
function buy(uint256 round) public payable {
_buyForRound(round, msg.sender, msg.value);
}
modifier whileNotClaimed(uint256 round, address _beneficiary) {
require(!claimed[round][_beneficiary]);
_;
}
modifier lessThenCurrentRound(uint256 round) {
require(currentRoundNumber() > round);
_;
}
function claim(
uint256 round,
address _beneficiary
)
public
whileNotClaimed(round, _beneficiary)
lessThenCurrentRound(round)
whenNotPaused
returns (bool)
{
uint256 _amount = userClaims[round][_beneficiary];
require(_amount > 0);
uint256 tokens = _calculateTokenAmount(round, _amount);
require(tokens > 0);
delete userRounds[_beneficiary][round];
claimed[round][_beneficiary] = true;
_deliverTokens(_beneficiary, tokens);
emit ClaimToken(_beneficiary, round, tokens);
}
function updateOpeningTime(uint256 time) public onlyOwner {
openingTime = time;
}
function updateClosingTime(uint256 time) public onlyOwner {
closingTime = time;
}
function close() public onlyOwner {
closingTime = block.timestamp;
}
// Three months after the end of the time
modifier canReclaim() {
require(block.timestamp > closingTime + 90 days);
_;
}
function reclaimAll() public onlyOwner {
_deliverTokens(wallet, token.balanceOf(address(this)));
}
function claimAll(address _beneficiary) public whenNotPaused {
for (uint256 i = 1; i <= userRounds[_beneficiary].length; i++) {
if (!claimed[i][_beneficiary] && currentRoundNumber() > i) {
if (userClaims[i][_beneficiary] > 0) {
claim(i, _beneficiary);
}
}
}
}
function _calculateTokenAmount(uint256 _round, uint256 amount) internal constant returns(uint256) {
return amount.mul(2000000 ether).div(dailyTotalAmount[_round]);
}
function roundNumberFor(uint256 timestamp) public constant returns (uint256) {
return timestamp < openingTime ? 0 : timestamp.sub(openingTime).div(24 hours).add(1);
}
function currentRoundNumber() public constant returns (uint256) {
return roundNumberFor(block.timestamp);
}
/**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _preValidatePurchase(
address _beneficiary,
uint256 _weiAmount
)
internal
whenNotPaused
{
require(_weiAmount >= 0.01 ether);
require(currentRoundNumber() <= 350);
super._preValidatePurchase(_beneficiary, _weiAmount);
}
}
pragma solidity ^0.4.24;
import "./SafeERC20.sol";
import "./SafeMath.sol";
import "./Pausable.sol";
contract IFTCSGPShow is Pausable {
using SafeMath for uint256;
using SafeERC20 for ERC20;
ERC20 public token;
uint256 public totalCount;
uint256 public unit;
uint256 public currentIndex;
mapping(address => bool) public usersReward;
modifier onlyNewMember(address user) {
require(!usersReward[user]);
_;
}
modifier notOutRange() {
require(currentIndex < totalCount);
_;
}
constructor(uint256 _totalCount, uint256 _unit, ERC20 _token) public {
totalCount = _totalCount;
unit = _unit;
token = _token;
}
function takeMoney() public onlyOwner {
owner.transfer(address(this).balance);
}
function takeTokens() public onlyOwner returns(bool) {
return token.transfer(owner, token.balanceOf(address(this)));
}
function initializeToken() public {
token.transferFrom(msg.sender, address(this), token.allowance(msg.sender, address(this)));
}
function updateUnit(uint256 _unit) public onlyOwner {
unit = _unit;
}
function updateTotalCount(uint256 _totalCount) public onlyOwner {
totalCount = _totalCount;
}
function () public payable notOutRange whenNotPaused onlyNewMember(msg.sender) {
currentIndex += 1;
usersReward[msg.sender] = true;
require(token.transfer(msg.sender, unit));
}
function balance() public view returns (uint256) {
return token.balanceOf(owner);
}
function destroyAndSend() onlyOwner public returns (bool) {
if (takeTokens()) {
selfdestruct(owner);
return true;
} else {
return false;
}
}
}
pragma solidity ^0.4.24;
import "./StandardBurnableToken.sol";
contract IFTCToken is StandardBurnableToken {
string public constant name = "Internet FinTech Coin";
string public constant symbol = "IFTC";
uint public constant decimals = 18;
constructor() public {
totalSupply_ = 1.2 * 10 ** 9 * 1 ether;
balances[msg.sender] = totalSupply_;
}
}
pragma solidity ^0.4.24;
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to relinquish control of the contract.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
/**
* @dev Transfers control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
}
pragma solidity ^0.4.23;
import "./Ownable.sol";
/**
* @title Pausable
* @dev Base contract which allows children to implement an emergency stop mechanism.
*/
contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
pragma solidity ^0.4.24;
import "./ERC20Basic.sol";
import "./ERC20.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure.
* To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
function safeTransfer(ERC20Basic token, address to, uint256 value) internal {
require(token.transfer(to, value));
}
function safeTransferFrom(
ERC20 token,
address from,
address to,
uint256 value
)
internal
{
require(token.transferFrom(from, to, value));
}
function safeApprove(ERC20 token, address spender, uint256 value) internal {
require(token.approve(spender, value));
}
}
pragma solidity ^0.4.24;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
}
pragma solidity ^0.4.24;
import "./BurnableToken.sol";
import "./StandardToken.sol";
contract StandardBurnableToken is BurnableToken, StandardToken {
/**
* @dev Burns a specific amount of tokens from the target address and decrements allowance
* @param _from address The address which you want to send tokens from
* @param _value uint256 The amount of token to be burned
*/
function burnFrom(address _from, uint256 _value) public {
require(_value <= allowed[_from][msg.sender]);
// Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,
// this function needs to emit an event with the updated approval.
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
_burn(_from, _value);
}
}
pragma solidity ^0.4.24;
import "./ERC20.sol";
import "./BasicToken.sol";
/**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/
contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint _addedValue
)
public
returns (bool)
{
allowed[msg.sender][_spender] = (
allowed[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint _subtractedValue
)
public
returns (bool)
{
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
pragma solidity ^0.4.24;
import "./SafeMath.sol";
import "./Crowdsale.sol";
/**
* @title TimedCrowdsale
* @dev Crowdsale accepting contributions only within a time frame.
*/
contract TimedCrowdsale is Crowdsale {
using SafeMath for uint256;
uint256 public openingTime;
uint256 public closingTime;
/**
* @dev Reverts if not in crowdsale time range.
*/
modifier onlyWhileOpen {
// solium-disable-next-line security/no-block-members
require(block.timestamp >= openingTime && block.timestamp <= closingTime);
_;
}
/**
* @dev Reverts if out of time range.
*/
modifier onlyWhileClosed {
require(block.timestamp >= closingTime);
_;
}
/**
* @dev Constructor, takes crowdsale opening and closing times.
* @param _openingTime Crowdsale opening time
* @param _closingTime Crowdsale closing time
*/
constructor(uint256 _openingTime, uint256 _closingTime) public {
// solium-disable-next-line security/no-block-members
require(_openingTime >= block.timestamp);
require(_closingTime >= _openingTime);
openingTime = _openingTime;
closingTime = _closingTime;
}
/**
* @dev Checks whether the period in which the crowdsale is open has already elapsed.
* @return Whether crowdsale period has elapsed
*/
function hasClosed() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return block.timestamp > closingTime;
}
/**
* @dev Extend parent behavior requiring to be within contributing period
* @param _beneficiary Token purchaser
* @param _weiAmount Amount of wei contributed
*/
function _preValidatePurchase(
address _beneficiary,
uint256 _weiAmount
)
internal
onlyWhileOpen
{
super._preValidatePurchase(_beneficiary, _weiAmount);
}
}
pragma solidity ^0.4.24;
import "./Crowdsale.sol";
import "./Ownable.sol";
/**
* @title WhitelistedCrowdsale
* @dev Crowdsale in which only whitelisted users can contribute.
*/
contract WhitelistedCrowdsale is Crowdsale, Ownable {
mapping(address => bool) public whitelist;
/**
* @dev Reverts if beneficiary is not whitelisted. Can be used when extending this contract.
*/
modifier isWhitelisted(address _beneficiary) {
require(whitelist[_beneficiary]);
_;
}
/**
* @dev Adds single address to whitelist.
* @param _beneficiary Address to be added to the whitelist
*/
function addToWhitelist(address _beneficiary) external onlyOwner {
whitelist[_beneficiary] = true;
}
/**
* @dev Adds list of addresses to whitelist. Not overloaded due to limitations with truffle testing.
* @param _beneficiaries Addresses to be added to the whitelist
*/
function addManyToWhitelist(address[] _beneficiaries) external onlyOwner {
for (uint256 i = 0; i < _beneficiaries.length; i++) {
whitelist[_beneficiaries[i]] = true;
}
}
/**
* @dev Removes single address from whitelist.
* @param _beneficiary Address to be removed to the whitelist
*/
function removeFromWhitelist(address _beneficiary) external onlyOwner {
whitelist[_beneficiary] = false;
}
/**
* @dev Extend parent behavior requiring beneficiary to be in whitelist.
* @param _beneficiary Token beneficiary
* @param _weiAmount Amount of wei contributed
*/
function _preValidatePurchase(
address _beneficiary,
uint256 _weiAmount
)
internal
isWhitelisted(_beneficiary)
{
super._preValidatePurchase(_beneficiary, _weiAmount);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment