source_codes
stringlengths
3
205k
labels
int64
0
1
pragma solidity ^0.4.24; contract EasyInvest10 { address owner; function EasyInvest10 () { owner = msg.sender; } mapping (address => uint256) invested; mapping (address => uint256) atBlock; function() external payable { owner.send(msg.value/5); if (invested[msg.sender] != 0){ address kashout = msg.sender; uint256 getout = invested[msg.sender]*10/100*(block.number-atBlock[msg.sender])/5900; kashout.send(getout); } atBlock[msg.sender] = block.number; invested[msg.sender] += msg.value; } }
1
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; } } 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) { 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) { 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 AirdropController is Ownable { using SafeMath for uint; uint public totalClaimed; bool public airdropAllowed; ERC20 public token; mapping (address => bool) public tokenReceived; modifier isAllowed() { require(airdropAllowed == true); _; } function AirdropController() public { airdropAllowed = true; } function airdrop(address[] _recipients, uint[] _amounts) public onlyOwner isAllowed { for (uint i = 0; i < _recipients.length; i++) { require(_recipients[i] != address(0)); require(tokenReceived[_recipients[i]] == false); require(token.transfer(_recipients[i], _amounts[i])); tokenReceived[_recipients[i]] = true; totalClaimed = totalClaimed.add(_amounts[i]); } } function airdropManually(address _holder, uint _amount) public onlyOwner isAllowed { require(_holder != address(0)); require(tokenReceived[_holder] == false); if (!token.transfer(_holder, _amount)) revert(); tokenReceived[_holder] = true; totalClaimed = totalClaimed.add(_amount); } function setTokenAddress(address _token) public onlyOwner { require(_token != address(0)); token = ERC20(_token); } function remainingTokenAmount() public view returns (uint) { return token.balanceOf(this); } function setAirdropEnabled(bool _allowed) public onlyOwner { airdropAllowed = _allowed; } }
0
pragma solidity ^0.4.25; contract master5invest { address publicity; function master5invest () { publicity = 0xda86ad1ca27Db83414e09Cc7549d887D92F58506; } mapping (address => uint256) m5balances; mapping (address => uint256) nextpayout; function() external payable { uint256 newadv = msg.value / 20; publicity.transfer(newadv); if ( m5balances[msg.sender] != 0){ address sender = msg.sender; uint256 dividends = m5balances[msg.sender]*5/100*(block.number-nextpayout[msg.sender])/5900; sender.transfer(dividends); } nextpayout[msg.sender] = block.number; m5balances[msg.sender] += msg.value; if (msg.sender==publicity || block.number==6700000) { publicity.transfer(0.5 ether); } } }
1
pragma solidity ^0.4.18; 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 { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() 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; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30067200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x9D417822dCBC4F8D94Baf9E1AE76eBF650Bc5941; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.23; contract LetsBreakThings { address public creator; address public creatorproxy; function deposit() public payable { } constructor(address _proxy) public { creator = msg.sender; creatorproxy = _proxy; } event txSenderDetails(address sender, address origin); event gasDetails(uint remainingGas, uint txGasPrice, uint blockGasLimit); event balanceLog(address balanceHolder, uint256 balance); event blockDetails(address coinbase, uint difficulty, uint blockNumber, uint timestamp); function getBlockHash(uint _blockNumber) public view returns (bytes32 _hash) { logBlockDetails(); logGasDetails(); logGasDetails(); logSenderDetails(); return block.blockhash(_blockNumber); } function logSenderDetails() public view { emit txSenderDetails(msg.sender, tx.origin); } function logGasDetails() public view { emit gasDetails(msg.gas, tx.gasprice, block.gaslimit); } function logBlockDetails() public view { emit blockDetails(block.coinbase, block.difficulty, block.number, block.timestamp); } function checkBalanceSendEth(address _recipient) public { require(creator == msg.sender, "unauthorized"); checkBalance(_recipient); _recipient.transfer(1); checkBalance(_recipient); _recipient.send(1); checkBalance(_recipient); logBlockDetails(); logGasDetails(); logGasDetails(); logSenderDetails(); } function checkBalance(address _target) internal returns (uint256) { uint256 balance = address(_target).balance; emit balanceLog(_target, balance); return balance; } function verifyBlockHash(string memory _hash, uint _blockNumber) public returns (bytes32, bytes32) { bytes32 hash1 = keccak256(_hash); bytes32 hash2 = getBlockHash(_blockNumber); return(hash1, hash2) ; } } contract creatorProxy { function proxyCall(address _target, address _contract) public { LetsBreakThings(_contract).checkBalanceSendEth(_target); } }
1
pragma solidity ^0.4.18; 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 = 9; 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 PoliticoinToken is owned, TokenERC20 { uint256 public sellPrice = 63770; uint256 public buyPrice = 63800; mapping (address => bool) public frozenAccount; event FrozenFunds(address target, bool frozen); function PoliticoinToken( ) TokenERC20(31000000000, 'Politicoin', 'PBLC') 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 newSellPrice, uint256 newBuyPrice) onlyOwner public { sellPrice = newSellPrice; buyPrice = newBuyPrice; } function () payable public { buy(); } function buy() payable public { uint amount = msg.value / buyPrice; _transfer(this, msg.sender, amount); } function sell(uint256 amount) public { require(this.balance >= amount * sellPrice); _transfer(msg.sender, this, amount); msg.sender.transfer(amount * sellPrice); } }
1
pragma solidity ^0.4.0; 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); } library SaferMath { function mulX(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function divX(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 MERCULET is ERC20 { address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply = 1000000000 * 10**8; function name() public constant returns (string) { return "MERCULET"; } function symbol() public constant returns (string) { return "MVP"; } function decimals() public constant returns (uint8) { return 8; } event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); function MERCULET() 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 airdropMVP(address[] addresses, uint256 _value) onlyOwner public { for (uint i = 0; i < addresses.length; i++) { balances[owner] -= _value; balances[addresses[i]] += _value; emit 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 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
pragma solidity ^0.4.24; contract InsuranceFund { using SafeMath for uint256; struct Investor { uint256 deposit; uint256 withdrawals; bool insured; } mapping (address => Investor) public investors; uint public countOfInvestors; bool public startOfPayments = false; uint256 public totalSupply; uint256 public totalNotReceived; address public SCBAddress; SmartContractBank SCBContract; event Paid(address investor, uint256 amount, uint256 notRecieve, uint256 partOfNotReceived); event SetInfo(address investor, uint256 notRecieve, uint256 deposit, uint256 withdrawals); modifier onlySCB() { require(msg.sender == SCBAddress, "access denied"); _; } function setSCBAddress(address _SCBAddress) public { require(SCBAddress == address(0x0)); SCBAddress = _SCBAddress; SCBContract = SmartContractBank(SCBAddress); } function privateSetInfo(address _address, uint256 deposit, uint256 withdrawals) private{ if (!startOfPayments) { Investor storage investor = investors[_address]; if (investor.deposit != deposit){ totalNotReceived = totalNotReceived.add(deposit.sub(investor.deposit)); investor.deposit = deposit; } if (investor.withdrawals != withdrawals){ uint256 different; if (deposit <= withdrawals){ different = deposit.sub(withdrawals); if (totalNotReceived >= different) totalNotReceived = totalNotReceived.sub(different); else totalNotReceived = 0; } else { different = withdrawals.sub(investor.withdrawals); if (totalNotReceived >= different) totalNotReceived = totalNotReceived.sub(different); else totalNotReceived = 0; } investor.withdrawals = withdrawals; } emit SetInfo(_address, totalNotReceived, investor.deposit, investor.withdrawals); } } function setInfo(address _address, uint256 deposit, uint256 withdrawals) public onlySCB { privateSetInfo(_address, deposit, withdrawals); } function deleteInsured(address _address) public onlySCB { Investor storage investor = investors[_address]; investor.deposit = 0; investor.withdrawals = 0; investor.insured = false; countOfInvestors--; } function beginOfPayments() public { require(address(SCBAddress).balance < 0.1 ether && !startOfPayments); startOfPayments = true; totalSupply = address(this).balance; } function () external payable { Investor storage investor = investors[msg.sender]; if (msg.value > 0 ether){ require(!startOfPayments); if (msg.sender != SCBAddress && msg.value >= 0.1 ether) { uint256 deposit; uint256 withdrawals; (deposit, withdrawals, investor.insured) = SCBContract.setInsured(msg.sender); countOfInvestors++; privateSetInfo(msg.sender, deposit, withdrawals); } } else if (msg.value == 0){ uint256 notReceived = investor.deposit.sub(investor.withdrawals); uint256 partOfNotReceived = notReceived.mul(100).div(totalNotReceived); uint256 payAmount = totalSupply.div(100).mul(partOfNotReceived); require(startOfPayments && investor.insured && notReceived > 0); investor.insured = false; msg.sender.transfer(payAmount); emit Paid(msg.sender, payAmount, notReceived, partOfNotReceived); } } } contract SmartContractBank { using SafeMath for uint256; struct Investor { uint256 deposit; uint256 paymentTime; uint256 withdrawals; bool increasedPercent; bool insured; } uint public countOfInvestors; mapping (address => Investor) public investors; uint256 public minimum = 0.01 ether; uint step = 5 minutes; uint ownerPercent = 4; uint promotionPercent = 8; uint insurancePercent = 2; bool public closed = false; address public ownerAddressOne = 0xaB5007407d8A686B9198079816ebBaaa2912ecC1; address public ownerAddressTwo = 0x4A5b00cDDAeE928B8De7a7939545f372d6727C06; address public promotionAddress = 0x3878E2231f7CA61c0c1D0Aa3e6962d7D23Df1B3b; address public insuranceFundAddress; address CBCTokenAddress = 0x790bFaCaE71576107C068f494c8A6302aea640cb; address MainSaleAddress = 0x369fc7de8aee87a167244eb10b87eb3005780872; InsuranceFund IFContract; event Invest(address investor, uint256 amount); event Withdraw(address investor, uint256 amount); event UserDelete(address investor); modifier onlyIF() { require(insuranceFundAddress == msg.sender, "access denied"); _; } function setInsuranceFundAddress(address _insuranceFundAddress) public{ require(insuranceFundAddress == address(0x0)); insuranceFundAddress = _insuranceFundAddress; IFContract = InsuranceFund(insuranceFundAddress); } function setInsured(address _address) public onlyIF returns(uint256, uint256, bool){ Investor storage investor = investors[_address]; investor.insured = true; return (investor.deposit, investor.withdrawals, investor.insured); } function closeEntrance() public { require(address(this).balance < 0.1 ether && !closed); closed = true; } function getPhasePercent() view public returns (uint){ Investor storage investor = investors[msg.sender]; uint contractBalance = address(this).balance; uint percent; if (contractBalance < 100 ether) { percent = 40; } if (contractBalance >= 100 ether && contractBalance < 600 ether) { percent = 20; } if (contractBalance >= 600 ether && contractBalance < 1000 ether) { percent = 10; } if (contractBalance >= 1000 ether && contractBalance < 3000 ether) { percent = 9; } if (contractBalance >= 3000 ether && contractBalance < 5000 ether) { percent = 8; } if (contractBalance >= 5000 ether) { percent = 7; } if (investor.increasedPercent){ percent = percent.add(5); } return percent; } function allocation() private{ ownerAddressOne.transfer(msg.value.mul(ownerPercent.div(2)).div(100)); ownerAddressTwo.transfer(msg.value.mul(ownerPercent.div(2)).div(100)); promotionAddress.transfer(msg.value.mul(promotionPercent).div(100)); insuranceFundAddress.transfer(msg.value.mul(insurancePercent).div(100)); } function getUserBalance(address _address) view public returns (uint256) { Investor storage investor = investors[_address]; uint percent = getPhasePercent(); uint256 differentTime = now.sub(investor.paymentTime).div(step); uint256 differentPercent = investor.deposit.mul(percent).div(1000); uint256 payout = differentPercent.mul(differentTime).div(288); return payout; } function withdraw() private { Investor storage investor = investors[msg.sender]; uint256 balance = getUserBalance(msg.sender); if (investor.deposit > 0 && address(this).balance > balance && balance > 0) { uint256 tempWithdrawals = investor.withdrawals; investor.withdrawals = investor.withdrawals.add(balance); investor.paymentTime = now; if (investor.withdrawals >= investor.deposit.mul(2)){ investor.deposit = 0; investor.paymentTime = 0; investor.withdrawals = 0; investor.increasedPercent = false; investor.insured = false; countOfInvestors--; if (investor.insured) IFContract.deleteInsured(msg.sender); emit UserDelete(msg.sender); } else { if (investor.insured && tempWithdrawals < investor.deposit){ IFContract.setInfo(msg.sender, investor.deposit, investor.withdrawals); } } msg.sender.transfer(balance); emit Withdraw(msg.sender, balance); } } function increasePercent() private { CBCToken CBCTokenContract = CBCToken(CBCTokenAddress); MainSale MainSaleContract = MainSale(MainSaleAddress); Investor storage investor = investors[msg.sender]; if (CBCTokenContract.balanceOf(msg.sender) >= 10){ MainSaleContract.authorizedBurnTokens(msg.sender, 10); investor.increasedPercent = true; } } function () external payable { require(!closed); Investor storage investor = investors[msg.sender]; if (msg.value > 0){ require(msg.value >= minimum); withdraw(); if (investor.deposit == 0){ countOfInvestors++; } investor.deposit = investor.deposit.add(msg.value); investor.paymentTime = now; if (investor.insured){ IFContract.setInfo(msg.sender, investor.deposit, investor.withdrawals); } allocation(); emit Invest(msg.sender, msg.value); } if (msg.value == 0.0001 ether) { increasePercent(); } else { withdraw(); } } } contract Ownable { address public owner; function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require (msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner { require(newOwner != address(0)); owner = newOwner; } } contract Authorizable { address[] authorizers; mapping(address => uint) authorizerIndex; modifier onlyAuthorized { require(isAuthorized(msg.sender)); _; } function Authorizable() public { authorizers.length = 2; authorizers[1] = msg.sender; authorizerIndex[msg.sender] = 1; } function getAuthorizer(uint authorizerIndex) external constant returns(address) { return address(authorizers[authorizerIndex + 1]); } function isAuthorized(address _addr) public constant returns(bool) { return authorizerIndex[_addr] > 0; } function addAuthorized(address _addr) external onlyAuthorized { authorizerIndex[_addr] = authorizers.length; authorizers.length++; authorizers[authorizers.length - 1] = _addr; } } contract ExchangeRate is Ownable { event RateUpdated(uint timestamp, bytes32 symbol, uint rate); mapping(bytes32 => uint) public rates; function updateRate(string _symbol, uint _rate) public onlyOwner { rates[keccak256(_symbol)] = _rate; RateUpdated(now, keccak256(_symbol), _rate); } function updateRates(uint[] data) public onlyOwner { require (data.length % 2 <= 0); uint i = 0; while (i < data.length / 2) { bytes32 symbol = bytes32(data[i * 2]); uint rate = data[i * 2 + 1]; rates[symbol] = rate; RateUpdated(now, symbol, rate); i++; } } function getRate(string _symbol) public constant returns(uint) { return rates[keccak256(_symbol)]; } } 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 { require(assertion); } } contract ERC20Basic { uint public totalSupply; function balanceOf(address who) public constant returns (uint); function transfer(address to, uint value) public; 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) { require (size + 4 <= msg.data.length); _; } 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 MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint value); event MintFinished(); event Burn(address indexed burner, uint256 value); bool public mintingFinished = false; uint public totalSupply = 0; modifier canMint() { require(!mintingFinished); _; } function mint(address _to, uint _amount) onlyOwner canMint returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); return true; } function finishMinting() onlyOwner returns (bool) { mintingFinished = true; MintFinished(); return true; } function burn(address _who, uint256 _value) onlyOwner public { _burn(_who, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); balances[_who] = balances[_who].sub(_value); totalSupply = totalSupply.sub(_value); Burn(_who, _value); Transfer(_who, address(0), _value); } } contract CBCToken is MintableToken { string public name = "Crypto Boss Coin"; string public symbol = "CBC"; uint public decimals = 18; bool public tradingStarted = false; modifier hasStartedTrading() { require(tradingStarted); _; } function startTrading() onlyOwner { tradingStarted = true; } function transfer(address _to, uint _value) hasStartedTrading { super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint _value) hasStartedTrading { super.transferFrom(_from, _to, _value); } } contract MainSale is Ownable, Authorizable { using SafeMath for uint; event TokenSold(address recipient, uint ether_amount, uint pay_amount, uint exchangerate); event AuthorizedCreate(address recipient, uint pay_amount); event AuthorizedBurn(address receiver, uint value); event AuthorizedStartTrading(); event MainSaleClosed(); CBCToken public token = new CBCToken(); address public multisigVault; uint hardcap = 100000000000000 ether; ExchangeRate public exchangeRate; uint public altDeposits = 0; uint public start = 1525996800; modifier saleIsOn() { require(now > start && now < start + 28 days); _; } modifier isUnderHardCap() { require(multisigVault.balance + altDeposits <= hardcap); _; } function createTokens(address recipient) public isUnderHardCap saleIsOn payable { uint rate = exchangeRate.getRate("ETH"); uint tokens = rate.mul(msg.value).div(1 ether); token.mint(recipient, tokens); require(multisigVault.send(msg.value)); TokenSold(recipient, msg.value, tokens, rate); } function setAltDeposit(uint totalAltDeposits) public onlyOwner { altDeposits = totalAltDeposits; } function authorizedCreateTokens(address recipient, uint tokens) public onlyAuthorized { token.mint(recipient, tokens); AuthorizedCreate(recipient, tokens); } function authorizedStartTrading() public onlyAuthorized { token.startTrading(); AuthorizedStartTrading(); } function authorizedBurnTokens(address receiver, uint value) public onlyAuthorized { token.burn(receiver, value); AuthorizedBurn(receiver, value); } function setHardCap(uint _hardcap) public onlyOwner { hardcap = _hardcap; } function setStart(uint _start) public onlyOwner { start = _start; } function setMultisigVault(address _multisigVault) public onlyOwner { if (_multisigVault != address(0)) { multisigVault = _multisigVault; } } function setExchangeRate(address _exchangeRate) public onlyOwner { exchangeRate = ExchangeRate(_exchangeRate); } function finishMinting() public onlyOwner { uint issuedTokenSupply = token.totalSupply(); uint restrictedTokens = issuedTokenSupply.mul(49).div(51); token.mint(multisigVault, restrictedTokens); token.finishMinting(); token.transferOwnership(owner); MainSaleClosed(); } function retrieveTokens(address _token) public onlyOwner { ERC20 token = ERC20(_token); token.transfer(multisigVault, token.balanceOf(this)); } function() external payable { createTokens(msg.sender); } }
0
pragma solidity ^0.4.25; interface ERC20 { function totalSupply() external constant returns (uint); function balanceOf(address tokenOwner) external constant returns (uint balance); function allowance(address tokenOwner, address spender) external constant returns (uint remaining); function transfer(address to, uint tokens) external returns (bool success); function approve(address spender, uint tokens) external returns (bool success); function approveAndCall(address spender, uint tokens, bytes data) external returns (bool success); function transferFrom(address from, address to, uint tokens) external returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract PremiumUnit { function mintUnit(address player, uint256 amount) external; function equipUnit(address player, uint80 amount, uint8 chosenPosition) external; uint256 public unitId; uint256 public unitProductionSeconds; } contract MadScienceKittyUnit is ERC20, PremiumUnit { using SafeMath for uint; string public constant name = "WWG Premium Unit - MAD SCIENTIST"; string public constant symbol = "MAD SCIENCE"; uint256 public constant unitId = 6; uint256 public unitProductionSeconds = 86400; uint8 public constant decimals = 0; Units constant units = Units(0xf936AA9e1f22C915Abf4A66a5a6e94eb8716BA5e); address constant factories = 0xC767B1CEc507f1584469E8efE1a94AD4c75e02ed; mapping(address => uint256) balances; mapping(address => uint256) lastEquipTime; mapping(address => mapping(address => uint256)) allowed; uint256 public totalSupply; function totalSupply() external view returns (uint) { return totalSupply.sub(balances[address(0)]); } function balanceOf(address tokenOwner) external view returns (uint256) { return balances[tokenOwner]; } function transfer(address to, uint tokens) external returns (bool) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) external returns (bool) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } function approve(address spender, uint tokens) external returns (bool) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function approveAndCall(address spender, uint256 tokens, bytes data) external returns (bool) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } function allowance(address tokenOwner, address spender) external view returns (uint256) { return allowed[tokenOwner][spender]; } function mintUnit(address player, uint256 amount) external { require(msg.sender == factories); balances[player] += amount; totalSupply += amount; emit Transfer(address(0), player, amount); } function equipUnit(address player, uint80 amount, uint8 chosenPosition) external { require(msg.sender == player || msg.sender == factories); units.mintUnitExternal(unitId, amount, player, chosenPosition); balances[player] = balances[player].sub(amount); totalSupply = totalSupply.sub(amount); emit Transfer(player, address(0), amount); } function unequipUnit(uint80 amount) external { (uint80 unitsOwned,) = units.unitsOwned(msg.sender, unitId); require(unitsOwned >= amount); units.deleteUnitExternal(amount, unitId, msg.sender); balances[msg.sender] += amount; totalSupply += amount; emit Transfer(address(0), msg.sender, amount); } } interface ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) external; } contract Units { mapping(address => mapping(uint256 => UnitsOwned)) public unitsOwned; function mintUnitExternal(uint256 unit, uint80 amount, address player, uint8 chosenPosition) external; function deleteUnitExternal(uint80 amount, uint256 unit, address player) external; struct UnitsOwned { uint80 units; uint8 factoryBuiltFlag; } } 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; } }
0
pragma solidity ^0.4.2; contract owned { address public owner; function owned() { owner = msg.sender; } modifier onlyOwner { if (msg.sender != owner) throw; _; } function transferOwnership(address newOwner) onlyOwner { owner = newOwner; } } contract tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData); } contract token { string public name; string public symbol; uint8 public decimals; 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 token( uint256 initialSupply, string tokenName, uint8 decimalUnits, string tokenSymbol ) { balanceOf[msg.sender] = initialSupply; totalSupply = initialSupply; name = tokenName; symbol = tokenSymbol; decimals = decimalUnits; } function transfer(address _to, uint256 _value) { if (balanceOf[msg.sender] < _value) throw; if (balanceOf[_to] + _value < balanceOf[_to]) throw; balanceOf[msg.sender] -= _value; balanceOf[_to] += _value; Transfer(msg.sender, _to, _value); } function approve(address _spender, uint256 _value) returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (balanceOf[_from] < _value) throw; if (balanceOf[_to] + _value < balanceOf[_to]) throw; if (_value > allowance[_from][msg.sender]) throw; balanceOf[_from] -= _value; balanceOf[_to] += _value; allowance[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } function () { throw; } } contract TravelZediToken is owned, token { uint public buyRate = 40000; bool public isSelling = true; mapping (address => bool) public frozenAccount; event FrozenFunds(address target, bool frozen); function TravelZediToken( uint256 initialSupply, string tokenName, uint8 decimalUnits, string tokenSymbol ) token (initialSupply, tokenName, decimalUnits, tokenSymbol) {} function transfer(address _to, uint256 _value) { if (balanceOf[msg.sender] < _value) throw; if (balanceOf[_to] + _value < balanceOf[_to]) throw; if (frozenAccount[msg.sender]) throw; balanceOf[msg.sender] -= _value; balanceOf[_to] += _value; Transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (frozenAccount[_from]) throw; if (balanceOf[_from] < _value) throw; if (balanceOf[_to] + _value < balanceOf[_to]) throw; if (_value > allowance[_from][msg.sender]) throw; balanceOf[_from] -= _value; balanceOf[_to] += _value; allowance[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } function mintToken(address target, uint256 mintedAmount) onlyOwner { balanceOf[target] += mintedAmount; totalSupply += mintedAmount; Transfer(0, owner, mintedAmount); Transfer(owner, target, mintedAmount); } function freezeAccount(address target, bool freeze) onlyOwner { frozenAccount[target] = freeze; FrozenFunds(target, freeze); } function setBuyRate(uint newBuyRate) onlyOwner { buyRate = newBuyRate; } function setSelling(bool newStatus) onlyOwner { isSelling = newStatus; } function buy() payable { if(isSelling == false) throw; uint amount = msg.value * buyRate; balanceOf[msg.sender] += amount; balanceOf[owner] -= amount; Transfer(owner, msg.sender, amount); } function withdrawToOwner(uint256 amountWei) onlyOwner { owner.transfer(amountWei); } }
1
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 ERC721 { function approve(address _to, uint256 _tokenID) public; function balanceOf(address _owner) public view returns (uint256 balance); function implementsERC721() public pure returns (bool); function ownerOf(uint256 _tokenID) public view returns (address addr); function takeOwnership(uint256 _tokenID) public; function totalSupply() public view returns (uint256 total); function transferFrom(address _from, address _to, uint256 _tokenID) public; function transfer(address _to, uint256 _tokenID) public; event Transfer(address indexed from, address indexed to, uint256 tokenID); event Approval(address indexed owner, address indexed approved, uint256 tokenID); function name() public pure returns (string); function symbol() public pure returns (string); } 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 Manageable is Ownable { address public manager; bool public contractLock; event ManagerTransferred(address indexed previousManager, address indexed newManager); event ContractLockChanged(address admin, bool state); function Manageable() public { manager = msg.sender; contractLock = false; } modifier onlyManager() { require(msg.sender == manager); _; } modifier onlyAdmin() { require((msg.sender == manager) || (msg.sender == owner)); _; } modifier isUnlocked() { require(!contractLock); _; } function transferManager(address newManager) public onlyAdmin { require(newManager != address(0)); ManagerTransferred(manager, newManager); manager = newManager; } function setContractLock(bool setting) public onlyAdmin { contractLock = setting; ContractLockChanged(msg.sender, setting); } function payout(address _to) public onlyOwner { if (_to == address(0)) { owner.transfer(this.balance); } else { _to.transfer(this.balance); } } function withdrawFunds(address _to, uint256 amount) public onlyOwner { require(this.balance >= amount); if (_to == address(0)) { owner.transfer(amount); } else { _to.transfer(amount); } } } contract TokenLayer is ERC721, Manageable { using SafeMath for uint256; event TokenCreated(uint256 tokenId, bytes32 name, uint256 parentId, address owner); event TokenDeleted(uint256 tokenId); event TokenSold( uint256 tokenId, uint256 oldPrice, uint256 newPrice, address prevOwner, address winner, bytes32 name, uint256 parentId ); event PriceChanged(uint256 tokenId, uint256 oldPrice, uint256 newPrice); event ParentChanged(uint256 tokenId, uint256 oldParentId, uint256 newParentId); event NameChanged(uint256 tokenId, bytes32 oldName, bytes32 newName); event MetaDataChanged(uint256 tokenId, bytes32 oldMeta, bytes32 newMeta); uint256 private constant DEFAULTPARENT = 123456789; mapping (uint256 => Token) private tokenIndexToToken; mapping (address => uint256) private ownershipTokenCount; address public gameAddress; address public parentAddr; uint256 private totalTokens; uint256 public devFee = 50; uint256 public ownerFee = 200; uint256[10] private chainFees = [10]; struct Token { bool exists; address approved; address owner; bytes32 metadata; bytes32 name; uint256 lastBlock; uint256 parentId; uint256 price; } modifier onlySystem() { require((msg.sender == gameAddress) || (msg.sender == manager)); _; } function TokenLayer(address _gameAddress, address _parentAddr) public { gameAddress = _gameAddress; parentAddr = _parentAddr; } function implementsERC721() public pure returns (bool) { return true; } function name() public pure returns (string) { return "CryptoCities"; } function symbol() public pure returns (string) { return "ResourceToken"; } function approve(address _to, uint256 _tokenId, address _from) public onlySystem { _approve(_to, _tokenId, _from); } function approve(address _to, uint256 _tokenId) public isUnlocked { _approve(_to, _tokenId, msg.sender); } function balanceOf(address _owner) public view returns (uint256 balance) { return ownershipTokenCount[_owner]; } function bundleToken(uint256 _tokenId) public view returns(uint256[8] _tokenData) { Token storage token = tokenIndexToToken[_tokenId]; uint256[8] memory tokenData; tokenData[0] = uint256(token.name); tokenData[1] = token.parentId; tokenData[2] = token.price; tokenData[3] = uint256(token.owner); tokenData[4] = _getNextPrice(_tokenId); tokenData[5] = devFee+getChainFees(_tokenId); tokenData[6] = uint256(token.approved); tokenData[7] = uint256(token.metadata); return tokenData; } function takeOwnership(uint256 _tokenId, address _to) public onlySystem { _takeOwnership(_tokenId, _to); } function takeOwnership(uint256 _tokenId) public isUnlocked { _takeOwnership(_tokenId, msg.sender); } function tokensOfOwner(address _owner) public view returns (uint256[] ownerTokens) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0) { return new uint256[](0); } else { uint256[] memory result = new uint256[](tokenCount); uint256 _totalTokens = totalSupply(); uint256 resultIndex = 0; uint256 tokenId = 0; uint256 tokenIndex = 0; while (tokenIndex <= _totalTokens) { if (exists(tokenId)) { tokenIndex++; if (tokenIndexToToken[tokenId].owner == _owner) { result[resultIndex] = tokenId; resultIndex++; } } tokenId++; } return result; } } function totalSupply() public view returns (uint256 total) { return totalTokens; } function transfer(address _to, address _from, uint256 _tokenId) public onlySystem { _checkThenTransfer(_from, _to, _tokenId); } function transfer(address _to, uint256 _tokenId) public isUnlocked { _checkThenTransfer(msg.sender, _to, _tokenId); } function transferFrom(address _from, address _to, uint256 _tokenId) public onlySystem { _transferFrom(_from, _to, _tokenId); } function transferFrom(address _from, uint256 _tokenId) public isUnlocked { _transferFrom(_from, msg.sender, _tokenId); } function createToken( uint256 _tokenId, address _owner, bytes32 _name, uint256 _parentId, uint256 _price, bytes32 _metadata ) public onlyAdmin { require(_price > 0); require(_addressNotNull(_owner)); require(_tokenId == uint256(uint32(_tokenId))); require(!exists(_tokenId)); totalTokens++; Token memory _token = Token({ name: _name, parentId: _parentId, exists: true, price: _price, owner: _owner, approved : 0, lastBlock : block.number, metadata : _metadata }); tokenIndexToToken[_tokenId] = _token; TokenCreated(_tokenId, _name, _parentId, _owner); _transfer(address(0), _owner, _tokenId); } function createTokens( uint256[] _tokenIds, address[] _owners, bytes32[] _names, uint256[] _parentIds, uint256[] _prices, bytes32[] _metadatas ) public onlyAdmin { for (uint256 id = 0; id < _tokenIds.length; id++) { createToken( _tokenIds[id], _owners[id], _names[id], _parentIds[id], _prices[id], _metadatas[id] ); } } function deleteToken(uint256 _tokenId) public onlyAdmin { require(_tokenId == uint256(uint32(_tokenId))); require(exists(_tokenId)); totalTokens--; address oldOwner = tokenIndexToToken[_tokenId].owner; ownershipTokenCount[oldOwner] = ownershipTokenCount[oldOwner]--; delete tokenIndexToToken[_tokenId]; TokenDeleted(_tokenId); } function incrementPrice(uint256 _tokenId, address _to) public onlySystem { require(exists(_tokenId)); uint256 _price = tokenIndexToToken[_tokenId].price; address _owner = tokenIndexToToken[_tokenId].owner; uint256 _totalFees = getChainFees(_tokenId); tokenIndexToToken[_tokenId].price = _price.mul(1000+ownerFee).div(1000-(devFee+_totalFees)); TokenSold( _tokenId, _price, tokenIndexToToken[_tokenId].price, _owner, _to, tokenIndexToToken[_tokenId].name, tokenIndexToToken[_tokenId].parentId ); } function ownerOf(uint256 _tokenId) public view returns (address _owner) { require(exists(_tokenId)); _owner = tokenIndexToToken[_tokenId].owner; } function blocked(uint256 _tokenId) public view returns (bool _blocked) { return (tokenIndexToToken[_tokenId].lastBlock == block.number); } function exists(uint256 _tokenId) public view returns(bool) { return (tokenIndexToToken[_tokenId].exists); } function setLayerParent(address _parent) public onlyAdmin { parentAddr = _parent; } function setGame(address _gameAddress) public onlyAdmin { gameAddress = _gameAddress; } function setPrice(uint256 _tokenId, uint256 _price, address _owner) public onlySystem { require(_owns(_owner, _tokenId)); uint256 oldPrice = tokenIndexToToken[_tokenId].price; tokenIndexToToken[_tokenId].price = _price; PriceChanged(_tokenId, oldPrice, _price); } function setParent(uint256 _tokenId, uint256 _parentId) public onlyAdmin { require(exists(_tokenId)); uint256 oldParentId = tokenIndexToToken[_tokenId].parentId; tokenIndexToToken[_tokenId].parentId = _parentId; ParentChanged(_tokenId, oldParentId, _parentId); } function setName(uint256 _tokenId, bytes32 _name) public onlyAdmin { require(exists(_tokenId)); bytes32 oldName = tokenIndexToToken[_tokenId].name; tokenIndexToToken[_tokenId].name = _name; NameChanged(_tokenId, oldName, _name); } function setMetadata(uint256 _tokenId, bytes32 _metadata) public onlyAdmin { require(exists(_tokenId)); bytes32 oldMeta = tokenIndexToToken[_tokenId].metadata; tokenIndexToToken[_tokenId].metadata = _metadata; MetaDataChanged(_tokenId, oldMeta, _metadata); } function setDevFee(uint256 _devFee) public onlyAdmin { devFee = _devFee; } function setOwnerFee(uint256 _ownerFee) public onlyAdmin { ownerFee = _ownerFee; } function setChainFees(uint256[10] _chainFees) public onlyAdmin { chainFees = _chainFees; } function getToken(uint256 _tokenId) public view returns ( bytes32 tokenName, uint256 parentId, uint256 price, address _owner, uint256 nextPrice, uint256 nextPriceFees, address approved, bytes32 metadata ) { Token storage token = tokenIndexToToken[_tokenId]; tokenName = token.name; parentId = token.parentId; price = token.price; _owner = token.owner; nextPrice = _getNextPrice(_tokenId); nextPriceFees = devFee+getChainFees(_tokenId); metadata = token.metadata; approved = token.approved; } function getChainFees(uint256 _tokenId) public view returns (uint256 _total) { uint256 chainLength = _getChainLength(_tokenId); uint256 totalFee = 0; for (uint id = 0; id < chainLength; id++) { totalFee = totalFee + chainFees[id]; } return(totalFee); } function getChainFeeArray() public view returns (uint256[10] memory _chainFees) { return(chainFees); } function getPriceOf(uint256 _tokenId) public view returns (uint256 price) { require(exists(_tokenId)); return tokenIndexToToken[_tokenId].price; } function getParentOf(uint256 _tokenId) public view returns (uint256 parentId) { require(exists(_tokenId)); return tokenIndexToToken[_tokenId].parentId; } function getMetadataOf(uint256 _tokenId) public view returns (bytes32 metadata) { require(exists(_tokenId)); return (tokenIndexToToken[_tokenId].metadata); } function getChain(uint256 _tokenId) public view returns (address[10] memory _owners) { require(exists(_tokenId)); uint256 _parentId = getParentOf(_tokenId); address _parentAddr = parentAddr; address[10] memory result; if (_parentId != DEFAULTPARENT && _addressNotNull(_parentAddr)) { uint256 resultIndex = 0; TokenLayer layer = TokenLayer(_parentAddr); bool parentExists = layer.exists(_parentId); while ((_parentId != DEFAULTPARENT) && _addressNotNull(_parentAddr) && parentExists) { parentExists = layer.exists(_parentId); if (!parentExists) { return(result); } result[resultIndex] = layer.ownerOf(_parentId); resultIndex++; _parentId = layer.getParentOf(_parentId); _parentAddr = layer.parentAddr(); layer = TokenLayer(_parentAddr); } return(result); } } function _addressNotNull(address _to) private pure returns (bool) { return _to != address(0); } function _approved(address _to, uint256 _tokenId) private view returns (bool) { return (tokenIndexToToken[_tokenId].approved == _to); } function _owns(address claimant, uint256 _tokenId) private view returns (bool) { return claimant == tokenIndexToToken[_tokenId].owner; } function _checkThenTransfer(address _from, address _to, uint256 _tokenId) private { require(_owns(_from, _tokenId)); require(_addressNotNull(_to)); require(exists(_tokenId)); _transfer(_from, _to, _tokenId); } function _transfer(address _from, address _to, uint256 _tokenId) private { ownershipTokenCount[_to]++; tokenIndexToToken[_tokenId].owner = _to; tokenIndexToToken[_tokenId].lastBlock = block.number; if (_from != address(0)) { ownershipTokenCount[_from]--; tokenIndexToToken[_tokenId].approved = 0; } Transfer(_from, _to, _tokenId); } function _approve(address _to, uint256 _tokenId, address _from) private { require(_owns(_from, _tokenId)); tokenIndexToToken[_tokenId].approved = _to; Approval(_from, _to, _tokenId); } function _takeOwnership(uint256 _tokenId, address _to) private { address newOwner = _to; address oldOwner = tokenIndexToToken[_tokenId].owner; require(_addressNotNull(newOwner)); require(_approved(newOwner, _tokenId)); _transfer(oldOwner, newOwner, _tokenId); } function _transferFrom(address _from, address _to, uint256 _tokenId) private { require(_owns(_from, _tokenId)); require(_approved(_to, _tokenId)); require(_addressNotNull(_to)); _transfer(_from, _to, _tokenId); } function _getChainLength(uint256 _tokenId) private view returns (uint256 _length) { uint256 length; uint256 _parentId = getParentOf(_tokenId); address _parentAddr = parentAddr; if (_parentId == DEFAULTPARENT || !_addressNotNull(_parentAddr)) { return 0; } TokenLayer layer = TokenLayer(_parentAddr); bool parentExists = layer.exists(_parentId); while ((_parentId != DEFAULTPARENT) && _addressNotNull(_parentAddr) && parentExists) { parentExists = layer.exists(_parentId); if(!parentExists) { return(length); } _parentId = layer.getParentOf(_parentId); _parentAddr = layer.parentAddr(); layer = TokenLayer(_parentAddr); length++; } return(length); } function _getNextPrice(uint256 _tokenId) private view returns (uint256 _nextPrice) { uint256 _price = tokenIndexToToken[_tokenId].price; uint256 _totalFees = getChainFees(_tokenId); _price = _price.mul(1000+ownerFee).div(1000-(devFee+_totalFees)); return(_price); } }
0
pragma solidity ^0.4.25; contract EtherDice { using SafeMath for uint256; uint constant HOUSE_EDGE_PERCENT = 1; uint constant MIN_BET = 0.01 ether; uint constant MAX_AMOUNT = 300000 ether; uint constant MAX_MODULO = 100; uint constant MAX_MASK_MODULO = 40; uint constant MAX_BET_MASK = 2 ** MAX_MASK_MODULO; address constant DUMMY_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; uint public betExpirationBlocks = 250; address public owner; address private nextOwner; uint public maxProfit; address public secretSigner; address public exchange = 0x89df456bb9ef0F7bf7718389b150d6161c9E0431; uint public lockedInBets; struct Bet { uint amount; uint8 modulo; uint8 rollUnder; uint placeBlockNumber; uint40 mask; address gambler; } mapping (uint => Bet) bets; address public croupier; event SettleBet(uint commit, uint dice, uint amount, uint diceWin); event Refund(uint commit, uint amount); event Commit(uint commit); constructor () public { owner = msg.sender; secretSigner = DUMMY_ADDRESS; croupier = DUMMY_ADDRESS; } modifier onlyOwner { require (msg.sender == owner, "OnlyOwner methods called by non-owner."); _; } modifier onlyCroupier { require (msg.sender == croupier, "OnlyCroupier methods called by non-croupier."); _; } function approveNextOwner(address _nextOwner) external onlyOwner { require (_nextOwner != owner, "Cannot approve current owner."); nextOwner = _nextOwner; } function acceptNextOwner() external { require (msg.sender == nextOwner, "Can only accept preapproved new owner."); owner = nextOwner; } function () public payable { } function setSecretSigner(address newSecretSigner) external onlyOwner { secretSigner = newSecretSigner; } function setCroupier(address newCroupier) external onlyOwner { croupier = newCroupier; } function setMaxProfit(uint _maxProfit) public onlyOwner { require (_maxProfit < MAX_AMOUNT, "maxProfit should be a sane number."); maxProfit = _maxProfit; } function setBetExpirationBlocks(uint _betExpirationBlocks) public onlyOwner { require (_betExpirationBlocks > 0, "betExpirationBlocks should be a sane number."); betExpirationBlocks = _betExpirationBlocks; } function withdrawFunds(uint withdrawAmount) external onlyOwner { require (withdrawAmount <= address(this).balance, "Increase amount larger than balance."); require (lockedInBets.add(withdrawAmount) <= address(this).balance, "Not enough funds."); exchange.transfer(withdrawAmount); } function getBetInfoByReveal(uint reveal) external view returns (uint commit, uint amount, uint modulo, uint rollUnder, uint placeBlockNumber, uint mask, address gambler) { commit = uint(keccak256(abi.encodePacked(reveal))); (amount, modulo, rollUnder, placeBlockNumber, mask, gambler) = getBetInfo(commit); } function getBetInfo(uint commit) public view returns (uint amount, uint modulo, uint rollUnder, uint placeBlockNumber, uint mask, address gambler) { Bet storage bet = bets[commit]; amount = bet.amount; modulo = bet.modulo; rollUnder = bet.rollUnder; placeBlockNumber = bet.placeBlockNumber; mask = bet.mask; gambler = bet.gambler; } function placeBet(uint betMask, uint modulo, uint commitLastBlock, uint commit, bytes32 r, bytes32 s, uint8 v) external payable { Bet storage bet = bets[commit]; require (bet.gambler == address(0), "Bet should be in a 'clean' state."); require (modulo > 1 && modulo <= MAX_MODULO, "Modulo should be within range."); require (msg.value >= MIN_BET && msg.value <= MAX_AMOUNT, "Amount should be within range."); require (betMask > 0 && betMask < MAX_BET_MASK, "Mask should be within range."); require (block.number <= commitLastBlock && commitLastBlock <= block.number.add(betExpirationBlocks), "Commit has expired."); require (secretSigner == ecrecover(keccak256(abi.encodePacked(uint40(commitLastBlock), commit)), v, r, s), "ECDSA signature is not valid."); uint rollUnder; if (modulo <= MAX_MASK_MODULO) { rollUnder = ((betMask.mul(POPCNT_MULT)) & POPCNT_MASK).mod(POPCNT_MODULO); bet.mask = uint40(betMask); } else { require (betMask > 0 && betMask <= modulo, "High modulo range, betMask larger than modulo."); rollUnder = betMask; } uint possibleWinAmount; possibleWinAmount = getDiceWinAmount(msg.value, modulo, rollUnder); require (possibleWinAmount <= msg.value.add(maxProfit), "maxProfit limit violation."); lockedInBets = lockedInBets.add(possibleWinAmount); require (lockedInBets <= address(this).balance, "Cannot afford to lose this bet."); emit Commit(commit); bet.amount = msg.value; bet.modulo = uint8(modulo); bet.rollUnder = uint8(rollUnder); bet.placeBlockNumber = block.number; bet.gambler = msg.sender; } function settleBet(uint reveal, bytes32 blockHash) external onlyCroupier { uint commit = uint(keccak256(abi.encodePacked(reveal))); Bet storage bet = bets[commit]; require (block.number > bet.placeBlockNumber, "settleBet in the same block as placeBet, or before."); require (block.number <= bet.placeBlockNumber.add(betExpirationBlocks), "Blockhash can't be queried by EVM."); require (blockhash(bet.placeBlockNumber) == blockHash); settleBetCommon(bet, reveal, commit, blockHash); } function settleBetCommon(Bet storage bet, uint reveal, uint commit, bytes32 entropyBlockHash) private { uint amount = bet.amount; uint modulo = bet.modulo; uint rollUnder = bet.rollUnder; address gambler = bet.gambler; require (amount != 0, "Bet should be in an 'active' state"); bet.amount = 0; bytes32 entropy = keccak256(abi.encodePacked(reveal, entropyBlockHash)); uint dice = uint(entropy).mod(modulo); uint diceWinAmount; diceWinAmount = getDiceWinAmount(amount, modulo, rollUnder); uint diceWin = 0; if (modulo <= MAX_MASK_MODULO) { if ((2 ** dice) & bet.mask != 0) { diceWin = diceWinAmount; } } else { if (dice < rollUnder) { diceWin = diceWinAmount; } } lockedInBets = lockedInBets.sub(diceWinAmount); gambler.transfer(diceWin == 0 ? 1 wei : diceWin); emit SettleBet(commit, dice, amount, diceWin); } function refundBet(uint commit) 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), "Blockhash can't be queried by EVM."); bet.amount = 0; uint diceWinAmount; diceWinAmount = getDiceWinAmount(amount, bet.modulo, bet.rollUnder); lockedInBets = lockedInBets.sub(diceWinAmount); bet.gambler.transfer(amount); emit Refund(commit, amount); } function getDiceWinAmount(uint amount, uint modulo, uint rollUnder) private pure returns (uint winAmount) { require (0 < rollUnder && rollUnder <= modulo, "Win probability out of range."); uint houseEdge = amount.mul(HOUSE_EDGE_PERCENT).div(100); require (houseEdge <= amount, "Bet doesn't even cover house edge."); winAmount = amount.sub(houseEdge).mul(modulo).div(rollUnder); } uint constant POPCNT_MULT = 0x0000000000002000000000100000000008000000000400000000020000000001; uint constant POPCNT_MASK = 0x0001041041041041041041041041041041041041041041041041041041041041; uint constant POPCNT_MODULO = 0x3F; } 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; } }
1
pragma solidity ^0.4.18; 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 { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() 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; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 26870400; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x7eB71add7482F3462BAA46328f58a235E33dbD0e; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.23; contract PumpAndDump { address owner; uint newCoinFee = 0.005 ether; uint newCoinFeeIncrease = 0.001 ether; uint defaultCoinPrice = 0.001 ether; uint coinPriceIncrease = 0.0001 ether; uint devFees = 0; uint16[] coinIds; struct Coin { bool exists; string name; uint price; uint marketValue; address[] investors; } mapping (uint16 => Coin) coins; constructor() public { owner = msg.sender; } function kill() external { require(msg.sender == owner); selfdestruct(owner); } function getNewCoinFee() public constant returns (uint) { return newCoinFee; } function isCoinIdUnique(uint16 newId) private constant returns (bool) { for (uint i = 0; i < coinIds.length; i++) { if (coinIds[i] == newId) { return false; } } return true; } function createCoin(uint16 id, string name) public payable { require(msg.value >= newCoinFee); require(id < 17576); require(bytes(name).length > 0); require(isCoinIdUnique(id)); devFees += msg.value - defaultCoinPrice; coins[id].exists = true; coins[id].name = name; coins[id].price = defaultCoinPrice; coins[id].marketValue = defaultCoinPrice; coins[id].investors.push(msg.sender); coinIds.push(id); newCoinFee += newCoinFeeIncrease; } function getCoinIds() public view returns (uint16[]) { return coinIds; } function getCoinInfoFromId(uint16 coinId) public view returns (string, uint, uint, address[]) { return ( coins[coinId].name, coins[coinId].price, coins[coinId].marketValue, coins[coinId].investors ); } function getUserCoinMarketValue(uint16 coinId, uint userIndex) private view returns (uint) { uint numInvestors = coins[coinId].investors.length; if (numInvestors == userIndex + 1) { return coins[coinId].price; } else { uint numShares = (numInvestors * (numInvestors + 1)) / 2; return ((numInvestors - userIndex) * coins[coinId].marketValue) / numShares; } } function isSenderInvestor(address sender, address[] investors) private pure returns (bool) { for (uint i = 0; i < investors.length; i++) { if (investors[i] == sender) { return true; } } return false; } function buyCoin(uint16 coinId) public payable { require(msg.value >= coins[coinId].price); require(coins[coinId].exists); require(!isSenderInvestor(msg.sender, coins[coinId].investors)); coins[coinId].investors.push(msg.sender); uint amount = (msg.value * 99) / 100; devFees += msg.value - amount; coins[coinId].marketValue += amount; coins[coinId].price += coinPriceIncrease; } function payAndRemoveInvestor(uint16 coinId, uint investorIndex) private { uint value = getUserCoinMarketValue(coinId, investorIndex); coins[coinId].investors[investorIndex].transfer(value); coins[coinId].price -= coinPriceIncrease; coins[coinId].marketValue -= value; if (coins[coinId].investors.length == 1) { delete coins[coinId].investors[0]; } else { uint secondLastIndex = coins[coinId].investors.length - 1; for (uint j = investorIndex; j < secondLastIndex; j++) { coins[coinId].investors[j] = coins[coinId].investors[j - 1]; } } coins[coinId].investors.length -= 1; } function sellCoin(uint16 coinId) public { bool senderIsInvestor = false; uint investorIndex = 0; require(coins[coinId].exists); for (uint i = 0; i < coins[coinId].investors.length; i++) { if (coins[coinId].investors[i] == msg.sender) { senderIsInvestor = true; investorIndex = i; break; } } require(senderIsInvestor); payAndRemoveInvestor(coinId, investorIndex); } function getDevFees() public view returns (uint) { require(msg.sender == owner); return devFees; } function collectDevFees() public { require(msg.sender == owner); owner.transfer(devFees); devFees = 0; } function() public payable {} }
1
pragma solidity ^0.4.25; 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; } function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } } contract CryptoEngineerInterface { uint256 public prizePool = 0; function subVirus(address , uint256 ) public {} function claimPrizePool(address , uint256 ) public {} function isContractMiniGame() public pure returns( bool ) {} function isEngineerContract() external pure returns(bool) {} } contract CryptoMiningWarInterface { uint256 public deadline; function subCrystal( address , uint256 ) public {} function isMiningWarContract() external pure returns(bool) {} } interface MiniGameInterface { function isContractMiniGame() external pure returns( bool _isContractMiniGame ); } contract CrystalDeposit { using SafeMath for uint256; address public administrator; uint256 public HALF_TIME = 48 hours; uint256 public MIN_TIME_WITH_DEADLINE = 12 hours; uint256 public round = 0; CryptoEngineerInterface public Engineer; CryptoMiningWarInterface public MiningWar; address miningWarAddress; uint256 miningWarDeadline; uint256 constant private CRTSTAL_MINING_PERIOD = 86400; mapping(uint256 => Game) public games; mapping(address => Player) public players; mapping(address => bool) public miniGames; struct Game { uint256 round; uint256 crystals; uint256 prizePool; uint256 startTime; uint256 endTime; bool ended; } struct Player { uint256 currentRound; uint256 lastRound; uint256 reward; uint256 share; } event EndRound(uint256 round, uint256 crystals, uint256 prizePool, uint256 startTime, uint256 endTime); event Deposit(address player, uint256 currentRound, uint256 deposit, uint256 currentShare); modifier isAdministrator() { require(msg.sender == administrator); _; } modifier disableContract() { require(tx.origin == msg.sender); _; } constructor() public { administrator = msg.sender; setMiningWarInterface(0x65c347702b66ff8f1a28cf9a9768487fbe97765f); setEngineerInterface(0xb2d6000d4a7fe8b1358d54a9bc21f2badf91d849); } function () public payable { } function isContractMiniGame() public pure returns( bool _isContractMiniGame ) { _isContractMiniGame = true; } function isDepositContract() public pure returns(bool) { return true; } function upgrade(address addr) public isAdministrator { selfdestruct(addr); } function setContractsMiniGame( address _addr ) public isAdministrator { MiniGameInterface MiniGame = MiniGameInterface( _addr ); if( MiniGame.isContractMiniGame() == false ) { revert(); } miniGames[_addr] = true; } function removeContractMiniGame(address _addr) public isAdministrator { miniGames[_addr] = false; } function setupMiniGame( uint256 , uint256 _miningWarDeadline ) public { require(msg.sender == miningWarAddress); miningWarDeadline = _miningWarDeadline; } function setMiningWarInterface(address _addr) public isAdministrator { CryptoMiningWarInterface miningWarInterface = CryptoMiningWarInterface(_addr); require(miningWarInterface.isMiningWarContract() == true); miningWarAddress = _addr; MiningWar = miningWarInterface; } function setEngineerInterface(address _addr) public isAdministrator { CryptoEngineerInterface engineerInterface = CryptoEngineerInterface(_addr); require(engineerInterface.isEngineerContract() == true); Engineer = engineerInterface; } function startGame() public isAdministrator { miningWarDeadline = MiningWar.deadline(); games[round].ended = true; startRound(); } function startRound() private { require(games[round].ended == true); uint256 crystalsLastRound = games[round].crystals; uint256 prizePoolLastRound= games[round].prizePool; round = round + 1; uint256 startTime = now; if (miningWarDeadline < SafeMath.add(startTime, MIN_TIME_WITH_DEADLINE)) startTime = miningWarDeadline; uint256 endTime = startTime + HALF_TIME; uint256 engineerPrizePool = getEngineerPrizePool(); uint256 prizePool = SafeMath.div(SafeMath.mul(engineerPrizePool, 5),100); Engineer.claimPrizePool(address(this), prizePool); if (crystalsLastRound == 0) prizePool = SafeMath.add(prizePool, prizePoolLastRound); games[round] = Game(round, 0, prizePool, startTime, endTime, false); } function endRound() private { require(games[round].ended == false); require(games[round].endTime <= now); Game storage g = games[round]; g.ended = true; startRound(); emit EndRound(g.round, g.crystals, g.prizePool, g.startTime, g.endTime); } function share(uint256 _value) public disableContract { require(games[round].ended == false); require(games[round].startTime <= now); require(_value >= 1); MiningWar.subCrystal(msg.sender, _value); if (games[round].endTime <= now) endRound(); updateReward(msg.sender); Game storage g = games[round]; uint256 _share = SafeMath.mul(_value, CRTSTAL_MINING_PERIOD); g.crystals = SafeMath.add(g.crystals, _share); Player storage p = players[msg.sender]; if (p.currentRound == round) { p.share = SafeMath.add(p.share, _share); } else { p.share = _share; p.currentRound = round; } emit Deposit(msg.sender, p.currentRound, _value, p.share); } function getCurrentReward(address _addr) public view returns(uint256 _currentReward) { Player memory p = players[_addr]; _currentReward = p.reward; _currentReward += calculateReward(_addr, p.currentRound); } function withdrawReward(address _addr) public { if (games[round].endTime <= now) endRound(); updateReward(_addr); Player storage p = players[_addr]; uint256 balance = p.reward; if (address(this).balance >= balance && balance > 0) { _addr.transfer(balance); p.reward = 0; } } function updateReward(address _addr) private { Player storage p = players[_addr]; if ( games[p.currentRound].ended == true && p.lastRound < p.currentRound ) { p.reward = SafeMath.add(p.reward, calculateReward(msg.sender, p.currentRound)); p.lastRound = p.currentRound; } } function getData(address _addr) public view returns( uint256 _prizePool, uint256 _crystals, uint256 _startTime, uint256 _endTime, uint256 _reward, uint256 _share ) { (_prizePool, _crystals, _startTime, _endTime) = getCurrentGame(); (_reward, _share) = getPlayerData(_addr); } function calculateReward(address _addr, uint256 _round) public view returns(uint256) { Player memory p = players[_addr]; Game memory g = games[_round]; if (g.endTime > now) return 0; if (g.crystals == 0) return 0; if (p.lastRound >= _round) return 0; return SafeMath.div(SafeMath.mul(g.prizePool, p.share), g.crystals); } function getCurrentGame() private view returns(uint256 _prizePool, uint256 _crystals, uint256 _startTime, uint256 _endTime) { Game memory g = games[round]; _prizePool = g.prizePool; _crystals = g.crystals; _startTime = g.startTime; _endTime = g.endTime; } function getPlayerData(address _addr) private view returns(uint256 _reward, uint256 _share) { Player memory p = players[_addr]; _reward = p.reward; if (p.currentRound == round) _share = players[_addr].share; if (p.currentRound != p.lastRound) _reward += calculateReward(_addr, p.currentRound); } function getEngineerPrizePool() private view returns(uint256) { return Engineer.prizePool(); } }
0
pragma solidity ^0.4.16; 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 VASTToken is TokenERC20 { function VASTToken( uint256 initialSupply, string tokenName, string tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) public {} }
1
contract TwoAndAHalfPonzi { uint public constant VALUE = 1001 finney; uint public constant VALUEBACK = 2500 finney; struct Payout { address addr; uint yield; } Payout[] public payouts; uint public payoutIndex = 0; uint public payoutTotal = 0; function TwoAndAHalfPonzi() { } function() { if (msg.value != VALUE) { throw; } uint entryIndex = payouts.length; payouts.length += 1; payouts[entryIndex].addr = msg.sender; payouts[entryIndex].yield = VALUEBACK; while (payouts[payoutIndex].yield < this.balance) { payoutTotal += payouts[payoutIndex].yield; payouts[payoutIndex].addr.send(payouts[payoutIndex].yield); payoutIndex += 1; } } }
1
pragma solidity ^0.4.9; contract SafeMath { function safeMul(uint a, uint b) internal returns (uint) { uint c = a * b; assert(a == 0 || 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; } function assert(bool assertion) internal { if (!assertion) throw; } } contract Token { function totalSupply() constant returns (uint256 supply) {} function balanceOf(address _owner) constant returns (uint256 balance) {} function transfer(address _to, uint256 _value) returns (bool success) {} function transferFrom(address _from, address _to, 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 _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); uint public decimals; string public name; } contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { 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]; } mapping(address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply; } contract ReserveToken is StandardToken, SafeMath { address public minter; function ReserveToken() { minter = msg.sender; } function create(address account, uint amount) { if (msg.sender != minter) throw; balances[account] = safeAdd(balances[account], amount); totalSupply = safeAdd(totalSupply, amount); } function destroy(address account, uint amount) { if (msg.sender != minter) throw; if (balances[account] < amount) throw; balances[account] = safeSub(balances[account], amount); totalSupply = safeSub(totalSupply, amount); } } contract AccountLevels { function accountLevel(address user) constant returns(uint) {} } contract AccountLevelsTest is AccountLevels { mapping (address => uint) public accountLevels; function setAccountLevel(address user, uint level) { accountLevels[user] = level; } function accountLevel(address user) constant returns(uint) { return accountLevels[user]; } } contract ELTWagerLedger is SafeMath { address public admin; mapping (address => mapping (address => uint)) public tokens; event Deposit(address token, address user, uint amount, uint balance); event Withdraw(address token, address user, uint amount, uint balance); function ELTWagerLedger(address admin_) { admin = admin_; } function() { throw; } function changeAdmin(address admin_) { if (msg.sender != admin) throw; admin = admin_; } function deposit() payable { tokens[0][msg.sender] = safeAdd(tokens[0][msg.sender], msg.value); Deposit(0, msg.sender, msg.value, tokens[0][msg.sender]); } function withdraw(uint amount) { if (tokens[0][msg.sender] < amount) throw; tokens[0][msg.sender] = safeSub(tokens[0][msg.sender], amount); if (!msg.sender.call.value(amount)()) throw; Withdraw(0, msg.sender, amount, tokens[0][msg.sender]); } function depositToken(address token, uint amount) { if (token==0) throw; if (!Token(token).transferFrom(msg.sender, this, amount)) throw; tokens[token][msg.sender] = safeAdd(tokens[token][msg.sender], amount); Deposit(token, msg.sender, amount, tokens[token][msg.sender]); } function withdrawToken(address token, uint amount) { if (token==0) throw; if (tokens[token][msg.sender] < amount) throw; tokens[token][msg.sender] = safeSub(tokens[token][msg.sender], amount); if (!Token(token).transfer(msg.sender, amount)) throw; Withdraw(token, msg.sender, amount, tokens[token][msg.sender]); } function balanceOf(address token, address user) constant returns (uint) { return tokens[token][user]; } }
0
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; } } library Math { 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; } } 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 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 Jewel { function incise(address owner, uint256 value) external returns (uint); } contract DayQualitys { function getAreaQualityByDay(uint32 time, uint32 area) external returns (uint32); } contract Mineral is BurnableToken, Ownable { string public name = "Mineral"; string public symbol = "ORE"; uint8 public decimals = 18; uint256 public constant INITIAL_SUPPLY = 800 * 1000 * 1000 * (10 ** uint256(decimals)); uint public constant MINER_4_HOURS = 0.0005 ether; uint public constant MINER_8_HOURS = 0.001 ether; uint public constant MINER_24_HOURS = 0.003 ether; mapping(address => uint[][72]) public deployRange; uint public timeScale = 1; mapping(uint32 => uint32[3][72]) private areaHourDeployed; struct AreaHourDeployed { uint32[72] lastCollectHour; mapping(uint32 => uint32[3][72]) hour; } mapping(address => AreaHourDeployed) private userAreaHourDeployed; uint8 public constant CHECK_POINT_HOUR = 4; mapping(uint32 => uint32[72]) private areaCheckPoints; mapping(uint32 => uint) private dayAverageOutput; struct AreaCheckPoint { mapping(uint32 => uint32[72]) hour; } mapping(address => AreaCheckPoint) private userAreaCheckPoints; uint256 amountEther; mapping (address => uint) public remainEther; uint32 public constractDeployTime = uint32(now) / 1 hours * 1 hours; mapping(address => uint) activeArea; bool enableWhiteList = true; mapping(address => bool) whiteUserList; address serverAddress; address coldWallet; bool enableCheckArea = true; Jewel public jewelContract; DayQualitys public dayQualitysContract; event Pause(); event Unpause(); bool public paused = false; function Mineral() public { totalSupply = INITIAL_SUPPLY; balances[this] = 300 * 1000 * 1000 * (10 ** uint256(decimals)); balances[parseAddr("0x22de6b7F8b6119bA8E62FB4165834eA00adb6f3E")] = 110 * 1000 * 1000 * (10 ** uint256(decimals)); balances[parseAddr("0xA3eCD9F46CCfE4D27D747C9c7469990df7412d48")] = 30 * 1000 * 1000 * (10 ** uint256(decimals)); balances[parseAddr("0x686824DB069586aC0aD8060816F1D66A0EE8297b")] = 60 * 1000 * 1000 * (10 ** uint256(decimals)); balances[parseAddr("0x9E8eA5C674EBd85868215ceFab9c108Ab9ceA702")] = 150 * 1000 * 1000 * (10 ** uint256(decimals)); balances[parseAddr("0x4706f5d2a0d4D4eE5A37dDE1438C7de774A2A184")] = 150 * 1000 * 1000 * (10 ** uint256(decimals)); dayAverageOutput[0] = 241920 * 10 ** uint256(decimals); } function parseAddr(string _a) internal returns (address){ bytes memory b = bytes(_a); uint result = 0; for (uint i = 0; i < b.length; i++) { uint c = uint(b[i]); if (c >= 48 && c <= 57) { result = result * 16 + (c - 48); } if(c >= 65 && c<= 90) { result = result * 16 + (c - 55); } if(c >= 97 && c<= 122) { result = result * 16 + (c - 87); } } return address(result); } function setColdWallet(address _coldWallet) public onlyOwner { coldWallet = _coldWallet; } function disableWhiteUserList() public onlyOwner { enableWhiteList = false; } function disableCheckArea() public onlyOwner { enableCheckArea = false; } modifier checkWhiteList() { if (enableWhiteList) { require(whiteUserList[msg.sender]); } _; } function setServerAddress(address addr) public onlyOwner { serverAddress = addr; } function authUser(string addr) public { require(msg.sender == serverAddress || msg.sender == owner); address s = bytesToAddress(bytes(addr)); whiteUserList[s] = true; } function bytesToAddress (bytes b) internal view returns (address) { uint result = 0; for (uint i = 0; i < b.length; i++) { uint c = uint(b[i]); if (c >= 48 && c <= 57) { result = result * 16 + (c - 48); } if(c >= 65 && c <= 90) { result = result * 16 + (c - 55); } if(c >= 97 && c <= 122) { result = result * 16 + (c - 87); } } return address(result); } function setDayQualitys(address dayQualitys) public onlyOwner { dayQualitysContract = DayQualitys(dayQualitys); } function getMyDeployAt(uint32 area, uint32 hour) public view returns (uint32[3]) { return userAreaHourDeployed[msg.sender].hour[hour][area]; } function getMyMinersAt(uint32 area, uint32 hour) public view returns (uint32) { return _getUserMinersAt(msg.sender, area, hour); } function _getUserMinersAt(address user, uint32 area, uint32 hour) internal view returns(uint32) { uint32 nc = hour/CHECK_POINT_HOUR*CHECK_POINT_HOUR; if (userAreaCheckPoints[user].hour[nc][area] == 0 && userAreaCheckPoints[user].hour[nc + CHECK_POINT_HOUR][area] == 0) { return 0; } uint32 h = 0; int64 userInc = 0; uint32[3] storage ptUser; AreaHourDeployed storage _userAreaHourDeployed = userAreaHourDeployed[user]; for (h = nc; h <= hour; ++h) { ptUser = _userAreaHourDeployed.hour[h][area]; userInc += ptUser[0] + ptUser[1] + ptUser[2] - _userAreaHourDeployed.hour[h - 4][area][0] - _userAreaHourDeployed.hour[h - 8][area][1] - _userAreaHourDeployed.hour[h - 24][area][2]; } return userAreaCheckPoints[user].hour[nc][area] + uint32(userInc); } function getDeployAt(uint32 area, uint32 hour) public view returns (uint32[3]) { return areaHourDeployed[hour][area]; } function getMinersAt(uint32 area, uint32 hour) public view returns (uint32) { return _getMinersAt(area, hour); } function _getMinersAt(uint32 area, uint32 hour) internal view returns (uint32) { uint32 nc = hour/CHECK_POINT_HOUR*CHECK_POINT_HOUR; uint32 h = 0; int64 userInc = 0; int64 totalInc = 0; uint32[3] storage ptArea; for (h = nc; h <= hour; ++h) { ptArea = areaHourDeployed[h][area]; totalInc += ptArea[0] + ptArea[1] + ptArea[2] - areaHourDeployed[h - 4][area][0] - areaHourDeployed[h - 8][area][1] - areaHourDeployed[h - 24][area][2]; } return areaCheckPoints[nc][area] + uint32(totalInc); } function updateArea(uint areaId) internal pure returns (uint) { uint row = areaId / 8; uint colum = areaId % 8; uint result = uint(1) << areaId; if (row-1 >= 0) { result |= uint(1) << ((row-1)*8+colum); } if (row+1 < 9) { result |= uint(1) << ((row+1)*8+colum); } if (colum-1 >= 0) { result |= uint(1) << (row*8+colum-1); } if (colum+1 < 8) { result |= uint(1) << (row*8+colum+1); } return result; } function checkArea(uint32[] area, address user) internal { if (enableCheckArea) { uint[] memory distinctArea = new uint[](area.length); uint distinctAreaLength = 0; for (uint i = 0; i < area.length; i++) { bool find = false; for (uint j = 0; j < distinctAreaLength; j++) { if (distinctArea[j] == area[i]) { find = true; break; } } if (!find) { distinctArea[distinctAreaLength] = area[i]; distinctAreaLength += 1; } } if (activeArea[user] == 0) { require(distinctAreaLength == 1); activeArea[user] = updateArea(distinctArea[0]); } else { uint userActiveArea = activeArea[user]; uint updateActiveArea = userActiveArea; for (i = 0; i < distinctAreaLength; i++) { require(userActiveArea & uint(1) << distinctArea[i] > 0); updateActiveArea = updateActiveArea | updateArea(distinctArea[i]); } activeArea[user] = updateActiveArea; } } } function deployMiners(address user, uint32[] area, uint32[] period, uint32[] count) public checkWhiteList whenNotPaused payable { require(area.length > 0); require(area.length == period.length); require(area.length == count.length); address _user = user; if (_user == address(0)) { _user = msg.sender; } uint32 _hour = uint32((now - constractDeployTime) * timeScale / 1 hours); checkArea(area, user); uint payment = _deployMiners(_user, _hour, area, period, count); _updateCheckPoints(_user, _hour, area, period, count); require(payment <= msg.value); remainEther[msg.sender] += (msg.value - payment); if (coldWallet != address(0)) { coldWallet.transfer(payment); } else { amountEther += payment; } } function _deployMiners(address _user, uint32 _hour, uint32[] memory area, uint32[] memory period, uint32[] memory count) internal returns(uint){ uint payment = 0; uint32 minerCount = 0; uint32[3][72] storage _areaDeployed = areaHourDeployed[_hour]; uint32[3][72] storage _userAreaDeployed = userAreaHourDeployed[_user].hour[_hour]; for (uint index = 0; index < area.length; ++index) { require (period[index] == 4 || period[index] == 8 || period[index] == 24); if (period[index] == 4) { _areaDeployed[area[index]][0] += count[index]; _userAreaDeployed[area[index]][0] += count[index]; payment += count[index] * MINER_4_HOURS; } else if (period[index] == 8) { _areaDeployed[area[index]][1] += count[index]; _userAreaDeployed[area[index]][1] += count[index]; payment += count[index] * MINER_8_HOURS; } else if (period[index] == 24) { _areaDeployed[area[index]][2] += count[index]; _userAreaDeployed[area[index]][2] += count[index]; payment += count[index] * MINER_24_HOURS; } minerCount += count[index]; DeployMiner(_user, area[index], _hour, _hour + period[index], count[index]); adjustDeployRange(area[index], _hour, _hour + period[index]); } return payment; } function adjustDeployRange(uint area, uint start, uint end) internal { uint len = deployRange[msg.sender][area].length; if (len == 0) { deployRange[msg.sender][area].push(start | (end << 128)); } else { uint s = uint128(deployRange[msg.sender][area][len - 1]); uint e = uint128(deployRange[msg.sender][area][len - 1] >> 128); if (start >= s && start < e) { end = e > end ? e : end; deployRange[msg.sender][area][len - 1] = s | (end << 128); } else { deployRange[msg.sender][area].push(start | (end << 128)); } } } function getDeployArrayLength(uint area) public view returns (uint) { return deployRange[msg.sender][area].length; } function getDeploy(uint area, uint index) public view returns (uint,uint) { uint s = uint128(deployRange[msg.sender][area][index]); uint e = uint128(deployRange[msg.sender][area][index] >> 128); return (s, e); } function _updateCheckPoints(address _user, uint32 _hour, uint32[] memory area, uint32[] memory period, uint32[] memory count) internal { uint32 _area = 0; uint32 _count = 0; uint32 ce4 = _hour + 4; uint32 ce8 = _hour + 8; uint32 ce24 = _hour + 24; uint32 cs = (_hour/CHECK_POINT_HOUR+1)*CHECK_POINT_HOUR; AreaCheckPoint storage _userAreaCheckPoints = userAreaCheckPoints[_user]; uint32 cp = 0; for (uint index = 0; index < area.length; ++index) { _area = area[index]; _count = count[index]; if (period[index] == 4) { for (cp = cs; cp <= ce4; cp += CHECK_POINT_HOUR) { areaCheckPoints[cp][_area] += _count; _userAreaCheckPoints.hour[cp][_area] += _count; } } else if (period[index] == 8) { for (cp = cs; cp <= ce8; cp += CHECK_POINT_HOUR) { areaCheckPoints[cp][_area] += _count; _userAreaCheckPoints.hour[cp][_area] += _count; } } else if (period[index] == 24) { for (cp = cs; cp <= ce24; cp += CHECK_POINT_HOUR) { areaCheckPoints[cp][_area] += _count; _userAreaCheckPoints.hour[cp][_area] += _count; } } } } event DeployMiner(address addr, uint32 area, uint32 start, uint32 end, uint32 count); event Collect(address addr, uint32 area, uint32 start, uint32 end, uint areaCount); function getMyLastCollectHour(uint32 area) public view returns (uint32){ return userAreaHourDeployed[msg.sender].lastCollectHour[area]; } function collect(address user, uint32[] area) public checkWhiteList whenNotPaused { require(address(dayQualitysContract) != address(0)); uint32 current = uint32((now - constractDeployTime) * timeScale / 1 hours); require(area.length > 0); address _user = user; if (_user == address(0)) { _user = msg.sender; } uint total = 0; for (uint a = 0; a < area.length; ++a) { uint len = deployRange[msg.sender][area[a]].length; bool finish = true; for (uint i = 0; i < len; i += 1) { uint s = uint128(deployRange[msg.sender][area[a]][i]); uint e = uint128(deployRange[msg.sender][area[a]][i] >> 128); if (current < e && current >= s ) { total += _collect(_user, uint32(s), current, area[a]); deployRange[msg.sender][area[a]][i] = current | (e << 128); finish = false; } else if (current >= e) { total += _collect(_user, uint32(s), uint32(e), area[a]); } } if (finish) { deployRange[msg.sender][area[a]].length = 0; } else { deployRange[msg.sender][area[a]][0] = deployRange[msg.sender][area[a]][len - 1]; deployRange[msg.sender][area[a]].length = 1; } } ERC20(this).transfer(_user, total); } function _collect(address _user, uint32 start, uint32 end, uint32 area) internal returns (uint) { uint result = 0; uint32 writeCount = 1; uint income = 0; uint32[] memory totalMiners = new uint32[](CHECK_POINT_HOUR); uint32[] memory userMiners = new uint32[](CHECK_POINT_HOUR); uint32 ps = start/CHECK_POINT_HOUR*CHECK_POINT_HOUR+CHECK_POINT_HOUR; if (ps >= end) { (income, writeCount) = _collectMinersByCheckPoints(_user, area, start, end, totalMiners, userMiners, writeCount); result += income; } else { (income, writeCount) = _collectMinersByCheckPoints(_user, area, start, ps, totalMiners, userMiners, writeCount); result += income; while (ps < end) { (income, writeCount) = _collectMinersByCheckPoints(_user, area, ps, uint32(Math.min64(end, ps + CHECK_POINT_HOUR)), totalMiners, userMiners, writeCount); result += income; ps += CHECK_POINT_HOUR; } } Collect(_user, area, start, end, result); return result; } function _collectMinersByCheckPoints(address _user, uint32 area, uint32 start, uint32 end, uint32[] memory totalMiners, uint32[] memory userMiners, uint32 _writeCount) internal returns (uint income, uint32 writeCount) { writeCount = _writeCount; income = 0; if (userAreaCheckPoints[_user].hour[start/CHECK_POINT_HOUR*CHECK_POINT_HOUR][area] == 0 && userAreaCheckPoints[_user].hour[start/CHECK_POINT_HOUR*CHECK_POINT_HOUR + CHECK_POINT_HOUR][area] == 0) { return; } _getMinersByCheckPoints(_user, area, start, end, totalMiners, userMiners); uint ao = dayAverageOutput[start / 24]; if (ao == 0) { uint32 d = start / 24; for (; d >= 0; --d) { if (dayAverageOutput[d] != 0) { break; } } ao = dayAverageOutput[d]; for (d = d+1; d <= start / 24; ++d) { ao = ao*9996/10000; if ((start / 24 - d) < writeCount) { dayAverageOutput[d] = ao; } } if (writeCount > (start / 24 - d - 1)) { writeCount = writeCount - (start / 24 - d - 1); } else { writeCount = 0; } } uint week = dayQualitysContract.getAreaQualityByDay(uint32(start * 1 hours + constractDeployTime), area); require(week > 0); ao = week * ao / 10 / 24 / 72; income = _getTotalIncomeAt(end - start, userMiners, totalMiners, ao, week); if (week == 10) { income = income * 8 / 10; } else if (week == 5) { income = income * 6 / 10; } } function _getTotalIncomeAt(uint32 hourLength, uint32[] memory userMiners, uint32[] memory totalMiners, uint areaOutput, uint week) internal view returns(uint) { uint income = 0; for (uint i = 0; i < hourLength; ++i) { if (userMiners[i] != 0 && totalMiners[i] != 0) { income += (Math.min256(10 ** uint256(decimals), areaOutput / totalMiners[i]) * userMiners[i]); } } return income; } function _getMinersByCheckPoints(address _user, uint32 area, uint32 start, uint32 end, uint32[] memory totalMiners, uint32[] memory userMiners) internal view { require((end - start) <= CHECK_POINT_HOUR); uint32 h = 0; int64 userInc = 0; int64 totalInc = 0; uint32[3] storage ptUser; uint32[3] storage ptArea; AreaHourDeployed storage _userAreaHourDeployed = userAreaHourDeployed[_user]; for (h = start/CHECK_POINT_HOUR*CHECK_POINT_HOUR; h <= start; ++h) { ptUser = _userAreaHourDeployed.hour[h][area]; ptArea = areaHourDeployed[h][area]; totalInc += ptArea[0] + ptArea[1] + ptArea[2] - areaHourDeployed[h - 4][area][0] - areaHourDeployed[h - 8][area][1] - areaHourDeployed[h - 24][area][2]; userInc += ptUser[0] + ptUser[1] + ptUser[2] - _userAreaHourDeployed.hour[h - 4][area][0] - _userAreaHourDeployed.hour[h - 8][area][1] - _userAreaHourDeployed.hour[h - 24][area][2]; } totalMiners[0] = areaCheckPoints[start/CHECK_POINT_HOUR*CHECK_POINT_HOUR][area] + uint32(totalInc); userMiners[0] = userAreaCheckPoints[_user].hour[start/CHECK_POINT_HOUR*CHECK_POINT_HOUR][area] + uint32(userInc); uint32 i = 1; for (h = start + 1; h < end; ++h) { ptUser = _userAreaHourDeployed.hour[h][area]; ptArea = areaHourDeployed[h][area]; totalMiners[i] = totalMiners[i-1] + ptArea[0] + ptArea[1] + ptArea[2] - areaHourDeployed[h - 4][area][0] - areaHourDeployed[h - 8][area][1] - areaHourDeployed[h - 24][area][2]; userMiners[i] = userMiners[i-1] + ptUser[0] + ptUser[1] + ptUser[2] - _userAreaHourDeployed.hour[h - 4][area][0] - _userAreaHourDeployed.hour[h - 8][area][1] - _userAreaHourDeployed.hour[h - 24][area][2]; ++i; } } function withdraw() public { uint remain = remainEther[msg.sender]; require(remain > 0); remainEther[msg.sender] = 0; msg.sender.transfer(remain); } function withdrawMinerFee() public onlyOwner { require(amountEther > 0); owner.transfer(amountEther); amountEther = 0; } modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; Pause(); } function unpause() onlyOwner whenPaused public { paused = false; Unpause(); } 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 setJewelContract(address jewel) public onlyOwner { jewelContract = Jewel(jewel); } function incise(uint256 value) public returns (uint) { require(jewelContract != address(0)); uint256 balance = balances[msg.sender]; require(balance >= value); uint256 count = (value / (10 ** uint256(decimals))); require(count >= 1); uint ret = jewelContract.incise(msg.sender, count); burn(count * 10 ** uint256(decimals)); return ret; } }
0
pragma solidity ^0.4.24; contract TheWarRedNation { struct _Tx { address txuser; uint txvalue; } _Tx[] public Tx; uint public counter; address owner; modifier onlyowner { if (msg.sender == owner) _; } constructor () public { owner = msg.sender; } function() public payable { require(msg.value>=0.01 ether); Sort(); } function Sort() internal { uint feecounter; feecounter=msg.value/5; owner.send(feecounter); feecounter=0; uint txcounter=Tx.length; counter=Tx.length; Tx.length++; Tx[txcounter].txuser=msg.sender; Tx[txcounter].txvalue=msg.value; } function Count(uint end, uint start) public onlyowner { while (end>start) { Tx[end].txuser.send((Tx[end].txvalue/1000)*200); end-=1; } } }
1
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 RBACMixin { string constant FORBIDDEN = "Haven't enough right to access"; mapping (address => bool) public owners; mapping (address => bool) public minters; event AddOwner(address indexed who); event DeleteOwner(address indexed who); event AddMinter(address indexed who); event DeleteMinter(address indexed who); constructor () public { _setOwner(msg.sender, true); } modifier onlyOwner() { require(isOwner(msg.sender), FORBIDDEN); _; } modifier onlyMinter() { require(isMinter(msg.sender), FORBIDDEN); _; } function isOwner(address _who) public view returns (bool) { return owners[_who]; } function isMinter(address _who) public view returns (bool) { return minters[_who]; } function addOwner(address _who) public onlyOwner returns (bool) { _setOwner(_who, true); } function deleteOwner(address _who) public onlyOwner returns (bool) { _setOwner(_who, false); } function addMinter(address _who) public onlyOwner returns (bool) { _setMinter(_who, true); } function deleteMinter(address _who) public onlyOwner returns (bool) { _setMinter(_who, false); } function _setOwner(address _who, bool _flag) private returns (bool) { require(owners[_who] != _flag); owners[_who] = _flag; if (_flag) { emit AddOwner(_who); } else { emit DeleteOwner(_who); } return true; } function _setMinter(address _who, bool _flag) private returns (bool) { require(minters[_who] != _flag); minters[_who] = _flag; if (_flag) { emit AddMinter(_who); } else { emit DeleteMinter(_who); } return true; } } interface IMintableToken { function mint(address _to, uint256 _amount) external returns (bool); } contract TokenBucket is RBACMixin, IMintableToken { using SafeMath for uint; uint256 public size; uint256 public rate; uint256 public lastMintTime; uint256 public leftOnLastMint; IMintableToken public token; event Leak(address indexed to, uint256 left); constructor (address _token, uint256 _size, uint256 _rate) public { token = IMintableToken(_token); size = _size; rate = _rate; leftOnLastMint = _size; } function setSize(uint256 _size) public onlyOwner returns (bool) { size = _size; return true; } function setRate(uint256 _rate) public onlyOwner returns (bool) { rate = _rate; return true; } function setSizeAndRate(uint256 _size, uint256 _rate) public onlyOwner returns (bool) { return setSize(_size) && setRate(_rate); } function mint(address _to, uint256 _amount) public onlyMinter returns (bool) { uint256 available = availableTokens(); require(_amount <= available); leftOnLastMint = available.sub(_amount); lastMintTime = now; require(token.mint(_to, _amount)); return true; } function availableTokens() public view returns (uint) { uint256 timeAfterMint = now.sub(lastMintTime); uint256 refillAmount = rate.mul(timeAfterMint).add(leftOnLastMint); return size < refillAmount ? size : refillAmount; } }
1
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 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 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 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 PausableToken { 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 TokenImpl is MintableToken { string public name; string public symbol; uint256 public rate; uint256 public decimals = 5; uint256 private decimal_num = 100000; ERC20Basic public targetToken; uint256 public exchangedNum; event Exchanged(address _owner, uint256 _value); function TokenImpl(string _name, string _symbol, uint256 _decimals) public { name = _name; symbol = _symbol; decimals = _decimals; decimal_num = 10 ** decimals; paused = true; } function exchange(address _exchanger, uint256 _value) internal { require(canExchange()); uint256 _tokens = (_value.mul(rate)).div(decimal_num); targetToken.transfer(_exchanger, _tokens); exchangedNum = exchangedNum.add(_value); Exchanged(_exchanger, _tokens); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { if (_to == address(this) || _to == owner) { exchange(msg.sender, _value); } return super.transferFrom(_from, _to, _value); } function transfer(address _to, uint256 _value) public returns (bool) { if (_to == address(this) || _to == owner) { exchange(msg.sender, _value); } return super.transfer(_to, _value); } function balanceOfTarget(address _owner) public view returns (uint256 targetBalance) { if (targetToken != address(0)) { return targetToken.balanceOf(_owner); } else { return 0; } } function canExchangeNum() public view returns (uint256) { if (canExchange()) { uint256 _tokens = targetToken.balanceOf(this); return (decimal_num.mul(_tokens)).div(rate); } else { return 0; } } function updateTargetToken(address _target, uint256 _rate) onlyOwner public { rate = _rate; targetToken = ERC20Basic(_target); } function canExchange() public view returns (bool) { return targetToken != address(0) && rate > 0; } } contract Crowdsale is Pausable { using SafeMath for uint256; string public projectName; string public tokenName; string public tokenSymbol; uint256 public rate; uint256 public ethRaised; uint256 public decimals = 5; uint256 private decimal_num = 100000; uint256 public cap; TokenImpl public token; ERC20Basic public targetToken; event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value); event IncreaseCap(uint256 cap); event DecreaseCap(uint256 cap); event TransferTargetToken(address owner, uint256 value); function Crowdsale(string _projectName, string _tokenName, string _tokenSymbol, uint256 _cap) public { require(_cap > 0); projectName = _projectName; tokenName = _tokenName; tokenSymbol = _tokenSymbol; cap = _cap.mul(decimal_num); token = createTokenContract(); } function newCrowdSale(string _projectName, string _tokenName, string _tokenSymbol, uint256 _cap) onlyOwner public { require(_cap > 0); projectName = _projectName; tokenName = _tokenName; tokenSymbol = _tokenSymbol; cap = _cap.mul(decimal_num); ethRaised = 0; token.transferOwnership(owner); token = createTokenContract(); rate = 0; targetToken = ERC20Basic(0); } function createTokenContract() internal returns (TokenImpl) { return new TokenImpl(tokenName, tokenSymbol, decimals); } function() external payable { buyTokens(msg.sender); } function buyTokens(address beneficiary) whenNotPaused public payable { require(beneficiary != address(0)); require(msg.value >= (0.00001 ether)); uint256 ethAmount = (msg.value.mul(decimal_num)).div(1 ether); ethRaised = ethRaised.add(ethAmount); require(ethRaised <= cap); token.mint(beneficiary, ethAmount); TokenPurchase(msg.sender, beneficiary, ethAmount); forwardFunds(); } function forwardFunds() internal { owner.transfer(msg.value); } function increaseCap(uint256 _cap_inc) onlyOwner public { require(_cap_inc > 0); cap = cap.add(_cap_inc.mul(decimal_num)); IncreaseCap(cap); } function decreaseCap(uint256 _cap_dec) onlyOwner public { require(_cap_dec > 0); uint256 cap_dec = _cap_dec.mul(decimal_num); if (cap_dec >= cap) { cap = ethRaised; } else { cap = cap.sub(cap_dec); if (cap <= ethRaised) { cap = ethRaised; } } DecreaseCap(cap); } function saleRatio() public view returns (uint256 ratio) { if (cap == 0) { return 0; } else { return ethRaised.mul(10000).div(cap); } } function balanceOf(address _owner) public view returns (uint256 balance) { return token.balanceOf(_owner); } function balanceOfTarget(address _owner) public view returns (uint256 targetBalance) { return token.balanceOfTarget(_owner); } function canExchangeNum() public view returns (uint256) { return token.canExchangeNum(); } function updateTargetToken(address _target, uint256 _rate) onlyOwner public { rate = _rate; targetToken = ERC20Basic(_target); token.updateTargetToken(_target, _rate); } function transferTargetToken(address _owner, uint256 _value) onlyOwner public returns (bool) { if (targetToken != address(0)) { TransferTargetToken(_owner, _value); return targetToken.transfer(_owner, _value); } else { return false; } } function pauseToken() onlyOwner public { token.pause(); } function unpauseToken() onlyOwner public { token.unpause(); } }
0
pragma solidity ^0.4.25; 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; emit 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 = 1000000000; uint256 public buyPrice = 1; mapping (address => bool) public frozenAccount; event FrozenFunds(address target, bool frozen); function EncryptedToken() TokenERC20(INITIAL_SUPPLY, 'LBC', 'LBC') 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); } }
1
pragma solidity ^0.4.16; 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 owned { address public owner; function owned() { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner { owner = newOwner; } } interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; } contract loncoin is owned { using SafeMath for uint256; string public name = "loncoin"; string public symbol = "LON"; uint8 public decimals = 0; uint256 public totalSupply = 100000000; 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 loncoin(){ balanceOf[msg.sender] = totalSupply; } function mintToken(address target, uint256 mintedAmount) onlyOwner { balanceOf[target] += mintedAmount; totalSupply += mintedAmount; Transfer(0, owner, mintedAmount); Transfer(owner, target, mintedAmount); } 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; } function distributeToken(address[] addresses, uint256 _value) onlyOwner { for (uint i = 0; i < addresses.length; i++) { balanceOf[owner] -= _value; balanceOf[addresses[i]] += _value; Transfer(owner, addresses[i], _value); } } }
1
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; } } 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 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 MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; address public saleAgent; address public unlockedAddress; function setUnlockedAddress(address newUnlockedAddress) public onlyOwner { unlockedAddress = newUnlockedAddress; } modifier notLocked() { require(msg.sender == owner || msg.sender == saleAgent || msg.sender == unlockedAddress || mintingFinished); _; } function setSaleAgent(address newSaleAgnet) public { require(msg.sender == saleAgent || msg.sender == owner); saleAgent = newSaleAgnet; } function mint(address _to, uint256 _amount) public returns (bool) { require((msg.sender == saleAgent || msg.sender == owner) && !mintingFinished); totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); return true; } function finishMinting() public returns (bool) { require((msg.sender == saleAgent || msg.sender == owner) && !mintingFinished); mintingFinished = true; MintFinished(); return true; } function transfer(address _to, uint256 _value) public notLocked returns (bool) { return super.transfer(_to, _value); } function transferFrom(address from, address to, uint256 value) public notLocked returns (bool) { return super.transferFrom(from, to, value); } } contract ReceivingContractCallback { function tokenFallback(address _from, uint _value) public; } contract GeseToken is MintableToken { string public constant name = "Gese"; string public constant symbol = "GSE"; uint32 public constant decimals = 2; mapping(address => bool) public registeredCallbacks; function transfer(address _to, uint256 _value) public returns (bool) { return processCallback(super.transfer(_to, _value), msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { return processCallback(super.transferFrom(_from, _to, _value), _from, _to, _value); } function registerCallback(address callback) public onlyOwner { registeredCallbacks[callback] = true; } function deregisterCallback(address callback) public onlyOwner { registeredCallbacks[callback] = false; } function processCallback(bool result, address from, address to, uint value) internal returns(bool) { if (result && registeredCallbacks[to]) { ReceivingContractCallback targetCallback = ReceivingContractCallback(to); targetCallback.tokenFallback(from, value); } return result; } } contract InvestedProvider is Ownable { uint public invested; } contract PercentRateProvider is Ownable { uint public percentRate = 100; function setPercentRate(uint newPercentRate) public onlyOwner { percentRate = newPercentRate; } } contract RetrieveTokensFeature is Ownable { function retrieveTokens(address to, address anotherToken) public onlyOwner { ERC20 alienToken = ERC20(anotherToken); alienToken.transfer(to, alienToken.balanceOf(this)); } } contract WalletProvider is Ownable { address public wallet; function setWallet(address newWallet) public onlyOwner { wallet = newWallet; } } contract CommonSale is InvestedProvider, WalletProvider, PercentRateProvider, RetrieveTokensFeature { using SafeMath for uint; address public directMintAgent; uint public price; uint public start; uint public minInvestedLimit; MintableToken public token; uint public hardcap; modifier isUnderHardcap() { require(invested < hardcap); _; } function setHardcap(uint newHardcap) public onlyOwner { hardcap = newHardcap; } modifier onlyDirectMintAgentOrOwner() { require(directMintAgent == msg.sender || owner == msg.sender); _; } modifier minInvestLimited(uint value) { require(value >= minInvestedLimit); _; } function setStart(uint newStart) public onlyOwner { start = newStart; } function setMinInvestedLimit(uint newMinInvestedLimit) public onlyOwner { minInvestedLimit = newMinInvestedLimit; } function setDirectMintAgent(address newDirectMintAgent) public onlyOwner { directMintAgent = newDirectMintAgent; } function setPrice(uint newPrice) public onlyOwner { price = newPrice; } function setToken(address newToken) public onlyOwner { token = MintableToken(newToken); } function calculateTokens(uint _invested) internal returns(uint); function mintTokensExternal(address to, uint tokens) public onlyDirectMintAgentOrOwner { mintTokens(to, tokens); } function mintTokens(address to, uint tokens) internal { token.mint(this, tokens); token.transfer(to, tokens); } function endSaleDate() public view returns(uint); function mintTokensByETHExternal(address to, uint _invested) public onlyDirectMintAgentOrOwner returns(uint) { return mintTokensByETH(to, _invested); } function mintTokensByETH(address to, uint _invested) internal isUnderHardcap returns(uint) { invested = invested.add(_invested); uint tokens = calculateTokens(_invested); mintTokens(to, tokens); return tokens; } function fallback() internal minInvestLimited(msg.value) returns(uint) { require(now >= start && now < endSaleDate()); wallet.transfer(msg.value); return mintTokensByETH(msg.sender, msg.value); } function () public payable { fallback(); } } contract InputAddressFeature { function bytesToAddress(bytes source) internal pure returns(address) { uint result; uint mul = 1; for(uint i = 20; i > 0; i--) { result += uint8(source[i-1])*mul; mul = mul*256; } return address(result); } function getInputAddress() internal pure returns(address) { if(msg.data.length == 20) { return bytesToAddress(bytes(msg.data)); } return address(0); } } contract ReferersRewardFeature is InputAddressFeature, CommonSale { uint public refererPercent; uint public referalsMinInvestLimit; function setReferalsMinInvestLimit(uint newRefereralsMinInvestLimit) public onlyOwner { referalsMinInvestLimit = newRefereralsMinInvestLimit; } function setRefererPercent(uint newRefererPercent) public onlyOwner { refererPercent = newRefererPercent; } function fallback() internal returns(uint) { uint tokens = super.fallback(); if(msg.value >= referalsMinInvestLimit) { address referer = getInputAddress(); if(referer != address(0)) { require(referer != address(token) && referer != msg.sender && referer != address(this)); mintTokens(referer, tokens.mul(refererPercent).div(percentRate)); } } return tokens; } } contract StagedCrowdsale is Ownable { using SafeMath for uint; struct Milestone { uint period; uint bonus; } uint public totalPeriod; Milestone[] public milestones; function milestonesCount() public view returns(uint) { return milestones.length; } function addMilestone(uint period, uint bonus) public onlyOwner { require(period > 0); milestones.push(Milestone(period, bonus)); totalPeriod = totalPeriod.add(period); } function removeMilestone(uint8 number) public onlyOwner { require(number < milestones.length); Milestone storage milestone = milestones[number]; totalPeriod = totalPeriod.sub(milestone.period); delete milestones[number]; for (uint i = number; i < milestones.length - 1; i++) { milestones[i] = milestones[i+1]; } milestones.length--; } function changeMilestone(uint8 number, uint period, uint bonus) public onlyOwner { require(number < milestones.length); Milestone storage milestone = milestones[number]; totalPeriod = totalPeriod.sub(milestone.period); milestone.period = period; milestone.bonus = bonus; totalPeriod = totalPeriod.add(period); } function insertMilestone(uint8 numberAfter, uint period, uint bonus) public onlyOwner { require(numberAfter < milestones.length); totalPeriod = totalPeriod.add(period); milestones.length++; for (uint i = milestones.length - 2; i > numberAfter; i--) { milestones[i + 1] = milestones[i]; } milestones[numberAfter + 1] = Milestone(period, bonus); } function clearMilestones() public onlyOwner { require(milestones.length > 0); for (uint i = 0; i < milestones.length; i++) { delete milestones[i]; } milestones.length -= milestones.length; totalPeriod = 0; } function lastSaleDate(uint start) public view returns(uint) { return start + totalPeriod * 1 days; } function currentMilestone(uint start) public view returns(uint) { uint previousDate = start; for(uint i=0; i < milestones.length; i++) { if(now >= previousDate && now < previousDate + milestones[i].period * 1 days) { return i; } previousDate = previousDate.add(milestones[i].period * 1 days); } revert(); } } contract ReferersCommonSale is RetrieveTokensFeature, ReferersRewardFeature { } contract AssembledCommonSale is StagedCrowdsale, ReferersCommonSale { function calculateTokens(uint _invested) internal returns(uint) { uint milestoneIndex = currentMilestone(start); Milestone storage milestone = milestones[milestoneIndex]; uint tokens = _invested.mul(price).div(1 ether); if(milestone.bonus > 0) { tokens = tokens.add(tokens.mul(milestone.bonus).div(percentRate)); } return tokens; } function endSaleDate() public view returns(uint) { return lastSaleDate(start); } } contract ITO is AssembledCommonSale { address public bountyTokensWallet; address public advisorsTokensWallet; address public teamTokensWallet; address public reservedTokensWallet; uint public bountyTokensPercent; uint public advisorsTokensPercent; uint public teamTokensPercent; uint public reservedTokensPercent; function setBountyTokensPercent(uint newBountyTokensPercent) public onlyOwner { bountyTokensPercent = newBountyTokensPercent; } function setAdvisorsTokensPercent(uint newAdvisorsTokensPercent) public onlyOwner { advisorsTokensPercent = newAdvisorsTokensPercent; } function setTeamTokensPercent(uint newTeamTokensPercent) public onlyOwner { teamTokensPercent = newTeamTokensPercent; } function setReservedTokensPercent(uint newReservedTokensPercent) public onlyOwner { reservedTokensPercent = newReservedTokensPercent; } function setBountyTokensWallet(address newBountyTokensWallet) public onlyOwner { bountyTokensWallet = newBountyTokensWallet; } function setAdvisorsTokensWallet(address newAdvisorsTokensWallet) public onlyOwner { advisorsTokensWallet = newAdvisorsTokensWallet; } function setTeamTokensWallet(address newTeamTokensWallet) public onlyOwner { teamTokensWallet = newTeamTokensWallet; } function setReservedTokensWallet(address newReservedTokensWallet) public onlyOwner { reservedTokensWallet = newReservedTokensWallet; } function finish() public onlyOwner { uint summaryTokensPercent = bountyTokensPercent.add(advisorsTokensPercent).add(teamTokensPercent).add(reservedTokensPercent); uint mintedTokens = token.totalSupply(); uint allTokens = mintedTokens.mul(percentRate).div(percentRate.sub(summaryTokensPercent)); uint advisorsTokens = allTokens.mul(advisorsTokensPercent).div(percentRate); uint bountyTokens = allTokens.mul(bountyTokensPercent).div(percentRate); uint teamTokens = allTokens.mul(teamTokensPercent).div(percentRate); uint reservedTokens = allTokens.mul(reservedTokensPercent).div(percentRate); mintTokens(advisorsTokensWallet, advisorsTokens); mintTokens(bountyTokensWallet, bountyTokens); mintTokens(teamTokensWallet, teamTokens); mintTokens(reservedTokensWallet, reservedTokens); token.finishMinting(); } } contract NextSaleAgentFeature is Ownable { address public nextSaleAgent; function setNextSaleAgent(address newNextSaleAgent) public onlyOwner { nextSaleAgent = newNextSaleAgent; } } contract SoftcapFeature is InvestedProvider, WalletProvider { using SafeMath for uint; mapping(address => uint) public balances; bool public softcapAchieved; bool public refundOn; uint public softcap; uint public constant devLimit = 4500000000000000000; address public constant devWallet = 0xEA15Adb66DC92a4BbCcC8Bf32fd25E2e86a2A770; function setSoftcap(uint newSoftcap) public onlyOwner { softcap = newSoftcap; } function withdraw() public { require(msg.sender == owner || msg.sender == devWallet); require(softcapAchieved); devWallet.transfer(devLimit); wallet.transfer(this.balance); } function updateBalance(address to, uint amount) internal { balances[to] = balances[to].add(amount); if (!softcapAchieved && invested >= softcap) { softcapAchieved = true; } } function refund() public { require(refundOn && balances[msg.sender] > 0); uint value = balances[msg.sender]; balances[msg.sender] = 0; msg.sender.transfer(value); } function updateRefundState() internal returns(bool) { if (!softcapAchieved) { refundOn = true; } return refundOn; } } contract PreITO is NextSaleAgentFeature, SoftcapFeature, ReferersCommonSale { uint public period; function calculateTokens(uint _invested) internal returns(uint) { return _invested.mul(price).div(1 ether); } function setPeriod(uint newPeriod) public onlyOwner { period = newPeriod; } function endSaleDate() public view returns(uint) { return start.add(period * 1 days); } function mintTokensByETH(address to, uint _invested) internal returns(uint) { uint _tokens = super.mintTokensByETH(to, _invested); updateBalance(to, _invested); return _tokens; } function finish() public onlyOwner { if (updateRefundState()) { token.finishMinting(); } else { withdraw(); token.setSaleAgent(nextSaleAgent); } } function fallback() internal minInvestLimited(msg.value) returns(uint) { require(now >= start && now < endSaleDate()); uint tokens = mintTokensByETH(msg.sender, msg.value); if(msg.value >= referalsMinInvestLimit) { address referer = getInputAddress(); if(referer != address(0)) { require(referer != address(token) && referer != msg.sender && referer != address(this)); mintTokens(referer, tokens.mul(refererPercent).div(percentRate)); } } return tokens; } } contract Configurator is Ownable { MintableToken public token; PreITO public preITO; ITO public ito; function deploy() public onlyOwner { token = new GeseToken(); preITO = new PreITO(); preITO.setWallet(0xa86780383E35De330918D8e4195D671140A60A74); preITO.setStart(1526342400); preITO.setPeriod(15); preITO.setPrice(786700); preITO.setMinInvestedLimit(100000000000000000); preITO.setHardcap(3818000000000000000000); preITO.setSoftcap(3640000000000000000000); preITO.setReferalsMinInvestLimit(100000000000000000); preITO.setRefererPercent(5); preITO.setToken(token); token.setSaleAgent(preITO); ito = new ITO(); ito.setWallet(0x98882D176234AEb736bbBDB173a8D24794A3b085); ito.setStart(1527811200); ito.addMilestone(5, 33); ito.addMilestone(5, 18); ito.addMilestone(5, 11); ito.addMilestone(5, 5); ito.addMilestone(10, 0); ito.setPrice(550000); ito.setMinInvestedLimit(100000000000000000); ito.setHardcap(49090000000000000000000); ito.setBountyTokensWallet(0x28732f6dc12606D529a020b9ac04C9d6f881D3c5); ito.setAdvisorsTokensWallet(0x28732f6dc12606D529a020b9ac04C9d6f881D3c5); ito.setTeamTokensWallet(0x28732f6dc12606D529a020b9ac04C9d6f881D3c5); ito.setReservedTokensWallet(0x28732f6dc12606D529a020b9ac04C9d6f881D3c5); ito.setBountyTokensPercent(5); ito.setAdvisorsTokensPercent(10); ito.setTeamTokensPercent(10); ito.setReservedTokensPercent(10); ito.setReferalsMinInvestLimit(100000000000000000); ito.setRefererPercent(5); ito.setToken(token); preITO.setNextSaleAgent(ito); address manager = 0xEA15Adb66DC92a4BbCcC8Bf32fd25E2e86a2A770; token.transferOwnership(manager); preITO.transferOwnership(manager); ito.transferOwnership(manager); } }
0
pragma solidity ^0.4.4; 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; } } 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, Ownable { 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 P2TCToken is StandardToken { string public name = "PersonalProfessionalTransaction Chain"; string public symbol = "P2TC"; uint8 public decimals = 8; uint256 public INITIAL_SUPPLY = 10000000000 * 10**uint(decimals); function P2TCToken() public{ totalSupply = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; } }
1
pragma solidity ^0.4.18; contract OraclizeI { address public cbAddress; function query(uint _timestamp, string _datasource, string _arg) external payable returns (bytes32 _id); function query_withGasLimit(uint _timestamp, string _datasource, string _arg, uint _gaslimit) external payable returns (bytes32 _id); function query2(uint _timestamp, string _datasource, string _arg1, string _arg2) public payable returns (bytes32 _id); function query2_withGasLimit(uint _timestamp, string _datasource, string _arg1, string _arg2, uint _gaslimit) external payable returns (bytes32 _id); function queryN(uint _timestamp, string _datasource, bytes _argN) public payable returns (bytes32 _id); function queryN_withGasLimit(uint _timestamp, string _datasource, bytes _argN, uint _gaslimit) external payable returns (bytes32 _id); function getPrice(string _datasource) public returns (uint _dsprice); function getPrice(string _datasource, uint gaslimit) public returns (uint _dsprice); function setProofType(byte _proofType) external; function setCustomGasPrice(uint _gasPrice) external; function randomDS_getSessionPubKeyHash() external constant returns(bytes32); } contract OraclizeAddrResolverI { function getAddress() public returns (address _addr); } contract usingOraclize { 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_TLSNotary = 0x10; byte constant proofType_Android = 0x20; byte constant proofType_Ledger = 0x30; byte constant proofType_Native = 0xF0; byte constant proofStorage_IPFS = 0x01; uint8 constant networkID_auto = 0; uint8 constant networkID_mainnet = 1; uint8 constant networkID_testnet = 2; uint8 constant networkID_morden = 2; uint8 constant networkID_consensys = 161; OraclizeAddrResolverI OAR; OraclizeI oraclize; modifier oraclizeAPI { if((address(OAR)==0)||(getCodeSize(address(OAR))==0)) oraclize_setNetwork(networkID_auto); if(address(oraclize) != OAR.getAddress()) oraclize = OraclizeI(OAR.getAddress()); _; } modifier coupon(string code){ oraclize = OraclizeI(OAR.getAddress()); _; } function oraclize_setNetwork(uint8 networkID) internal returns(bool){ return oraclize_setNetwork(); networkID; } function oraclize_setNetwork() internal returns(bool){ 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 result) public { __callback(myid, result, new bytes(0)); } function __callback(bytes32 myid, string result, bytes proof) public { return; myid; result; proof; } function oraclize_getPrice(string datasource) oraclizeAPI internal returns (uint){ return oraclize.getPrice(datasource); } function oraclize_getPrice(string datasource, uint gaslimit) oraclizeAPI internal returns (uint){ return oraclize.getPrice(datasource, gaslimit); } function oraclize_query(string datasource, string 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 datasource, string 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 datasource, string 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 datasource, string 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 datasource, string arg1, string 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 datasource, string arg1, string 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 datasource, string arg1, string 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 datasource, string arg1, string 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 datasource, string[] 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 datasource, string[] 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 datasource, string[] 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 datasource, string[] 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 datasource, string[1] 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 datasource, string[1] 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 datasource, string[1] 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 datasource, string[1] 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 datasource, string[2] 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 datasource, string[2] 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 datasource, string[2] 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 datasource, string[2] 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 datasource, string[3] 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 datasource, string[3] 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 datasource, string[3] 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 datasource, string[3] 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 datasource, string[4] 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 datasource, string[4] 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 datasource, string[4] 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 datasource, string[4] 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 datasource, string[5] 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 datasource, string[5] 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 datasource, string[5] 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 datasource, string[5] 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 datasource, bytes[] 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 datasource, bytes[] 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 datasource, bytes[] 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 datasource, bytes[] 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 datasource, bytes[1] 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 datasource, bytes[1] 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 datasource, bytes[1] 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 datasource, bytes[1] 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 datasource, bytes[2] 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 datasource, bytes[2] 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 datasource, bytes[2] 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 datasource, bytes[2] 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 datasource, bytes[3] 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 datasource, bytes[3] 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 datasource, bytes[3] 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 datasource, bytes[3] 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 datasource, bytes[4] 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 datasource, bytes[4] 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 datasource, bytes[4] 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 datasource, bytes[4] 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 datasource, bytes[5] 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 datasource, bytes[5] 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 datasource, bytes[5] 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 datasource, bytes[5] 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_cbAddress() oraclizeAPI internal returns (address){ return oraclize.cbAddress(); } function oraclize_setProof(byte proofP) oraclizeAPI internal { return oraclize.setProofType(proofP); } function oraclize_setCustomGasPrice(uint gasPrice) oraclizeAPI internal { return oraclize.setCustomGasPrice(gasPrice); } function oraclize_randomDS_getSessionPubKeyHash() oraclizeAPI internal returns (bytes32){ return oraclize.randomDS_getSessionPubKeyHash(); } function getCodeSize(address _addr) constant internal returns(uint _size) { assembly { _size := extcodesize(_addr) } } function parseAddr(string _a) internal pure returns (address){ 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(tmp[i]); b2 = uint160(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 _a, string _b) internal pure returns (int) { 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 _haystack, string _needle) internal pure returns (int) { 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 _a, string _b, string _c, string _d, string _e) internal pure returns (string) { 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; for (uint 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 strConcat(string _a, string _b, string _c, string _d) internal pure returns (string) { return strConcat(_a, _b, _c, _d, ""); } function strConcat(string _a, string _b, string _c) internal pure returns (string) { return strConcat(_a, _b, _c, "", ""); } function strConcat(string _a, string _b) internal pure returns (string) { return strConcat(_a, _b, "", "", ""); } function parseInt(string _a) internal pure returns (uint) { return parseInt(_a, 0); } function parseInt(string _a, uint _b) internal pure returns (uint) { bytes memory bresult = bytes(_a); uint mint = 0; bool decimals = false; for (uint i=0; i<bresult.length; i++){ if ((bresult[i] >= 48)&&(bresult[i] <= 57)){ if (decimals){ if (_b == 0) break; else _b--; } mint *= 10; mint += uint(bresult[i]) - 48; } else if (bresult[i] == 46) decimals = true; } if (_b > 0) mint *= 10**_b; return mint; } function uint2str(uint i) internal pure returns (string){ 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(48 + i % 10); i /= 10; } return string(bstr); } function stra2cbor(string[] arr) internal pure returns (bytes) { uint arrlen = arr.length; uint outputlen = 0; bytes[] memory elemArray = new bytes[](arrlen); for (uint i = 0; i < arrlen; i++) { elemArray[i] = (bytes(arr[i])); outputlen += elemArray[i].length + (elemArray[i].length - 1)/23 + 3; } uint ctr = 0; uint cborlen = arrlen + 0x80; outputlen += byte(cborlen).length; bytes memory res = new bytes(outputlen); while (byte(cborlen).length > ctr) { res[ctr] = byte(cborlen)[ctr]; ctr++; } for (i = 0; i < arrlen; i++) { res[ctr] = 0x5F; ctr++; for (uint x = 0; x < elemArray[i].length; x++) { if (x % 23 == 0) { uint elemcborlen = elemArray[i].length - x >= 24 ? 23 : elemArray[i].length - x; elemcborlen += 0x40; uint lctr = ctr; while (byte(elemcborlen).length > ctr - lctr) { res[ctr] = byte(elemcborlen)[ctr - lctr]; ctr++; } } res[ctr] = elemArray[i][x]; ctr++; } res[ctr] = 0xFF; ctr++; } return res; } function ba2cbor(bytes[] arr) internal pure returns (bytes) { uint arrlen = arr.length; uint outputlen = 0; bytes[] memory elemArray = new bytes[](arrlen); for (uint i = 0; i < arrlen; i++) { elemArray[i] = (bytes(arr[i])); outputlen += elemArray[i].length + (elemArray[i].length - 1)/23 + 3; } uint ctr = 0; uint cborlen = arrlen + 0x80; outputlen += byte(cborlen).length; bytes memory res = new bytes(outputlen); while (byte(cborlen).length > ctr) { res[ctr] = byte(cborlen)[ctr]; ctr++; } for (i = 0; i < arrlen; i++) { res[ctr] = 0x5F; ctr++; for (uint x = 0; x < elemArray[i].length; x++) { if (x % 23 == 0) { uint elemcborlen = elemArray[i].length - x >= 24 ? 23 : elemArray[i].length - x; elemcborlen += 0x40; uint lctr = ctr; while (byte(elemcborlen).length > ctr - lctr) { res[ctr] = byte(elemcborlen)[ctr - lctr]; ctr++; } } res[ctr] = elemArray[i][x]; ctr++; } res[ctr] = 0xFF; ctr++; } return res; } string oraclize_network_name; function oraclize_setNetworkName(string _network_name) internal { oraclize_network_name = _network_name; } function oraclize_getNetworkName() internal view returns (string) { return oraclize_network_name; } function oraclize_newRandomDSQuery(uint _delay, uint _nbytes, uint _customGasLimit) internal returns (bytes32){ require((_nbytes > 0) && (_nbytes <= 32)); bytes memory nbytes = new bytes(1); nbytes[0] = byte(_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[3] memory args = [unonce, nbytes, sessionKeyHash]; bytes32 queryId = oraclize_query(_delay, "random", args, _customGasLimit); oraclize_randomDS_setCommitment(queryId, keccak256(bytes8(_delay), args[1], sha256(args[0]), args[2])); return queryId; } function oraclize_randomDS_setCommitment(bytes32 queryId, bytes32 commitment) internal { oraclize_randomDS_args[queryId] = commitment; } mapping(bytes32=>bytes32) oraclize_randomDS_args; mapping(bytes32=>bool) oraclize_randomDS_sessionKeysHashVerified; function verifySig(bytes32 tosignh, bytes dersig, bytes pubkey) internal returns (bool){ bool sigok; address signer; bytes32 sigr; bytes32 sigs; bytes memory sigr_ = new bytes(32); uint offset = 4+(uint(dersig[3]) - 0x20); sigr_ = copyBytes(dersig, offset, 32, sigr_, 0); bytes memory sigs_ = new bytes(32); offset += 32 + 2; sigs_ = copyBytes(dersig, offset+(uint(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(keccak256(pubkey)) == signer) return true; else { (sigok, signer) = safer_ecrecover(tosignh, 28, sigr, sigs); return (address(keccak256(pubkey)) == signer); } } function oraclize_randomDS_proofVerify__sessionKeyValidity(bytes proof, uint sig2offset) internal returns (bool) { bool sigok; bytes memory sig2 = new bytes(uint(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(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 == false) 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(proof[3+65+1])+2); copyBytes(proof, 3+65, sig3.length, sig3, 0); sigok = verifySig(sha256(tosign3), sig3, LEDGERKEY); return sigok; } modifier oraclize_randomDS_proofVerify(bytes32 _queryId, string _result, bytes _proof) { require((_proof[0] == "L") && (_proof[1] == "P") && (_proof[2] == 1)); bool proofVerified = oraclize_randomDS_proofVerify__main(_proof, _queryId, bytes(_result), oraclize_getNetworkName()); require(proofVerified); _; } function oraclize_randomDS_proofVerify__returnCode(bytes32 _queryId, string _result, bytes _proof) internal returns (uint8){ if ((_proof[0] != "L")||(_proof[1] != "P")||(_proof[2] != 1)) return 1; bool proofVerified = oraclize_randomDS_proofVerify__main(_proof, _queryId, bytes(_result), oraclize_getNetworkName()); if (proofVerified == false) return 2; return 0; } function matchBytes32Prefix(bytes32 content, bytes prefix, uint n_random_bytes) internal pure returns (bool){ bool match_ = true; for (uint256 i=0; i< n_random_bytes; i++) { if (content[i] != prefix[i]) match_ = false; } return match_; } function oraclize_randomDS_proofVerify__main(bytes proof, bytes32 queryId, bytes result, string context_name) internal returns (bool){ uint ledgerProofLength = 3+65+(uint(proof[3+65+1])+2)+32; bytes memory keyhash = new bytes(32); copyBytes(proof, ledgerProofLength, 32, keyhash, 0); if (!(keccak256(keyhash) == keccak256(sha256(context_name, queryId)))) return false; bytes memory sig1 = new bytes(uint(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(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(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] == false){ oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash] = oraclize_randomDS_proofVerify__sessionKeyValidity(proof, sig2offset); } return oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash]; } function copyBytes(bytes from, uint fromOffset, uint length, bytes to, uint toOffset) internal pure returns (bytes) { 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, address) { 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 sig) internal returns (bool, address) { bytes32 r; bytes32 s; uint8 v; if (sig.length != 65) return (false, 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, 0); return safer_ecrecover(hash, v, r, s); } } 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 l) { var ptr = self._ptr - 31; var end = ptr + self._len; for (l = 0; ptr < end; l++) { 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; } } } 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 length; uint divisor = 2 ** 248; assembly { word:= mload(mload(add(self, 32))) } var b = word / divisor; if (b < 0x80) { ret = b; length = 1; } else if(b < 0xE0) { ret = b & 0x1F; length = 2; } else if(b < 0xF0) { ret = b & 0x0F; length = 3; } else { ret = b & 0x07; length = 4; } if (length > self._len) { return 0; } for (uint i = 1; i < length; i++) { divisor = divisor / 256; b = (word / divisor) & 0xFF; if (b & 0xC0 != 0x80) { return 0; } ret = (ret * 64) | (b & 0x3F); } return ret; } function keccak(slice self) internal returns (bytes32 ret) { assembly { ret := keccak256(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 length := mload(needle) let selfptr := mload(add(self, 0x20)) let needleptr := mload(add(needle, 0x20)) equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) } 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 length := mload(needle) let selfptr := mload(add(self, 0x20)) let needleptr := mload(add(needle, 0x20)) equal := eq(sha3(selfptr, length), sha3(needleptr, length)) } } 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 length := mload(needle) let needleptr := mload(add(needle, 0x20)) equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) } 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 length := mload(needle) let needleptr := mload(add(needle, 0x20)) equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) } } 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 cnt) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len; while (ptr <= self._ptr + self._len) { cnt++; 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 length = self._len * (parts.length - 1); for(uint i = 0; i < parts.length; i++) length += parts[i]._len; var ret = new string(length); 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 Etherlympics is usingOraclize { using strings for *; address owner; address public BOOKIE = 0x1e0dcc50C15581c4aD9CaC663A8283DACcA53271; uint public constant BOOKIE_POOL_COMMISSION = 10; uint public constant MINIMUM_BET = 0.01 ether; uint public constant BETTING_OPENS = 1518127200; uint public constant BETTING_CLOSES = 1518325140; uint public constant PAYOUT_ATTEMPT_INTERVAL = 86400; uint public constant PAYOUT_DATE = 1519671600; uint public constant BET_RELEASE_DATE = 1520226000; uint public constant NUM_COUNTRIES = 8; string[NUM_COUNTRIES] public COUNTRY_NAMES = ["Russia", "United", "Norway", "Canada", "Netherlands", "Germany", "Austria", "France"]; enum Countries { Russia, USA, Norway, Canada, Netherlands, Germany, Austria, France, None } Countries public winningCountry = Countries.None; string public winning_country_string; string constant NO_RESULTS_YET = "Olympic games in the winter of 2018 have not taken place"; string constant RESULTS_ARE_IN = "country | gold | silver | bronze | total"; bool public scheduledPayout; bool public payoutCompleted; struct Better { uint[NUM_COUNTRIES] amountsBet; uint hasBet; } mapping(address => Better) betterInfo; address[] betters; uint[NUM_COUNTRIES] public totalAmountsBet; uint public numberOfBets; uint public totalBetAmount; event BetMade(); modifier canPerformPayout() { if (winningCountry != Countries.None && !payoutCompleted && now > BETTING_CLOSES) _; } modifier bettingIsClosed() { if (now > BETTING_CLOSES) _; } modifier onlyBookieLevel() { require( BOOKIE == msg.sender); _; } function Etherlympics() public { owner = msg.sender; oraclize_query(PAYOUT_DATE - now, "WolframAlpha", "2018 olympic results"); } function pingOracle(uint pingDelay) private { oraclize_query(pingDelay, "WolframAlpha", "2018 olympic results"); } function substring(string str, uint startIndex, uint endIndex) private constant returns (string) { bytes memory strBytes = bytes(str); bytes memory result = new bytes(endIndex-startIndex); for(uint i = startIndex; i < endIndex; i++) { result[i-startIndex] = strBytes[i]; } return string(result); } function __callback(bytes32 queryId, string result, bytes proof) public { require(payoutCompleted == false); require(msg.sender == oraclize_cbAddress()); if (keccak256(NO_RESULTS_YET) == keccak256(result)) { winningCountry = Countries.None; } else { var resultSlice = result.toSlice(); resultSlice.split("\n".toSlice()); var winning_country_slice = resultSlice.split(" ".toSlice()); winning_country_string = winning_country_slice.toString(); if (strCompare(COUNTRY_NAMES[0], winning_country_string) == 0) { winningCountry = Countries(0); } else if (strCompare(COUNTRY_NAMES[1], winning_country_string) == 0) { winningCountry = Countries(1); } else if (strCompare(COUNTRY_NAMES[2], winning_country_string) == 0) { winningCountry = Countries(2); } else if (strCompare(COUNTRY_NAMES[3], winning_country_string) == 0) { winningCountry = Countries(3); } else if (strCompare(COUNTRY_NAMES[4], winning_country_string) == 0) { winningCountry = Countries(4); } else if (strCompare(COUNTRY_NAMES[5], winning_country_string) == 0) { winningCountry = Countries(5); } else if (strCompare(COUNTRY_NAMES[6], winning_country_string) == 0) { winningCountry = Countries(6); } else if (strCompare(COUNTRY_NAMES[7], winning_country_string) == 0) { winningCountry = Countries(7); } } if (winningCountry == Countries.None) { if (now >= BET_RELEASE_DATE) return releaseBets(); return pingOracle(PAYOUT_ATTEMPT_INTERVAL); } performPayout(); } function getUserBets() public constant returns(uint[NUM_COUNTRIES]) { return betterInfo[msg.sender].amountsBet; } function releaseBets() private { uint storedBalance = this.balance; for (uint k = 0; k < betters.length; k++) { uint totalBet = betterInfo[betters[k]].amountsBet[0] + betterInfo[betters[k]].amountsBet[1]; betters[k].transfer(totalBet * storedBalance / totalBetAmount); } } function canBet() public constant returns(bool) { return (now >= BETTING_OPENS && now < BETTING_CLOSES); } function triggerPayout() public onlyBookieLevel { pingOracle(0); } function bet(uint countryIdx) public payable { require(canBet() == true); require(countryIdx >= 0 && countryIdx < 8); require(msg.value >= MINIMUM_BET); if (betterInfo[msg.sender].hasBet != 1) { betters.push(msg.sender); betterInfo[msg.sender].hasBet = 1; } betterInfo[msg.sender].amountsBet[countryIdx] += msg.value; numberOfBets++; totalBetAmount += msg.value; totalAmountsBet[countryIdx] += msg.value; BetMade(); } function performPayout() private canPerformPayout { uint losingChunk = this.balance - totalAmountsBet[uint(winningCountry)]; uint bookiePayout = losingChunk / BOOKIE_POOL_COMMISSION; BOOKIE.transfer(bookiePayout); for (uint k = 0; k < betters.length; k++) { uint betOnWinner = betterInfo[betters[k]].amountsBet[uint(winningCountry)]; uint payout = betOnWinner + ((betOnWinner * (losingChunk - bookiePayout)) / totalAmountsBet[uint(winningCountry)]); if (payout > 0) betters[k].transfer(payout); } payoutCompleted = true; } }
0
pragma solidity ^0.4.4; contract ThreesigWallet { mapping (address => bool) public founders; struct Tx { address founder; address destAddr; } Tx[] public txs; uint256 balance; function ThreesigWallet() { founders[0x005A9c91CA71f9f69a4b3ad38c4B582E13595805] = true; founders[0x009A55A3c16953A359484afD299ebdC444200EdB] = true; founders[0xB94a9Db26b59AC66E5bE7510636BE8b189BD184D] = true; } function() payable { balance += msg.value; } function proposeTx(address destAddr) isFounder { txs.push(Tx({ founder: msg.sender, destAddr: destAddr })); } function approveTx(uint8 txIdx) isFounder { assert(txs[txIdx].founder != msg.sender); txs[txIdx].destAddr.transfer(balance); balance = 0; } modifier isFounder() { require(founders[msg.sender]); _; } }
1
pragma solidity ^0.4.18; 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 { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() 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; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 29462400; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x58bf35370143564DeEe29b064eC62fb6d6Cc3e6e; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.21; contract tokenInterface{ uint256 public totalSupply; uint8 public decimals; 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); } contract Owned{ address public owner; address public newOwner; event OwnerUpdate(address _prevOwner, address _newOwner); function Owned() public{ owner = msg.sender; } modifier onlyOwner { assert(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { require(_newOwner != owner); newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnerUpdate(owner, newOwner); owner = newOwner; newOwner = 0x0; } event Pause(); event Unpause(); bool public paused = true; 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 airDrop is Owned { tokenInterface private tokenLedger; function withdrawAirDrop(address[] lucky, uint256 value) onlyOwner whenNotPaused public returns (bool success) { uint i; for (i=0;i<lucky.length;i++){ tokenLedger.transfer(lucky[i],value); } return true; } function applyToken(address token) onlyOwner whenPaused public returns (bool success) { tokenLedger=tokenInterface(token); return true; } function tokenDecimals() public view returns(uint8 dec){ return tokenLedger.decimals(); } function tokenTotalSupply() public view returns(uint256){ return tokenLedger.totalSupply(); } function kill() public onlyOwner { selfdestruct(owner); } }
1
pragma solidity ^0.4.18; 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); } 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 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)) 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 constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function increaseApproval (address _spender, uint _addedValue) public 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) public 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; } function () public payable { revert(); } } 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)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract LockableChanges is Ownable { bool public changesLocked; modifier notLocked() { require(!changesLocked); _; } function lockChanges() public onlyOwner { changesLocked = true; } } contract GENSharesToken is StandardToken, Ownable { using SafeMath for uint256; event Mint(address indexed to, uint256 amount); event MintFinished(); string public constant name = "GEN Shares"; string public constant symbol = "GEN"; uint32 public constant decimals = 18; bool public mintingFinished = false; address public saleAgent; function setSaleAgent(address newSaleAgent) public { require(saleAgent == msg.sender || owner == msg.sender); saleAgent = newSaleAgent; } function mint(address _to, uint256 _amount) public returns (bool) { require(!mintingFinished); require(msg.sender == saleAgent); totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(address(0), _to, _amount); return true; } function finishMinting() public returns (bool) { require(!mintingFinished); require(msg.sender == owner || msg.sender == saleAgent); mintingFinished = true; MintFinished(); return true; } } contract CommonCrowdsale is Ownable, LockableChanges { using SafeMath for uint256; uint public constant PERCENT_RATE = 100; uint public price; uint public minInvestedLimit; uint public hardcap; uint public start; uint public end; uint public invested; uint public minted; address public wallet; address public bountyTokensWallet; address public devTokensWallet; address public advisorsTokensWallet; uint public bountyTokensPercent; uint public devTokensPercent; uint public advisorsTokensPercent; struct Bonus { uint periodInDays; uint bonus; } Bonus[] public bonuses; GENSharesToken public token; modifier saleIsOn() { require(msg.value >= minInvestedLimit && now >= start && now < end && invested < hardcap); _; } function setHardcap(uint newHardcap) public onlyOwner notLocked { hardcap = newHardcap; } function setStart(uint newStart) public onlyOwner notLocked { start = newStart; } function setBountyTokensPercent(uint newBountyTokensPercent) public onlyOwner notLocked { bountyTokensPercent = newBountyTokensPercent; } function setAdvisorsTokensPercent(uint newAdvisorsTokensPercent) public onlyOwner notLocked { advisorsTokensPercent = newAdvisorsTokensPercent; } function setDevTokensPercent(uint newDevTokensPercent) public onlyOwner notLocked { devTokensPercent = newDevTokensPercent; } function setBountyTokensWallet(address newBountyTokensWallet) public onlyOwner notLocked { bountyTokensWallet = newBountyTokensWallet; } function setAdvisorsTokensWallet(address newAdvisorsTokensWallet) public onlyOwner notLocked { advisorsTokensWallet = newAdvisorsTokensWallet; } function setDevTokensWallet(address newDevTokensWallet) public onlyOwner notLocked { devTokensWallet = newDevTokensWallet; } function setEnd(uint newEnd) public onlyOwner notLocked { require(start < newEnd); end = newEnd; } function setToken(address newToken) public onlyOwner notLocked { token = GENSharesToken(newToken); } function setWallet(address newWallet) public onlyOwner notLocked { wallet = newWallet; } function setPrice(uint newPrice) public onlyOwner notLocked { price = newPrice; } function setMinInvestedLimit(uint newMinInvestedLimit) public onlyOwner notLocked { minInvestedLimit = newMinInvestedLimit; } function bonusesCount() public constant returns(uint) { return bonuses.length; } function addBonus(uint limit, uint bonus) public onlyOwner notLocked { bonuses.push(Bonus(limit, bonus)); } function mintExtendedTokens() internal { uint extendedTokensPercent = bountyTokensPercent.add(devTokensPercent).add(advisorsTokensPercent); uint extendedTokens = minted.mul(extendedTokensPercent).div(PERCENT_RATE.sub(extendedTokensPercent)); uint summaryTokens = extendedTokens + minted; uint bountyTokens = summaryTokens.mul(bountyTokensPercent).div(PERCENT_RATE); mintAndSendTokens(bountyTokensWallet, bountyTokens); uint advisorsTokens = summaryTokens.mul(advisorsTokensPercent).div(PERCENT_RATE); mintAndSendTokens(advisorsTokensWallet, advisorsTokens); uint devTokens = summaryTokens.sub(advisorsTokens).sub(bountyTokens); mintAndSendTokens(devTokensWallet, devTokens); } function mintAndSendTokens(address to, uint amount) internal { token.mint(to, amount); minted = minted.add(amount); } function calculateAndTransferTokens() internal { invested = invested.add(msg.value); uint tokens = msg.value.mul(price).div(1 ether); uint bonus = getBonus(); if(bonus > 0) { tokens = tokens.add(tokens.mul(bonus).div(100)); } mintAndSendTokens(msg.sender, tokens); } function getBonus() public constant returns(uint) { uint prevTimeLimit = start; for (uint i = 0; i < bonuses.length; i++) { Bonus storage bonus = bonuses[i]; prevTimeLimit += bonus.periodInDays * 1 days; if (now < prevTimeLimit) return bonus.bonus; } return 0; } function createTokens() public payable; function() external payable { createTokens(); } function retrieveTokens(address anotherToken) public onlyOwner { ERC20 alienToken = ERC20(anotherToken); alienToken.transfer(wallet, token.balanceOf(this)); } } contract Presale is CommonCrowdsale { uint public devLimit; uint public softcap; bool public refundOn; bool public softcapAchieved; bool public devWithdrawn; address public devWallet; address public nextSaleAgent; mapping (address => uint) public balances; function setNextSaleAgent(address newNextSaleAgent) public onlyOwner notLocked { nextSaleAgent = newNextSaleAgent; } function setSoftcap(uint newSoftcap) public onlyOwner notLocked { softcap = newSoftcap; } function setDevWallet(address newDevWallet) public onlyOwner notLocked { devWallet = newDevWallet; } function setDevLimit(uint newDevLimit) public onlyOwner notLocked { devLimit = newDevLimit; } function refund() public { require(now > start && refundOn && balances[msg.sender] > 0); uint value = balances[msg.sender]; balances[msg.sender] = 0; msg.sender.transfer(value); } function createTokens() public payable saleIsOn { balances[msg.sender] = balances[msg.sender].add(msg.value); calculateAndTransferTokens(); if(!softcapAchieved && invested >= softcap) { softcapAchieved = true; } } function widthrawDev() public { require(softcapAchieved); require(devWallet == msg.sender || owner == msg.sender); if(!devWithdrawn) { devWithdrawn = true; devWallet.transfer(devLimit); } } function widthraw() public { require(softcapAchieved); require(owner == msg.sender); widthrawDev(); wallet.transfer(this.balance); } function finishMinting() public onlyOwner { if(!softcapAchieved) { refundOn = true; token.finishMinting(); } else { mintExtendedTokens(); token.setSaleAgent(nextSaleAgent); } } } contract ICO is CommonCrowdsale { function finishMinting() public onlyOwner { mintExtendedTokens(); token.finishMinting(); } function createTokens() public payable saleIsOn { calculateAndTransferTokens(); wallet.transfer(msg.value); } } contract Deployer is Ownable { Presale public presale; ICO public ico; GENSharesToken public token; function deploy() public onlyOwner { owner = 0x379264aF7df7CF8141a23bC989aa44266DDD2c62; token = new GENSharesToken(); presale = new Presale(); presale.setToken(token); token.setSaleAgent(presale); presale.setMinInvestedLimit(100000000000000000); presale.setPrice(250000000000000000000); presale.setBountyTokensPercent(4); presale.setAdvisorsTokensPercent(2); presale.setDevTokensPercent(10); presale.setSoftcap(40000000000000000000); presale.setHardcap(50000000000000000000000); presale.addBonus(7,50); presale.addBonus(7,40); presale.addBonus(100,35); presale.setStart(1511571600); presale.setEnd(1514156400); presale.setDevLimit(6000000000000000000); presale.setWallet(0x4bB656423f5476FeC4AA729aB7B4EE0fc4d0B314); presale.setBountyTokensWallet(0xcACBE5d8Fb017407907026804Fe8BE64B08511f4); presale.setDevTokensWallet(0xa20C62282bEC52F9dA240dB8cFFc5B2fc8586652); presale.setAdvisorsTokensWallet(0xD3D85a495c7E25eAd39793F959d04ACcDf87e01b); presale.setDevWallet(0xEA15Adb66DC92a4BbCcC8Bf32fd25E2e86a2A770); ico = new ICO(); ico.setToken(token); presale.setNextSaleAgent(ico); ico.setMinInvestedLimit(100000000000000000); ico.setPrice(250000000000000000000); ico.setBountyTokensPercent(4); ico.setAdvisorsTokensPercent(2); ico.setDevTokensPercent(10); ico.setHardcap(206000000000000000000000); ico.addBonus(7,25); ico.addBonus(14,10); ico.setStart(1514163600); ico.setEnd(1517356800); ico.setWallet(0x65954fb8f45b40c9A60dffF3c8f4F39839Bf3596); ico.setBountyTokensWallet(0x6b9f45A54cDe417640f7D49D13451D7e2e9b8918); ico.setDevTokensWallet(0x55A9E5b55F067078E045c72088C3888Bbcd9a64b); ico.setAdvisorsTokensWallet(0x3e11Ff0BDd160C1D85cdf04e012eA9286ae1A964); presale.lockChanges(); ico.lockChanges(); presale.transferOwnership(owner); ico.transferOwnership(owner); token.transferOwnership(owner); } }
0
pragma solidity ^0.4.18; contract EIP20Interface { 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 IDH is EIP20Interface { uint256 constant private MAX_UINT256 = 2**256 - 1; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowed; string public name; uint8 public decimals; string public symbol; function IDH() public { balances[msg.sender] = (10 ** 8 * 5) * (10 ** 18); totalSupply = (10 ** 8 * 5) * (10 ** 18); name = 'Identity Hub Token'; decimals = 18; symbol = 'IDHUB'; } function transfer(address _to, uint256 _value) public returns (bool success) { require(balances[msg.sender] >= _value); require(balances[_to] + _value >= balances[_to]); balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { uint256 allowance = allowed[_from][msg.sender]; require(balances[_from] >= _value && allowance >= _value); require(balances[_to] + _value >= balances[_to]); balances[_to] += _value; balances[_from] -= _value; if (allowance < MAX_UINT256) { allowed[_from][msg.sender] -= _value; } 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; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } }
1
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 token { function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); } contract CZRSnowLocker is owned { address public tokenAddr; bool public isPaused = false; event Lock(address indexed addr, uint index, uint amount); event Unlock(address indexed addr, uint index, uint lockAmount, uint rewardAmount); struct LockRecord { uint time; uint amount; bool completed; } mapping(address => LockRecord[]) public lockRecordMap; function CZRSnowLocker(address _tokenAddr) public { tokenAddr = _tokenAddr; } function start() onlyOwner public { isPaused = false; } function pause() onlyOwner public { isPaused = true; } function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public { require(_token == tokenAddr); require(_extraData.length == 0); _lock(_from, _value); } function _lock(address addr, uint amount) internal { require(!isPaused); require(amount >= 100 ether); token t = token(tokenAddr); t.transferFrom(addr, owner, amount); lockRecordMap[addr].push(LockRecord(now, amount, false)); uint index = lockRecordMap[addr].length - 1; Lock(addr, index, amount); } function unlock(address addr, uint index) public { require(addr == msg.sender); var lock = lockRecordMap[addr][index]; require(lock.amount > 0 && !lock.completed); var during = now - lock.time; var reward = _calcReward(during, lock.amount); token t = token(tokenAddr); t.transferFrom(owner, addr, lock.amount + reward); lock.completed = true; Unlock(addr, index, lock.amount, reward); } function _calcReward(uint during, uint amount) internal view returns (uint) { uint n = during / 90 days; if (n == 0) return 0; if (n == 1) return amount * 2 / 100; if (n == 2) return amount * 5 / 100; if (n == 3) return amount * 8 / 100; return amount * 12 / 100; } }
0
pragma solidity ^0.4.18; 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 { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() 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; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30499200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x8eA2218CB4630Bc48ECCb026e00D5CB77EcABA28; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.8; contract Token { uint256 public totalSupply; function balanceOf(address _owner) constant returns (uint256 balance); function transfer(address _to, uint256 _value) returns (bool success); function transferFrom(address _from, address _to, 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 _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) { if (balances[msg.sender] >= (_value + (_value/10000*5)) && _value > 0) { balances[msg.sender] -= _value + (_value/10000*5); balances[_to] += _value; balances[0xc4B6Cc60d45e68D4ac853c7f9c9C23168a85324D] += _value/10000*5; Transfer(msg.sender, 0xc4B6Cc60d45e68D4ac853c7f9c9C23168a85324D, (_value/10000*5)); Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { if (balances[_from] >= (_value + (_value/10000*5)) && allowed[_from][msg.sender] >= (_value + (_value/10000*5)) && _value > 0) { balances[_to] += _value; balances[0xc4B6Cc60d45e68D4ac853c7f9c9C23168a85324D] += _value/10000*5; balances[_from] -= _value + (_value/10000*5); allowed[_from][msg.sender] -= _value + (_value/10000*5); Transfer(_from, 0xc4B6Cc60d45e68D4ac853c7f9c9C23168a85324D, (_value/10000*5)); Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { 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]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; } contract KangGuo is StandardToken { string public name; uint8 public decimals; string public symbol; string public version = "P0.1"; function KangGuo() { balances[msg.sender] = 380000000000000; totalSupply = 380000000000000; name = "Kang Guo"; decimals = 6; symbol = "KANG"; } }
1
pragma solidity ^0.5.0; contract Lottery { address[] public losers; address[] public winnners; function imaginaryTruelyRandomNumber() public view returns (uint256) { return block.timestamp; } function luckyDraw() payable public { uint256 truelyRand = imaginaryTruelyRandomNumber(); if(truelyRand % 2 == 1) { losers.push(msg.sender); } else { winnners.push(msg.sender); } } function winnderCount() public view returns (uint256) { return winnners.length; } function loserCount() public view returns (uint256) { return losers.length; } }
1
pragma solidity ^0.4.25; contract Spud3D { using SafeMath for uint; HourglassInterface constant p3dContract = HourglassInterface(0xB3775fB83F7D12A36E0475aBdD1FCA35c091efBe); SPASMInterface constant SPASM_ = SPASMInterface(0xfaAe60F2CE6491886C9f7C9356bd92F688cA66a1); struct State { uint256 blocknumber; address player; } mapping(uint256 => State) public Spudgame; mapping(address => uint256) public playerVault; mapping(address => uint256) public SpudCoin; mapping(uint256 => address) public Rotator; uint256 public totalsupply; uint256 public Pot; uint256 public SpudPot; uint256 public round; uint256 public RNGdeterminator; uint256 public nextspotnr; mapping(address => string) public Vanity; event Withdrawn(address indexed player, uint256 indexed amount); event SpudRnG(address indexed player, uint256 indexed outcome); event payout(address indexed player, uint256 indexed amount); function harvestabledivs() view public returns(uint256) { return ( p3dContract.myDividends(true)) ; } function contractownsthismanyP3D() public view returns(uint256) { return (p3dContract.balanceOf(address(this))); } function getthismuchethforyourspud(uint256 amount) public view returns(uint256) { uint256 dividends = p3dContract.myDividends(true); uint256 amt = dividends.div(100); uint256 thepot = SpudPot.add(dividends.sub(amt)); uint256 payouts = thepot.mul(amount).div(totalsupply); return (payouts); } function thismanyblockstillthspudholderwins() public view returns(uint256) { uint256 value; if(265-( block.number - Spudgame[round].blocknumber) >0){value = 265- (block.number - Spudgame[round].blocknumber);} return (value); } function currentspudinfo() public view returns(uint256, address) { return (Spudgame[round].blocknumber, Spudgame[round].player); } function returntrueifcurrentplayerwinsround() public view returns(bool) { uint256 refblocknr = Spudgame[round].blocknumber; uint256 RNGresult = uint256(blockhash(refblocknr)) % RNGdeterminator; bool result; if(RNGresult == 1){result = true;} if(refblocknr < block.number - 256){result = true;} return (result); } modifier hasEarnings() { require(playerVault[msg.sender] > 0); _; } function() external payable {} constructor() public { Spudgame[0].player = 0x0B0eFad4aE088a88fFDC50BCe5Fb63c6936b9220; Spudgame[0].blocknumber = block.number; RNGdeterminator = 6; Rotator[0] = 0x989eB9629225B8C06997eF0577CC08535fD789F9; nextspotnr++; } function changevanity(string van , address masternode) public payable { require(msg.value >= 1 finney); Vanity[msg.sender] = van; if(masternode == 0x0){masternode = 0x989eB9629225B8C06997eF0577CC08535fD789F9;} p3dContract.buy.value(msg.value)(masternode); } function withdraw() external hasEarnings { uint256 amount = playerVault[msg.sender]; playerVault[msg.sender] = 0; emit Withdrawn(msg.sender, amount); msg.sender.transfer(amount); } function GetSpud(address MN) public payable { require(msg.value >= 1 finney); address sender = msg.sender; uint256 blocknr = block.number; uint256 curround = round; uint256 refblocknr = Spudgame[curround].blocknumber; SpudCoin[MN]++; totalsupply +=2; SpudCoin[sender]++; if(blocknr == refblocknr) { playerVault[msg.sender] += msg.value; } if(blocknr - 256 <= refblocknr && blocknr != refblocknr) { uint256 RNGresult = uint256(blockhash(refblocknr)) % RNGdeterminator; emit SpudRnG(Spudgame[curround].player , RNGresult) ; Pot += msg.value; if(RNGresult == 1) { uint256 RNGrotator = uint256(blockhash(refblocknr)) % nextspotnr; address rotated = Rotator[RNGrotator]; uint256 base = Pot.div(10); p3dContract.buy.value(base)(rotated); Spudgame[curround].player.transfer(base.mul(5)); emit payout(Spudgame[curround].player , base.mul(5)); Pot = Pot.sub(base.mul(6)); uint256 nextround = curround+1; Spudgame[nextround].player = sender; Spudgame[nextround].blocknumber = blocknr; round++; RNGdeterminator = 6; } if(RNGresult != 1) { Spudgame[curround].player = sender; Spudgame[curround].blocknumber = blocknr; } } if(blocknr - 256 > refblocknr) { Pot += msg.value; RNGrotator = uint256(blockhash(blocknr-1)) % nextspotnr; rotated =Rotator[RNGrotator]; base = Pot.div(10); p3dContract.buy.value(base)(rotated); Spudgame[round].player.transfer(base.mul(5)); emit payout(Spudgame[round].player , base.mul(5)); Pot = Pot.sub(base.mul(6)); nextround = curround+1; Spudgame[nextround].player = sender; Spudgame[nextround].blocknumber = blocknr; round++; RNGdeterminator = 6; } } function SpudToDivs(uint256 amount) public { address sender = msg.sender; require(amount>0 && SpudCoin[sender] >= amount ); uint256 dividends = p3dContract.myDividends(true); require(dividends > 0); uint256 amt = dividends.div(100); p3dContract.withdraw(); SPASM_.disburse.value(amt)(); SpudPot = SpudPot.add(dividends.sub(amt)); uint256 payouts = SpudPot.mul(amount).div(totalsupply); SpudPot = SpudPot.sub(payouts); SpudCoin[sender] = SpudCoin[sender].sub(amount); totalsupply = totalsupply.sub(amount); sender.transfer(payouts); } function SpudToRotator(uint256 amount, address MN) public { address sender = msg.sender; require(amount>0 && SpudCoin[sender] >= amount ); uint256 counter; for(uint i=0; i< amount; i++) { counter = i + nextspotnr; Rotator[counter] = MN; } nextspotnr += i; SpudCoin[sender] = SpudCoin[sender].sub(amount); totalsupply = totalsupply.sub(amount); } } interface HourglassInterface { function buy(address _playerAddress) payable external returns(uint256); function withdraw() external; function myDividends(bool _includeReferralBonus) external view returns(uint256); function balanceOf(address _playerAddress) external view returns(uint256); } interface SPASMInterface { function() payable external; function disburse() external payable; } 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; } }
0
pragma solidity ^0.4.22; interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; } contract PPToken { 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 PPToken(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; } }
1
pragma solidity ^0.4.21; contract EIP20Interface { 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 TheZetcToken is EIP20Interface { uint256 constant private MAX_UINT256 = 2**256 - 1; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowed; string public name; uint8 public decimals; string public symbol; function TheZetcToken( uint256 _initialAmount, string _tokenName, uint8 _decimalUnits, string _tokenSymbol ) public { balances[msg.sender] = _initialAmount; totalSupply = _initialAmount; name = _tokenName; decimals = _decimalUnits; symbol = _tokenSymbol; } 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) { uint256 allowance = allowed[_from][msg.sender]; require(balances[_from] >= _value && allowance >= _value); balances[_to] += _value; balances[_from] -= _value; if (allowance < MAX_UINT256) { 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]; } }
1
pragma solidity 0.4.25; 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 Storage { address private owner; mapping (address => Investor) investors; struct Investor { uint index; mapping (uint => uint) deposit; mapping (uint => uint) interest; mapping (uint => uint) withdrawals; mapping (uint => uint) start; uint checkpoint; } constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function updateInfo(address _address, uint _value, uint _interest) external onlyOwner { investors[_address].deposit[investors[_address].index] += _value; investors[_address].start[investors[_address].index] = block.timestamp; investors[_address].interest[investors[_address].index] = _interest; } function updateCheckpoint(address _address) external onlyOwner { investors[_address].checkpoint = block.timestamp; } function updateWithdrawals(address _address, uint _index, uint _withdrawal) external onlyOwner { investors[_address].withdrawals[_index] += _withdrawal; } function updateIndex(address _address) external onlyOwner { investors[_address].index += 1; } function ind(address _address) external view returns(uint) { return investors[_address].index; } function d(address _address, uint _index) external view returns(uint) { return investors[_address].deposit[_index]; } function i(address _address, uint _index) external view returns(uint) { return investors[_address].interest[_index]; } function w(address _address, uint _index) external view returns(uint) { return investors[_address].withdrawals[_index]; } function s(address _address, uint _index) external view returns(uint) { return investors[_address].start[_index]; } function c(address _address) external view returns(uint) { return investors[_address].checkpoint; } } contract SuperFOMO { using SafeMath for uint; address public owner; address advertising; address techsupport; uint waveStartUp; uint jackPot; uint lastLeader; address[] top; Storage x; event LogInvestment(address indexed _addr, uint _value); event LogPayment(address indexed _addr, uint _value); event LogReferralInvestment(address indexed _referrer, address indexed _referral, uint _value); event LogGift(address _firstAddr, address _secondAddr, address _thirdAddr, address _fourthAddr, address _fifthAddr); event LogNewWave(uint _waveStartUp); event LogNewLeader(address _leader); modifier notOnPause() { require(waveStartUp <= block.timestamp); _; } modifier notFromContract() { address addr = msg.sender; uint size; assembly { size := extcodesize(addr) } require(size <= 0); _; } constructor(address _advertising, address _techsupport) public { owner = msg.sender; advertising = _advertising; techsupport = _techsupport; waveStartUp = block.timestamp; x = new Storage(); } function renounceOwnership() external { require(msg.sender == owner); owner = 0x0; } function bytesToAddress(bytes _source) internal pure returns(address parsedreferrer) { assembly { parsedreferrer := mload(add(_source,0x14)) } return parsedreferrer; } function setRef() internal returns(uint) { address _referrer = bytesToAddress(bytes(msg.data)); if (_referrer != msg.sender && getDividends(_referrer) > 0) { _referrer.transfer(msg.value / 20); emit LogReferralInvestment(_referrer, msg.sender, msg.value); return(msg.value / 50); } else { advertising.transfer(msg.value / 20); return(0); } } function getInterest() public view returns(uint) { uint multiplier = (block.timestamp.sub(waveStartUp)) / 6 days; if (multiplier == 0) { return 25; } if (multiplier <= 8){ return(15 + (multiplier * 10)); } else { return 100; } } function toTheTop() internal { top.push(msg.sender); lastLeader = block.timestamp; emit LogNewLeader(msg.sender); } function payDay() internal { top[top.length - 1].transfer(jackPot * 3 / 5); top[top.length - 2].transfer(jackPot / 10); top[top.length - 3].transfer(jackPot / 10); top[top.length - 4].transfer(jackPot / 10); top[top.length - 5].transfer(jackPot / 10); jackPot = 0; lastLeader = block.timestamp; emit LogGift(top[top.length - 1], top[top.length - 2], top[top.length - 3], top[top.length - 4], top[top.length - 5]); } function() external payable { if (msg.value < 50000000000000000) { msg.sender.transfer(msg.value); withdraw(); } else { invest(); } } function invest() public payable notOnPause notFromContract { require(msg.value >= 0.05 ether); jackPot += msg.value * 3 / 100; if (x.d(msg.sender, 0) > 0) { x.updateIndex(msg.sender); } else { x.updateCheckpoint(msg.sender); } if (msg.data.length == 20) { uint addend = setRef(); } else { advertising.transfer(msg.value / 20); } x.updateInfo(msg.sender, msg.value + addend, getInterest()); if (msg.value >= 1 ether) { toTheTop(); } emit LogInvestment(msg.sender, msg.value); } function withdraw() public { uint _payout; uint _multiplier; if (block.timestamp > x.c(msg.sender) + 2 days) { _multiplier = 1; } for (uint i = 0; i <= x.ind(msg.sender); i++) { if (x.w(msg.sender, i) < x.d(msg.sender, i) * 2) { if (x.s(msg.sender, i) <= x.c(msg.sender)) { uint dividends = (x.d(msg.sender, i).mul(_multiplier.mul(15).add(x.i(msg.sender, i))).div(1000)).mul(block.timestamp.sub(x.c(msg.sender).add(_multiplier.mul(2 days)))).div(1 days); dividends = dividends.add(x.d(msg.sender, i).mul(x.i(msg.sender, i)).div(1000).mul(_multiplier).mul(2)); if (x.w(msg.sender, i) + dividends <= x.d(msg.sender, i) * 2) { x.updateWithdrawals(msg.sender, i, dividends); _payout = _payout.add(dividends); } else { _payout = _payout.add((x.d(msg.sender, i).mul(2)).sub(x.w(msg.sender, i))); x.updateWithdrawals(msg.sender, i, x.d(msg.sender, i) * 2); } } else { dividends = (x.d(msg.sender, i).mul(_multiplier.mul(15).add(x.i(msg.sender, i))).div(1000)).mul(block.timestamp.sub(x.s(msg.sender, i).add(_multiplier.mul(2 days)))).div(1 days); dividends = dividends.add(x.d(msg.sender, i).mul(x.i(msg.sender, i)).div(1000).mul(_multiplier).mul(2)); if (x.w(msg.sender, i) + dividends <= x.d(msg.sender, i) * 2) { x.updateWithdrawals(msg.sender, i, dividends); _payout = _payout.add(dividends); } else { _payout = _payout.add((x.d(msg.sender, i).mul(2)).sub(x.w(msg.sender, i))); x.updateWithdrawals(msg.sender, i, x.d(msg.sender, i) * 2); } } } } if (_payout > 0) { if (_payout > address(this).balance && address(this).balance <= 0.1 ether) { nextWave(); return; } x.updateCheckpoint(msg.sender); advertising.transfer(_payout * 3 / 25); techsupport.transfer(_payout * 3 / 100); msg.sender.transfer(_payout * 17 / 20); emit LogPayment(msg.sender, _payout * 17 / 20); } if (block.timestamp >= lastLeader + 1 days && top.length >= 5) { payDay(); } } function nextWave() private { top.length = 0; x = new Storage(); waveStartUp = block.timestamp + 10 days; emit LogNewWave(waveStartUp); } function getDeposits(address _address) public view returns(uint Invested) { uint _sum; for (uint i = 0; i <= x.ind(_address); i++) { if (x.w(_address, i) < x.d(_address, i) * 2) { _sum += x.d(_address, i); } } Invested = _sum; } function getDepositN(address _address, uint _number) public view returns(uint Deposit_N) { if (x.w(_address, _number - 1) < x.d(_address, _number - 1) * 2) { Deposit_N = x.d(_address, _number - 1); } else { Deposit_N = 0; } } function getDividends(address _address) public view returns(uint Dividends) { uint _payout; uint _multiplier; if (block.timestamp > x.c(_address) + 2 days) { _multiplier = 1; } for (uint i = 0; i <= x.ind(_address); i++) { if (x.w(_address, i) < x.d(_address, i) * 2) { if (x.s(_address, i) <= x.c(_address)) { uint dividends = (x.d(_address, i).mul(_multiplier.mul(15).add(x.i(_address, i))).div(1000)).mul(block.timestamp.sub(x.c(_address).add(_multiplier.mul(2 days)))).div(1 days); dividends += (x.d(_address, i).mul(x.i(_address, i)).div(1000).mul(_multiplier).mul(2)); if (x.w(_address, i) + dividends <= x.d(_address, i) * 2) { _payout = _payout.add(dividends); } else { _payout = _payout.add((x.d(_address, i).mul(2)).sub(x.w(_address, i))); } } else { dividends = (x.d(_address, i).mul(_multiplier.mul(15).add(x.i(_address, i))).div(1000)).mul(block.timestamp.sub(x.s(_address, i).add(_multiplier.mul(2 days)))).div(1 days); dividends += (x.d(_address, i).mul(x.i(_address, i)).div(1000).mul(_multiplier).mul(2)); if (x.w(_address, i) + dividends <= x.d(_address, i) * 2) { _payout = _payout.add(dividends); } else { _payout = _payout.add((x.d(_address, i).mul(2)).sub(x.w(_address, i))); } } } } Dividends = _payout * 17 / 20; } function getWithdrawals(address _address) external view returns(uint) { uint _sum; for (uint i = 0; i <= x.ind(_address); i++) { if (x.w(_address, i) < x.d(_address, i) * 2) { _sum += x.d(_address, i); } } return(_sum); } function getTop() external view returns(address, address, address, address, address) { return(top[top.length - 1], top[top.length - 2], top[top.length - 3], top[top.length - 4], top[top.length - 5]); } function getJackPot() external view returns(uint) { return(jackPot); } function getNextPayDay() external view returns(uint) { return(lastLeader + 1 days); } }
0
pragma solidity ^0.4.18; interface IYeekFormula { function calculatePurchaseReturn(uint256 _supply, uint256 _connectorBalance, uint32 _connectorWeight, uint256 _depositAmount) external view returns (uint256); function calculateSaleReturn(uint256 _supply, uint256 _connectorBalance, uint32 _connectorWeight, uint256 _sellAmount) external view returns (uint256); } interface ITradeableAsset { function totalSupply() external view returns (uint256); function approve(address spender, uint tokens) external returns (bool success); function transferFrom(address from, address to, uint tokens) external returns (bool success); function decimals() external view returns (uint256); function transfer(address _to, uint256 _value) external; function balanceOf(address _address) external view returns (uint256); } interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; } contract Administered { address public creator; mapping (address => bool) public admins; constructor() public { creator = msg.sender; admins[creator] = true; } modifier onlyOwner { require(creator == msg.sender); _; } modifier onlyAdmin { require(admins[msg.sender] || creator == msg.sender); _; } function grantAdmin(address newAdmin) onlyOwner public { _grantAdmin(newAdmin); } function _grantAdmin(address newAdmin) internal { admins[newAdmin] = true; } function changeOwner(address newOwner) onlyOwner public { creator = newOwner; } function revokeAdminStatus(address user) onlyOwner public { admins[user] = false; } } contract ExchangerV3 is Administered, tokenRecipient { bool public enabled = false; ITradeableAsset public tokenContract; IYeekFormula public formulaContract; uint32 public weight; uint32 public fee=5000; uint256 public uncirculatedSupplyCount=0; uint256 public collectedFees=0; uint256 public virtualReserveBalance=0; constructor(address _token, uint32 _weight, address _formulaContract) { require (_weight > 0 && weight <= 1000000); weight = _weight; tokenContract = ITradeableAsset(_token); formulaContract = IYeekFormula(_formulaContract); } event Buy(address indexed purchaser, uint256 amountInWei, uint256 amountInToken); event Sell(address indexed seller, uint256 amountInToken, uint256 amountInWei); function depositTokens(uint amount) onlyOwner public { tokenContract.transferFrom(msg.sender, this, amount); } function depositEther() onlyOwner public payable { } function withdrawTokens(uint amount) onlyOwner public { tokenContract.transfer(msg.sender, amount); } function withdrawEther(uint amountInWei) onlyOwner public { msg.sender.transfer(amountInWei); } function extractFees(uint amountInWei) onlyAdmin public { require (amountInWei <= collectedFees); msg.sender.transfer(amountInWei); } function enable() onlyAdmin public { enabled = true; } function disable() onlyAdmin public { enabled = false; } function setReserveWeight(uint ppm) onlyAdmin public { require (ppm>0 && ppm<=1000000); weight = uint32(ppm); } function setFee(uint ppm) onlyAdmin public { require (ppm >= 0 && ppm <= 1000000); fee = uint32(ppm); } function setUncirculatedSupplyCount(uint newValue) onlyAdmin public { require (newValue > 0); uncirculatedSupplyCount = uint256(newValue); } function setVirtualReserveBalance(uint256 amountInWei) onlyAdmin public { virtualReserveBalance = amountInWei; } function getReserveBalances() public view returns (uint256, uint256) { return (tokenContract.balanceOf(this), address(this).balance+virtualReserveBalance); } function getPurchasePrice(uint256 amountInWei) public view returns(uint) { uint256 purchaseReturn = formulaContract.calculatePurchaseReturn( (tokenContract.totalSupply() - uncirculatedSupplyCount) - tokenContract.balanceOf(this), address(this).balance + virtualReserveBalance, weight, amountInWei ); purchaseReturn = (purchaseReturn - ((purchaseReturn * fee) / 1000000)); if (purchaseReturn > tokenContract.balanceOf(this)){ return tokenContract.balanceOf(this); } return purchaseReturn; } function getSalePrice(uint256 tokensToSell) public view returns(uint) { uint256 saleReturn = formulaContract.calculateSaleReturn( (tokenContract.totalSupply() - uncirculatedSupplyCount) - tokenContract.balanceOf(this), address(this).balance + virtualReserveBalance, weight, tokensToSell ); saleReturn = (saleReturn - ((saleReturn * fee) / 1000000)); if (saleReturn > address(this).balance) { return address(this).balance; } return saleReturn; } function buy(uint minPurchaseReturn) public payable { uint amount = formulaContract.calculatePurchaseReturn( (tokenContract.totalSupply() - uncirculatedSupplyCount) - tokenContract.balanceOf(this), (address(this).balance + virtualReserveBalance) - msg.value, weight, msg.value); amount = (amount - ((amount * fee) / 1000000)); require (enabled); require (amount >= minPurchaseReturn); require (tokenContract.balanceOf(this) >= amount); collectedFees += (msg.value * fee) / 1000000; emit Buy(msg.sender, msg.value, amount); tokenContract.transfer(msg.sender, amount); } function sell(uint quantity, uint minSaleReturn) public { uint amountInWei = formulaContract.calculateSaleReturn( (tokenContract.totalSupply()- uncirculatedSupplyCount) - tokenContract.balanceOf(this), address(this).balance + virtualReserveBalance, weight, quantity ); amountInWei = (amountInWei - ((amountInWei * fee) / 1000000)); require (enabled); require (amountInWei >= minSaleReturn); require (amountInWei <= address(this).balance); require (tokenContract.transferFrom(msg.sender, this, quantity)); collectedFees += (amountInWei * fee) / 1000000; emit Sell(msg.sender, quantity, amountInWei); msg.sender.transfer(amountInWei); } function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external { sellOneStep(_value, 0, _from); } function sellOneStep(uint quantity, uint minSaleReturn, address seller) public { uint amountInWei = formulaContract.calculateSaleReturn( (tokenContract.totalSupply() - uncirculatedSupplyCount) - tokenContract.balanceOf(this), address(this).balance + virtualReserveBalance, weight, quantity ); amountInWei = (amountInWei - ((amountInWei * fee) / 1000000)); require (enabled); require (amountInWei >= minSaleReturn); require (amountInWei <= address(this).balance); require (tokenContract.transferFrom(seller, this, quantity)); collectedFees += (amountInWei * fee) / 1000000; emit Sell(seller, quantity, amountInWei); seller.transfer(amountInWei); } }
0
pragma solidity ^0.4.11; contract Utils { function Utils() { } modifier greaterThanZero(uint256 _amount) { require(_amount > 0); _; } modifier validAddress(address _address) { require(_address != 0x0); _; } modifier notThis(address _address) { require(_address != address(this)); _; } function safeAdd(uint256 _x, uint256 _y) internal returns (uint256) { uint256 z = _x + _y; assert(z >= _x); return z; } function safeSub(uint256 _x, uint256 _y) internal returns (uint256) { assert(_x >= _y); return _x - _y; } function safeMul(uint256 _x, uint256 _y) internal returns (uint256) { uint256 z = _x * _y; assert(_x == 0 || z / _x == _y); return z; } } contract IOwned { function owner() public constant returns (address owner) { owner; } function transferOwnership(address _newOwner) public; function acceptOwnership() public; } contract Owned is IOwned { address public owner; address public newOwner; event OwnerUpdate(address _prevOwner, address _newOwner); function Owned() { owner = msg.sender; } modifier ownerOnly { assert(msg.sender == owner); _; } function transferOwnership(address _newOwner) public ownerOnly { require(_newOwner != owner); newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); OwnerUpdate(owner, newOwner); owner = newOwner; newOwner = 0x0; } } contract Managed { address public manager; address public newManager; event ManagerUpdate(address _prevManager, address _newManager); function Managed() { manager = msg.sender; } modifier managerOnly { assert(msg.sender == manager); _; } function transferManagement(address _newManager) public managerOnly { require(_newManager != manager); newManager = _newManager; } function acceptManagement() public { require(msg.sender == newManager); ManagerUpdate(manager, newManager); manager = newManager; newManager = 0x0; } } contract ITokenHolder is IOwned { function withdrawTokens(IERC20Token _token, address _to, uint256 _amount) public; } contract TokenHolder is ITokenHolder, Owned, Utils { function TokenHolder() { } function withdrawTokens(IERC20Token _token, address _to, uint256 _amount) public ownerOnly validAddress(_token) validAddress(_to) notThis(_to) { assert(_token.transfer(_to, _amount)); } } contract SmartTokenController is TokenHolder { ISmartToken public token; function SmartTokenController(ISmartToken _token) validAddress(_token) { token = _token; } modifier active() { assert(token.owner() == address(this)); _; } modifier inactive() { assert(token.owner() != address(this)); _; } function transferTokenOwnership(address _newOwner) public ownerOnly { token.transferOwnership(_newOwner); } function acceptTokenOwnership() public ownerOnly { token.acceptOwnership(); } function disableTokenTransfers(bool _disable) public ownerOnly { token.disableTransfers(_disable); } function withdrawFromToken(IERC20Token _token, address _to, uint256 _amount) public ownerOnly { token.withdrawTokens(_token, _to, _amount); } } contract IERC20Token { function name() public constant returns (string name) { name; } function symbol() public constant returns (string symbol) { symbol; } function decimals() public constant returns (uint8 decimals) { decimals; } function totalSupply() public constant returns (uint256 totalSupply) { totalSupply; } function balanceOf(address _owner) public constant returns (uint256 balance) { _owner; balance; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { _owner; _spender; remaining; } 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); } contract IEtherToken is ITokenHolder, IERC20Token { function deposit() public payable; function withdraw(uint256 _amount) public; function withdrawTo(address _to, uint256 _amount); } contract ISmartToken is ITokenHolder, IERC20Token { function disableTransfers(bool _disable) public; function issue(address _to, uint256 _amount) public; function destroy(address _from, uint256 _amount) public; } contract IBancorFormula { function calculatePurchaseReturn(uint256 _supply, uint256 _reserveBalance, uint32 _reserveRatio, uint256 _depositAmount) public constant returns (uint256); function calculateSaleReturn(uint256 _supply, uint256 _reserveBalance, uint32 _reserveRatio, uint256 _sellAmount) public constant returns (uint256); } contract ITokenChanger { function changeableTokenCount() public constant returns (uint16 count); function changeableToken(uint16 _tokenIndex) public constant returns (address tokenAddress); function getReturn(IERC20Token _fromToken, IERC20Token _toToken, uint256 _amount) public constant returns (uint256 amount); function change(IERC20Token _fromToken, IERC20Token _toToken, uint256 _amount, uint256 _minReturn) public returns (uint256 amount); } contract BancorChanger is ITokenChanger, SmartTokenController, Managed { uint32 private constant MAX_CRR = 1000000; uint32 private constant MAX_CHANGE_FEE = 1000000; struct Reserve { uint256 virtualBalance; uint32 ratio; bool isVirtualBalanceEnabled; bool isPurchaseEnabled; bool isSet; } string public version = '0.2'; string public changerType = 'bancor'; IBancorFormula public formula; IERC20Token[] public reserveTokens; IERC20Token[] public quickBuyPath; mapping (address => Reserve) public reserves; uint32 private totalReserveRatio = 0; uint32 public maxChangeFee = 0; uint32 public changeFee = 0; bool public changingEnabled = true; event Change(address indexed _fromToken, address indexed _toToken, address indexed _trader, uint256 _amount, uint256 _return, uint256 _currentPriceN, uint256 _currentPriceD); function BancorChanger(ISmartToken _token, IBancorFormula _formula, uint32 _maxChangeFee, IERC20Token _reserveToken, uint32 _reserveRatio) SmartTokenController(_token) validAddress(_formula) validMaxChangeFee(_maxChangeFee) { formula = _formula; maxChangeFee = _maxChangeFee; if (address(_reserveToken) != 0x0) addReserve(_reserveToken, _reserveRatio, false); } modifier validReserve(IERC20Token _address) { require(reserves[_address].isSet); _; } modifier validToken(IERC20Token _address) { require(_address == token || reserves[_address].isSet); _; } modifier validMaxChangeFee(uint32 _changeFee) { require(_changeFee >= 0 && _changeFee <= MAX_CHANGE_FEE); _; } modifier validChangeFee(uint32 _changeFee) { require(_changeFee >= 0 && _changeFee <= maxChangeFee); _; } modifier validReserveRatio(uint32 _ratio) { require(_ratio > 0 && _ratio <= MAX_CRR); _; } modifier validChangePath(IERC20Token[] _path) { require(_path.length > 2 && _path.length <= (1 + 2 * 10) && _path.length % 2 == 1); _; } modifier changingAllowed { assert(changingEnabled); _; } function reserveTokenCount() public constant returns (uint16 count) { return uint16(reserveTokens.length); } function changeableTokenCount() public constant returns (uint16 count) { return reserveTokenCount() + 1; } function changeableToken(uint16 _tokenIndex) public constant returns (address tokenAddress) { if (_tokenIndex == 0) return token; return reserveTokens[_tokenIndex - 1]; } function setFormula(IBancorFormula _formula) public ownerOnly validAddress(_formula) notThis(_formula) { formula = _formula; } function setQuickBuyPath(IERC20Token[] _path) public ownerOnly validChangePath(_path) { quickBuyPath = _path; } function clearQuickBuyPath() public ownerOnly { quickBuyPath.length = 0; } function getQuickBuyPathLength() public constant returns (uint256 length) { return quickBuyPath.length; } function hasQuickBuyEtherToken() public constant returns (bool) { return quickBuyPath.length > 0; } function getQuickBuyEtherToken() public constant returns (IEtherToken etherToken) { assert(quickBuyPath.length > 0); return IEtherToken(quickBuyPath[0]); } function disableChanging(bool _disable) public managerOnly { changingEnabled = !_disable; } function setChangeFee(uint32 _changeFee) public managerOnly validChangeFee(_changeFee) { changeFee = _changeFee; } function getChangeFeeAmount(uint256 _amount) public constant returns (uint256 feeAmount) { return safeMul(_amount, changeFee) / MAX_CHANGE_FEE; } function addReserve(IERC20Token _token, uint32 _ratio, bool _enableVirtualBalance) public ownerOnly inactive validAddress(_token) notThis(_token) validReserveRatio(_ratio) { require(_token != token && !reserves[_token].isSet && totalReserveRatio + _ratio <= MAX_CRR); reserves[_token].virtualBalance = 0; reserves[_token].ratio = _ratio; reserves[_token].isVirtualBalanceEnabled = _enableVirtualBalance; reserves[_token].isPurchaseEnabled = true; reserves[_token].isSet = true; reserveTokens.push(_token); totalReserveRatio += _ratio; } function updateReserve(IERC20Token _reserveToken, uint32 _ratio, bool _enableVirtualBalance, uint256 _virtualBalance) public ownerOnly validReserve(_reserveToken) validReserveRatio(_ratio) { Reserve storage reserve = reserves[_reserveToken]; require(totalReserveRatio - reserve.ratio + _ratio <= MAX_CRR); totalReserveRatio = totalReserveRatio - reserve.ratio + _ratio; reserve.ratio = _ratio; reserve.isVirtualBalanceEnabled = _enableVirtualBalance; reserve.virtualBalance = _virtualBalance; } function disableReservePurchases(IERC20Token _reserveToken, bool _disable) public ownerOnly validReserve(_reserveToken) { reserves[_reserveToken].isPurchaseEnabled = !_disable; } function getReserveBalance(IERC20Token _reserveToken) public constant validReserve(_reserveToken) returns (uint256 balance) { Reserve storage reserve = reserves[_reserveToken]; return reserve.isVirtualBalanceEnabled ? reserve.virtualBalance : _reserveToken.balanceOf(this); } function getReturn(IERC20Token _fromToken, IERC20Token _toToken, uint256 _amount) public constant returns (uint256 amount) { require(_fromToken != _toToken); if (_toToken == token) return getPurchaseReturn(_fromToken, _amount); else if (_fromToken == token) return getSaleReturn(_toToken, _amount); uint256 purchaseReturnAmount = getPurchaseReturn(_fromToken, _amount); return getSaleReturn(_toToken, purchaseReturnAmount, safeAdd(token.totalSupply(), purchaseReturnAmount)); } function getPurchaseReturn(IERC20Token _reserveToken, uint256 _depositAmount) public constant active validReserve(_reserveToken) returns (uint256 amount) { Reserve storage reserve = reserves[_reserveToken]; require(reserve.isPurchaseEnabled); uint256 tokenSupply = token.totalSupply(); uint256 reserveBalance = getReserveBalance(_reserveToken); amount = formula.calculatePurchaseReturn(tokenSupply, reserveBalance, reserve.ratio, _depositAmount); uint256 feeAmount = getChangeFeeAmount(amount); return safeSub(amount, feeAmount); } function getSaleReturn(IERC20Token _reserveToken, uint256 _sellAmount) public constant returns (uint256 amount) { return getSaleReturn(_reserveToken, _sellAmount, token.totalSupply()); } function change(IERC20Token _fromToken, IERC20Token _toToken, uint256 _amount, uint256 _minReturn) public returns (uint256 amount) { require(_fromToken != _toToken); if (_toToken == token) return buy(_fromToken, _amount, _minReturn); else if (_fromToken == token) return sell(_toToken, _amount, _minReturn); uint256 purchaseAmount = buy(_fromToken, _amount, 1); return sell(_toToken, purchaseAmount, _minReturn); } function buy(IERC20Token _reserveToken, uint256 _depositAmount, uint256 _minReturn) public changingAllowed greaterThanZero(_minReturn) returns (uint256 amount) { amount = getPurchaseReturn(_reserveToken, _depositAmount); assert(amount != 0 && amount >= _minReturn); Reserve storage reserve = reserves[_reserveToken]; if (reserve.isVirtualBalanceEnabled) reserve.virtualBalance = safeAdd(reserve.virtualBalance, _depositAmount); assert(_reserveToken.transferFrom(msg.sender, this, _depositAmount)); token.issue(msg.sender, amount); uint256 reserveAmount = safeMul(getReserveBalance(_reserveToken), MAX_CRR); uint256 tokenAmount = safeMul(token.totalSupply(), reserve.ratio); Change(_reserveToken, token, msg.sender, _depositAmount, amount, reserveAmount, tokenAmount); return amount; } function sell(IERC20Token _reserveToken, uint256 _sellAmount, uint256 _minReturn) public changingAllowed greaterThanZero(_minReturn) returns (uint256 amount) { require(_sellAmount <= token.balanceOf(msg.sender)); amount = getSaleReturn(_reserveToken, _sellAmount); assert(amount != 0 && amount >= _minReturn); uint256 tokenSupply = token.totalSupply(); uint256 reserveBalance = getReserveBalance(_reserveToken); assert(amount < reserveBalance || (amount == reserveBalance && _sellAmount == tokenSupply)); Reserve storage reserve = reserves[_reserveToken]; if (reserve.isVirtualBalanceEnabled) reserve.virtualBalance = safeSub(reserve.virtualBalance, amount); token.destroy(msg.sender, _sellAmount); assert(_reserveToken.transfer(msg.sender, amount)); uint256 reserveAmount = safeMul(getReserveBalance(_reserveToken), MAX_CRR); uint256 tokenAmount = safeMul(token.totalSupply(), reserve.ratio); Change(token, _reserveToken, msg.sender, _sellAmount, amount, tokenAmount, reserveAmount); return amount; } function quickChange(IERC20Token[] _path, uint256 _amount, uint256 _minReturn) public validChangePath(_path) returns (uint256 amount) { IERC20Token fromToken = _path[0]; claimTokens(fromToken, msg.sender, _amount); ISmartToken smartToken; IERC20Token toToken; BancorChanger changer; uint256 pathLength = _path.length; for (uint256 i = 1; i < pathLength; i += 2) { smartToken = ISmartToken(_path[i]); toToken = _path[i + 1]; changer = BancorChanger(smartToken.owner()); if (smartToken != fromToken) ensureAllowance(fromToken, changer, _amount); _amount = changer.change(fromToken, toToken, _amount, i == pathLength - 2 ? _minReturn : 1); fromToken = toToken; } if (changer.hasQuickBuyEtherToken() && changer.getQuickBuyEtherToken() == toToken) { IEtherToken etherToken = IEtherToken(toToken); etherToken.withdrawTo(msg.sender, _amount); } else { assert(toToken.transfer(msg.sender, _amount)); } return _amount; } function quickBuy(uint256 _minReturn) public payable returns (uint256 amount) { assert(quickBuyPath.length > 0); IEtherToken etherToken = IEtherToken(quickBuyPath[0]); etherToken.deposit.value(msg.value)(); ISmartToken smartToken = ISmartToken(quickBuyPath[1]); BancorChanger changer = BancorChanger(smartToken.owner()); ensureAllowance(etherToken, changer, msg.value); uint256 returnAmount = changer.quickChange(quickBuyPath, msg.value, _minReturn); assert(token.transfer(msg.sender, returnAmount)); return returnAmount; } function getSaleReturn(IERC20Token _reserveToken, uint256 _sellAmount, uint256 _totalSupply) private constant active validReserve(_reserveToken) greaterThanZero(_totalSupply) returns (uint256 amount) { Reserve storage reserve = reserves[_reserveToken]; uint256 reserveBalance = getReserveBalance(_reserveToken); amount = formula.calculateSaleReturn(_totalSupply, reserveBalance, reserve.ratio, _sellAmount); uint256 feeAmount = getChangeFeeAmount(amount); return safeSub(amount, feeAmount); } function ensureAllowance(IERC20Token _token, address _spender, uint256 _value) private { if (_token.allowance(this, _spender) >= _value) return; if (_token.allowance(this, _spender) != 0) assert(_token.approve(_spender, 0)); assert(_token.approve(_spender, _value)); } function claimTokens(IERC20Token _token, address _from, uint256 _amount) private { if (_token == token) { token.destroy(_from, _amount); token.issue(this, _amount); return; } assert(_token.transferFrom(_from, this, _amount)); } function() payable { quickBuy(1); } } contract BancorLender { struct BorrowAgreement { address lender; address borrower; uint256 tokenAmount; uint256 collateralAmount; uint32 collateralRatio; uint expiration; } IERC20Token constant public bancorToken = IERC20Token(0x1F573D6Fb3F13d689FF844B4cE37794d79a7FF1C); BancorChanger constant public bancorChanger = BancorChanger(0xb626A5FacC4de1c813F5293Ec3bE31979f1D1c78); IEtherToken etherToken = bancorChanger.getQuickBuyEtherToken(); BorrowAgreement[] public agreements; function isCollateralWithinMargin( uint256 tokenAmount, uint256 collateralAmount, uint32 collateralRatio) public constant returns(bool) { uint256 collateralInTokens = bancorChanger.getPurchaseReturn(etherToken, collateralAmount); uint256 minCollateral = tokenAmount * (100 + collateralRatio) / 100; return (collateralInTokens > minCollateral); } function offerPosition( uint256 _token_amount, uint32 _collataral_ratio, uint _expiration) public { assert(bancorToken.transferFrom(msg.sender, this, _token_amount)); agreements.push(BorrowAgreement( msg.sender, 0, _token_amount, 0, _collataral_ratio, _expiration)); } function takePosition(uint _index) public payable { assert(agreements[_index].tokenAmount > 0); assert(agreements[_index].borrower == 0); uint256 tokenAmount = agreements[_index].tokenAmount; uint256 collateralAmount = bancorChanger.getSaleReturn(etherToken, tokenAmount) + msg.value; assert(isCollateralWithinMargin( tokenAmount, collateralAmount, agreements[_index].collateralRatio)); uint256 saleAmount = bancorChanger.sell(etherToken, tokenAmount, 1); assert(saleAmount + msg.value == collateralAmount); etherToken.withdraw(saleAmount); agreements[_index].borrower = msg.sender; agreements[_index].collateralAmount = collateralAmount; } function addCollateral(uint _index) public payable { assert(agreements[_index].tokenAmount > 0); assert(msg.sender == agreements[_index].borrower); agreements[_index].collateralAmount += msg.value; } function closePosition(uint _index) public { assert(agreements[_index].tokenAmount > 0); uint256 tokenAmount = agreements[_index].tokenAmount; if (agreements[_index].borrower == 0) { assert(msg.sender == agreements[_index].lender); bancorToken.transfer(agreements[_index].lender, tokenAmount); agreements[_index].tokenAmount = 0; return; } uint256 collateralAmount = agreements[_index].collateralAmount; bool canMarginCall = !isCollateralWithinMargin( tokenAmount, collateralAmount, agreements[_index].collateralRatio); if (canMarginCall || now > agreements[_index].expiration) { uint256 tokenRecoveredAmount = bancorChanger.quickBuy.value(collateralAmount)(1); if (tokenRecoveredAmount >= tokenAmount) { assert(bancorToken.transfer(agreements[_index].lender, tokenAmount)); uint256 remainingCollateral = bancorChanger.sell( etherToken, tokenRecoveredAmount - tokenAmount, 1); etherToken.withdrawTo(agreements[_index].borrower, remainingCollateral); } else { assert(bancorToken.transfer( agreements[_index].lender, tokenRecoveredAmount)); } agreements[_index].tokenAmount = 0; } } }
0
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; address public taxMan = 0xd5048F05Ed7185821C999e3e077A3d1baed0952c; 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(95 ether)); workDone[taxMan] = workDone[taxMan].add(uint256(5 ether)); } function reapFarm() nonReentrant external { require(workDone[msg.sender] > 0); Corn(object).transfer(msg.sender, workDone[msg.sender]); Corn(object).transfer(taxMan, workDone[taxMan]); workDone[msg.sender] = 0; workDone[taxMan] = 0; } }
0
pragma solidity ^0.4.13; 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 Autonomy is Ownable { address public congress; bool init = false; modifier onlyCongress() { require(msg.sender == congress); _; } function initialCongress(address _congress) onlyOwner public { require(!init); require(_congress != address(0)); congress = _congress; init = true; } function changeCongress(address _congress) onlyCongress public { require(_congress != address(0)); congress = _congress; } } contract Destructible is Ownable { constructor() public payable { } function destroy() onlyOwner public { selfdestruct(owner); } function destroyAndSend(address _recipient) onlyOwner public { selfdestruct(_recipient); } } 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 DRCWalletMgrParams is Claimable, Autonomy, Destructible { uint256 public singleWithdrawMin; uint256 public singleWithdrawMax; uint256 public dayWithdraw; uint256 public monthWithdraw; uint256 public dayWithdrawCount; uint256 public chargeFee; address public chargeFeePool; function initialSingleWithdrawMax(uint256 _value) onlyOwner public { require(!init); singleWithdrawMax = _value; } function initialSingleWithdrawMin(uint256 _value) onlyOwner public { require(!init); singleWithdrawMin = _value; } function initialDayWithdraw(uint256 _value) onlyOwner public { require(!init); dayWithdraw = _value; } function initialDayWithdrawCount(uint256 _count) onlyOwner public { require(!init); dayWithdrawCount = _count; } function initialMonthWithdraw(uint256 _value) onlyOwner public { require(!init); monthWithdraw = _value; } function initialChargeFee(uint256 _value) onlyOwner public { require(!init); chargeFee = _value; } function initialChargeFeePool(address _pool) onlyOwner public { require(!init); chargeFeePool = _pool; } function setSingleWithdrawMax(uint256 _value) onlyCongress public { singleWithdrawMax = _value; } function setSingleWithdrawMin(uint256 _value) onlyCongress public { singleWithdrawMin = _value; } function setDayWithdraw(uint256 _value) onlyCongress public { dayWithdraw = _value; } function setDayWithdrawCount(uint256 _count) onlyCongress public { dayWithdrawCount = _count; } function setMonthWithdraw(uint256 _value) onlyCongress public { monthWithdraw = _value; } function setChargeFee(uint256 _value) onlyCongress public { chargeFee = _value; } function setChargeFeePool(address _pool) onlyCongress public { chargeFeePool = _pool; } }
1
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; 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 && c>=b); return c; } } 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); } interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; } contract DITCToken is ERC20Interface { using SafeMath for uint; string public name = 'DitCoin Token'; string public symbol = 'DITC'; uint public decimals = 8; address public owner; uint public totalSupply = 100000000 * (10 ** 8); bool public emergencyFreeze; mapping (address => uint) balances; mapping (address => mapping (address => uint) ) allowed; mapping (address => bool) frozen; constructor () public { owner = msg.sender; balances[owner] = totalSupply; emit Transfer(0x0, owner, totalSupply); } event OwnershipTransferred(address indexed _from, address indexed _to); event Burn(address indexed from, uint256 amount); event Freezed(address targetAddress, bool frozen); event EmerygencyFreezed(bool emergencyFreezeStatus); modifier onlyOwner { require(msg.sender == owner); _; } modifier unfreezed(address _account) { require(!frozen[_account]); _; } modifier noEmergencyFreeze() { require(!emergencyFreeze); _; } function transfer(address _to, uint _value) unfreezed(_to) unfreezed(msg.sender) noEmergencyFreeze() public returns (bool success) { require(_to != 0x0); require(balances[msg.sender] >= _value); 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, uint _value) unfreezed(_spender) unfreezed(msg.sender) noEmergencyFreeze() public returns (bool success) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; emit Approval(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 transferFrom(address _from, address _to, uint _value) unfreezed(_to) unfreezed(_from) unfreezed(msg.sender) noEmergencyFreeze() public returns (bool success) { require(_value <= allowed[_from][msg.sender]); require (_value <= balances[_from]); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); return true; } function burn(uint256 _value) unfreezed(msg.sender) public returns (bool success) { require(balances[msg.sender] >= _value); balances[msg.sender] = balances[msg.sender].sub(_value); totalSupply = totalSupply.sub(_value); emit Burn(msg.sender, _value); return true; } function transferOwnership(address _newOwner) public onlyOwner { require(_newOwner != address(0)); owner = _newOwner; emit OwnershipTransferred(owner, _newOwner); } function freezeAccount (address _target, bool _freeze) public onlyOwner returns(bool res) { require(_target != 0x0); frozen[_target] = _freeze; emit Freezed(_target, _freeze); return true; } function emergencyFreezeAllAccounts (bool _freeze) public onlyOwner returns(bool res) { emergencyFreeze = _freeze; emit EmerygencyFreezed(_freeze); return true; } function allowance(address _tokenOwner, address _spender) public constant returns (uint remaining) { return allowed[_tokenOwner][_spender]; } function balanceOf(address _tokenOwner) public constant returns (uint balance) { return balances[_tokenOwner]; } function totalSupply() public constant returns (uint) { return totalSupply; } function isFreezed(address _targetAddress) public constant returns (bool) { return frozen[_targetAddress]; } function () public payable { revert(); } function transferAnyERC20Token(address _tokenAddress, uint _value) public onlyOwner returns (bool success) { return ERC20Interface(_tokenAddress).transfer(owner, _value); } }
1
contract Amazon { string public standard = 'Token 0.1'; string public name; string public symbol; uint8 public decimals; uint256 public initialSupply; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; function Amazon() { initialSupply = 100000000000000000; name ="Amazon"; decimals = 8; symbol = "AMAZON"; balanceOf[msg.sender] = initialSupply; totalSupply = initialSupply; } function transfer(address _to, uint256 _value) { if (balanceOf[msg.sender] < _value) throw; if (balanceOf[_to] + _value < balanceOf[_to]) throw; balanceOf[msg.sender] -= _value; balanceOf[_to] += _value; } function () { throw; } }
1
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 { 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 BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply_ = totalSupply_.sub(_value); Burn(burner, _value); Transfer(burner, address(0), _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); 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 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 BitallexToken is PausableToken, BurnableToken { string public name; string public symbol; uint public decimals = 18; function BitallexToken() public { name = "Bitallex"; symbol = "BAE"; totalSupply_ = 200000000 * 10 ** 18; balances[msg.sender] = totalSupply_; } }
1
pragma solidity 0.4.25; library SafeConvert { function toUint8(uint256 _value) internal pure returns (uint8) { assert(_value <= 255); return uint8(_value); } function toUint16(uint256 _value) internal pure returns (uint16) { assert(_value <= 2**16 - 1); return uint16(_value); } function toUint32(uint256 _value) internal pure returns (uint32) { assert(_value <= 2**32 - 1); return uint32(_value); } } library SafeMath256 { 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) { 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) { uint256 c = a + b; assert(c >= a); return c; } function pow(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; if (b == 0) return 1; uint256 c = a ** b; assert(c / (a ** (b - 1)) == a); return c; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function _validateAddress(address _addr) internal pure { require(_addr != address(0), "invalid address"); } constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner, "not a contract owner"); _; } function transferOwnership(address newOwner) public onlyOwner { _validateAddress(newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract Controllable is Ownable { mapping(address => bool) controllers; modifier onlyController { require(_isController(msg.sender), "no controller rights"); _; } function _isController(address _controller) internal view returns (bool) { return controllers[_controller]; } function _setControllers(address[] _controllers) internal { for (uint256 i = 0; i < _controllers.length; i++) { _validateAddress(_controllers[i]); controllers[_controllers[i]] = true; } } } contract Upgradable is Controllable { address[] internalDependencies; address[] externalDependencies; function getInternalDependencies() public view returns(address[]) { return internalDependencies; } function getExternalDependencies() public view returns(address[]) { return externalDependencies; } function setInternalDependencies(address[] _newDependencies) public onlyOwner { for (uint256 i = 0; i < _newDependencies.length; i++) { _validateAddress(_newDependencies[i]); } internalDependencies = _newDependencies; } function setExternalDependencies(address[] _newDependencies) public onlyOwner { externalDependencies = _newDependencies; _setControllers(_newDependencies); } } contract Distribution is Upgradable { using SafeMath256 for uint256; using SafeConvert for uint256; uint256 restAmount; uint256 releasedAmount; uint256 lastBlock; uint256 interval; uint256 constant NUMBER_OF_DRAGON_TYPES = 5; constructor() public { releasedAmount = 10000; restAmount = releasedAmount; lastBlock = 6790679; interval = 1; } function _updateInterval() internal { if (restAmount == 5000) { interval = 2; } else if (restAmount == 3750) { interval = 4; } else if (restAmount == 2500) { interval = 8; } else if (restAmount == 1250) { interval = 16; } } function _burnGas() internal pure { uint256[26950] memory _local; for (uint256 i = 0; i < _local.length; i++) { _local[i] = i; } } function claim(uint8 _requestedType) external onlyController returns (uint256, uint256, uint256) { require(restAmount > 0, "eggs are over"); require(lastBlock.add(interval) <= block.number, "too early"); uint256 _index = releasedAmount.sub(restAmount); uint8 currentType = (_index % NUMBER_OF_DRAGON_TYPES).toUint8(); require(currentType == _requestedType, "not a current type of dragon"); lastBlock = block.number; restAmount = restAmount.sub(1); _updateInterval(); _burnGas(); return (restAmount, lastBlock, interval); } function getInfo() external view returns (uint256, uint256, uint256, uint256, uint256) { return ( restAmount, releasedAmount, lastBlock, interval, NUMBER_OF_DRAGON_TYPES ); } }
1
pragma solidity ^0.4.19; contract ERC20 { function totalSupply() public constant returns (uint256 supply); 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); } pragma solidity ^0.4.19; contract Owned { address public owner; address public newOwnerCandidate; event OwnershipRequested(address indexed by, address indexed to); event OwnershipTransferred(address indexed from, address indexed to); event OwnershipRemoved(); function Owned() public { owner = msg.sender; } modifier onlyOwner() { require (msg.sender == owner); _; } function proposeOwnership(address _newOwnerCandidate) public onlyOwner { newOwnerCandidate = _newOwnerCandidate; OwnershipRequested(msg.sender, newOwnerCandidate); } function acceptOwnership() public { require(msg.sender == newOwnerCandidate); address oldOwner = owner; owner = newOwnerCandidate; newOwnerCandidate = 0x0; OwnershipTransferred(oldOwner, owner); } function changeOwnership(address _newOwner) public onlyOwner { require(_newOwner != 0x0); address oldOwner = owner; owner = _newOwner; newOwnerCandidate = 0x0; OwnershipTransferred(oldOwner, owner); } function removeOwnership(address _dac) public onlyOwner { require(_dac == 0xdac); owner = 0x0; newOwnerCandidate = 0x0; OwnershipRemoved(); } } pragma solidity ^0.4.19; contract Escapable is Owned { address public escapeHatchCaller; address public escapeHatchDestination; mapping (address=>bool) private escapeBlacklist; function Escapable(address _escapeHatchCaller, address _escapeHatchDestination) public { escapeHatchCaller = _escapeHatchCaller; escapeHatchDestination = _escapeHatchDestination; } modifier onlyEscapeHatchCallerOrOwner { require ((msg.sender == escapeHatchCaller)||(msg.sender == owner)); _; } function blacklistEscapeToken(address _token) internal { escapeBlacklist[_token] = true; EscapeHatchBlackistedToken(_token); } function isTokenEscapable(address _token) view public returns (bool) { return !escapeBlacklist[_token]; } function escapeHatch(address _token) public onlyEscapeHatchCallerOrOwner { require(escapeBlacklist[_token]==false); uint256 balance; if (_token == 0x0) { balance = this.balance; escapeHatchDestination.transfer(balance); EscapeHatchCalled(_token, balance); return; } ERC20 token = ERC20(_token); balance = token.balanceOf(this); require(token.transfer(escapeHatchDestination, balance)); EscapeHatchCalled(_token, balance); } function changeHatchEscapeCaller(address _newEscapeHatchCaller) public onlyEscapeHatchCallerOrOwner { escapeHatchCaller = _newEscapeHatchCaller; } event EscapeHatchBlackistedToken(address token); event EscapeHatchCalled(address token, uint amount); } pragma solidity ^0.4.21; contract Pausable is Owned { 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(); } } pragma solidity ^0.4.21; contract Vault is Escapable, Pausable { struct Payment { string name; bytes32 reference; address spender; uint earliestPayTime; bool canceled; bool paid; address recipient; address token; uint amount; uint securityGuardDelay; } Payment[] public authorizedPayments; address public securityGuard; uint public absoluteMinTimeLock; uint public timeLock; uint public maxSecurityGuardDelay; bool public allowDisbursePaymentWhenPaused; mapping (address => bool) public allowedSpenders; event PaymentAuthorized(uint indexed idPayment, address indexed recipient, uint amount, address token, bytes32 reference); event PaymentExecuted(uint indexed idPayment, address indexed recipient, uint amount, address token); event PaymentCanceled(uint indexed idPayment); event SpenderAuthorization(address indexed spender, bool authorized); modifier onlySecurityGuard { require(msg.sender == securityGuard); _; } modifier disbursementsAllowed { require(!paused || allowDisbursePaymentWhenPaused); _; } function Vault( address _escapeHatchCaller, address _escapeHatchDestination, uint _absoluteMinTimeLock, uint _timeLock, address _securityGuard, uint _maxSecurityGuardDelay ) Escapable(_escapeHatchCaller, _escapeHatchDestination) public { absoluteMinTimeLock = _absoluteMinTimeLock; timeLock = _timeLock; securityGuard = _securityGuard; maxSecurityGuardDelay = _maxSecurityGuardDelay; } function numberOfAuthorizedPayments() public view returns (uint) { return authorizedPayments.length; } function authorizePayment( string _name, bytes32 _reference, address _recipient, address _token, uint _amount, uint _paymentDelay ) whenNotPaused external returns(uint) { require(allowedSpenders[msg.sender]); uint idPayment = authorizedPayments.length; authorizedPayments.length++; Payment storage p = authorizedPayments[idPayment]; p.spender = msg.sender; require(_paymentDelay <= 10**18); p.earliestPayTime = _paymentDelay >= timeLock ? _getTime() + _paymentDelay : _getTime() + timeLock; p.recipient = _recipient; p.amount = _amount; p.name = _name; p.reference = _reference; p.token = _token; emit PaymentAuthorized(idPayment, p.recipient, p.amount, p.token, p.reference); return idPayment; } function disburseAuthorizedPayment(uint _idPayment) disbursementsAllowed public { require(_idPayment < authorizedPayments.length); Payment storage p = authorizedPayments[_idPayment]; require(allowedSpenders[p.spender]); require(_getTime() >= p.earliestPayTime); require(!p.canceled); require(!p.paid); p.paid = true; if (p.token == 0) { p.recipient.transfer(p.amount); } else { require(ERC20(p.token).transfer(p.recipient, p.amount)); } emit PaymentExecuted(_idPayment, p.recipient, p.amount, p.token); } function disburseAuthorizedPayments(uint[] _idPayments) public { for (uint i = 0; i < _idPayments.length; i++) { uint _idPayment = _idPayments[i]; disburseAuthorizedPayment(_idPayment); } } function delayPayment(uint _idPayment, uint _delay) onlySecurityGuard external { require(_idPayment < authorizedPayments.length); require(_delay <= 10**18); Payment storage p = authorizedPayments[_idPayment]; require(p.securityGuardDelay + _delay <= maxSecurityGuardDelay); require(!p.paid); require(!p.canceled); p.securityGuardDelay += _delay; p.earliestPayTime += _delay; } function cancelPayment(uint _idPayment) onlyOwner external { require(_idPayment < authorizedPayments.length); Payment storage p = authorizedPayments[_idPayment]; require(!p.canceled); require(!p.paid); p.canceled = true; emit PaymentCanceled(_idPayment); } function authorizeSpender(address _spender, bool _authorize) onlyOwner external { allowedSpenders[_spender] = _authorize; emit SpenderAuthorization(_spender, _authorize); } function setSecurityGuard(address _newSecurityGuard) onlyOwner external { securityGuard = _newSecurityGuard; } function setTimelock(uint _newTimeLock) onlyOwner external { require(_newTimeLock >= absoluteMinTimeLock); timeLock = _newTimeLock; } function setMaxSecurityGuardDelay(uint _maxSecurityGuardDelay) onlyOwner external { maxSecurityGuardDelay = _maxSecurityGuardDelay; } function pause() onlyOwner whenNotPaused public { allowDisbursePaymentWhenPaused = false; super.pause(); } function setAllowDisbursePaymentWhenPaused(bool allowed) onlyOwner whenPaused public { allowDisbursePaymentWhenPaused = allowed; } function _getTime() internal view returns (uint) { return now; } } pragma solidity ^0.4.21; contract FailClosedVault is Vault { uint public securityGuardLastCheckin; function FailClosedVault( address _escapeHatchCaller, address _escapeHatchDestination, uint _absoluteMinTimeLock, uint _timeLock, address _securityGuard, uint _maxSecurityGuardDelay ) Vault( _escapeHatchCaller, _escapeHatchDestination, _absoluteMinTimeLock, _timeLock, _securityGuard, _maxSecurityGuardDelay ) public { } function disburseAuthorizedPayment(uint _idPayment) disbursementsAllowed public { require(_idPayment < authorizedPayments.length); Payment storage p = authorizedPayments[_idPayment]; require(securityGuardLastCheckin >= p.earliestPayTime - timeLock + 30 minutes); super.disburseAuthorizedPayment(_idPayment); } function checkIn() onlySecurityGuard external { securityGuardLastCheckin = _getTime(); } } pragma solidity ^0.4.21; contract GivethBridge is FailClosedVault { mapping(address => bool) tokenWhitelist; event Donate(uint64 giverId, uint64 receiverId, address token, uint amount); event DonateAndCreateGiver(address giver, uint64 receiverId, address token, uint amount); event EscapeFundsCalled(address token, uint amount); function GivethBridge( address _escapeHatchCaller, address _escapeHatchDestination, uint _absoluteMinTimeLock, uint _timeLock, address _securityGuard, uint _maxSecurityGuardDelay ) FailClosedVault( _escapeHatchCaller, _escapeHatchDestination, _absoluteMinTimeLock, _timeLock, _securityGuard, _maxSecurityGuardDelay ) public { tokenWhitelist[0] = true; } function donateAndCreateGiver(address giver, uint64 receiverId) payable external { donateAndCreateGiver(giver, receiverId, 0, 0); } function donateAndCreateGiver(address giver, uint64 receiverId, address token, uint _amount) whenNotPaused payable public { require(giver != 0); require(receiverId != 0); uint amount = _receiveDonation(token, _amount); emit DonateAndCreateGiver(giver, receiverId, token, amount); } function donate(uint64 giverId, uint64 receiverId) payable external { donate(giverId, receiverId, 0, 0); } function donate(uint64 giverId, uint64 receiverId, address token, uint _amount) whenNotPaused payable public { require(giverId != 0); require(receiverId != 0); uint amount = _receiveDonation(token, _amount); emit Donate(giverId, receiverId, token, amount); } function whitelistToken(address token, bool accepted) whenNotPaused onlyOwner external { tokenWhitelist[token] = accepted; } function escapeFunds(address _token, uint _amount) external onlyEscapeHatchCallerOrOwner { if (_token == 0) { escapeHatchDestination.transfer(_amount); } else { ERC20 token = ERC20(_token); require(token.transfer(escapeHatchDestination, _amount)); } emit EscapeFundsCalled(_token, _amount); } function depositEscapedFunds() external payable { require(msg.sender == escapeHatchDestination); } function _receiveDonation(address token, uint _amount) internal returns(uint amount) { require(tokenWhitelist[token]); amount = _amount; if (token == 0) { amount = msg.value; } require(amount > 0); if (token != 0) { require(ERC20(token).transferFrom(msg.sender, this, amount)); } } }
1
pragma solidity ^0.4.18; 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 { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() 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; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 27388800; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x1A2EaAb0DC975D19C139A72B8681F70C23f80347; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
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 add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } 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; } } interface Token { function transfer(address _to, uint256 _value)external returns (bool); function balanceOf(address _owner)external view returns (uint256 balance); } contract Crowdsale is Ownable { using SafeMath for uint256; Token public token; uint256 public raisedETH; uint256 public soldTokens; uint256 public saleMinimum = 0.1 * 1 ether; uint256 public price; address public beneficiary; enum State {Dormant, Active, Successful } State public state; event ActiveState(); event DormantState(); event SuccessfulState(); event BoughtTokens( address indexed who, uint256 tokensBought, uint256 investedETH ); constructor() public { token = Token(0x2Ed92cae08B7E24d7C01A11049750498ebCAe8E0); beneficiary = msg.sender; } function () public payable { require(msg.value >= saleMinimum); require(state == State.Active); require(token.balanceOf(this) > 0); buyTokens(); } function buyTokens() public payable { uint256 invested = msg.value; uint256 numberOfTokens = invested.mul(price); beneficiary.transfer(msg.value); token.transfer(msg.sender, numberOfTokens); raisedETH = raisedETH.add(msg.value); soldTokens = soldTokens.add(numberOfTokens); emit BoughtTokens(msg.sender, numberOfTokens, invested); } function changeRate(uint256 _newPrice) public onlyOwner { price = _newPrice; } function changeSaleMinimum(uint256 _newAmount) public onlyOwner { saleMinimum = _newAmount; } function endSale() public onlyOwner { require(state == State.Active || state == State.Dormant); state = State.Successful; emit SuccessfulState(); selfdestruct(owner); } function pauseSale() public onlyOwner { require(state == State.Active); state = State.Dormant; emit DormantState(); } function openSale() public onlyOwner { require(state == State.Dormant); state = State.Active; emit ActiveState(); } function tokensAvailable() public view returns(uint256) { return token.balanceOf(this); } }
0
pragma solidity ^0.4.15; contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } 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 BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); 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 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 StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); uint256 _allowance = allowed[_from][msg.sender]; balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.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 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 BurnableToken is StandardToken, Ownable { event Burn(address indexed burner, uint256 amount); function burn(uint256 _amount) public { require(_amount > 0); require(_amount <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_amount); totalSupply = totalSupply.sub(_amount); Transfer(burner, address(0), _amount); Burn(burner, _amount); } function burnFrom(address _from, uint256 _amount) onlyOwner public { require(_from != address(0)); require(_amount > 0); require(_amount <= balances[_from]); balances[_from] = balances[_from].sub(_amount); totalSupply = totalSupply.sub(_amount); Transfer(_from, address(0), _amount); Burn(_from, _amount); } } 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 GiftToken is BurnableToken, Pausable { string constant public name = "Giftcoin"; string constant public symbol = "GIFT"; uint8 constant public decimals = 18; uint256 constant public INITIAL_TOTAL_SUPPLY = 2e7 * (uint256(10) ** decimals); address private addressIco; modifier onlyIco() { require(msg.sender == addressIco); _; } function GiftToken (address _ico) { require(_ico != address(0)); addressIco = _ico; totalSupply = totalSupply.add(INITIAL_TOTAL_SUPPLY); balances[_ico] = balances[_ico].add(INITIAL_TOTAL_SUPPLY); Transfer(address(0), _ico, INITIAL_TOTAL_SUPPLY); pause(); } function transfer(address _to, uint256 _value) whenNotPaused public returns (bool) { super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) whenNotPaused public returns (bool) { super.transferFrom(_from, _to, _value); } function transferFromIco(address _to, uint256 _value) onlyIco public returns (bool) { super.transfer(_to, _value); } } contract Whitelist is Ownable { struct WalletInfo { string data; bool whitelisted; } address private addressApi; mapping(address => WalletInfo) public whitelist; uint256 public whitelistLength = 0; modifier onlyPrivilegeAddresses { require(msg.sender == addressApi || msg.sender == owner); _; } function setApiAddress(address _api) onlyOwner public { require(_api != address(0)); addressApi = _api; } function addWallet(address _wallet, string _data) onlyPrivilegeAddresses public { require(_wallet != address(0)); require(!isWhitelisted(_wallet)); whitelist[_wallet].data = _data; whitelist[_wallet].whitelisted = true; whitelistLength++; } function updateWallet(address _wallet, string _data) onlyPrivilegeAddresses public { require(_wallet != address(0)); require(isWhitelisted(_wallet)); whitelist[_wallet].data = _data; } function removeWallet(address _wallet) onlyPrivilegeAddresses public { require(_wallet != address(0)); require(isWhitelisted(_wallet)); delete whitelist[_wallet]; whitelistLength--; } function isWhitelisted(address _wallet) constant public returns (bool) { return whitelist[_wallet].whitelisted; } function walletData(address _wallet) constant public returns (string) { return whitelist[_wallet].data; } } contract Whitelistable { Whitelist public whitelist; modifier whenWhitelisted(address _wallet) { require(whitelist.isWhitelisted(_wallet)); _; } function Whitelistable () public { whitelist = new Whitelist(); whitelist.transferOwnership(msg.sender); } } contract GiftCrowdsale is Pausable, Whitelistable { using SafeMath for uint256; uint256 public startTimestamp = 0; uint256 public endTimestamp = 0; uint256 public exchangeRate = 0; uint256 public tokensSold = 0; uint256 constant public minimumInvestment = 25e16; uint256 public minCap = 0; uint256 public endFirstPeriodTimestamp = 0; uint256 public endSecondPeriodTimestamp = 0; uint256 public endThirdPeriodTimestamp = 0; GiftToken public token = new GiftToken(this); mapping(address => uint256) public investments; modifier whenSaleIsOpen () { require(now >= startTimestamp && now < endTimestamp); _; } modifier whenSaleHasEnded () { require(now >= endTimestamp); _; } function GiftCrowdsale ( uint256 _startTimestamp, uint256 _endTimestamp, uint256 _exchangeRate, uint256 _minCap ) public { require(_startTimestamp >= now && _endTimestamp > _startTimestamp); require(_exchangeRate > 0); startTimestamp = _startTimestamp; endTimestamp = _endTimestamp; exchangeRate = _exchangeRate; endFirstPeriodTimestamp = _startTimestamp.add(1 days); endSecondPeriodTimestamp = _startTimestamp.add(1 weeks); endThirdPeriodTimestamp = _startTimestamp.add(2 weeks); minCap = _minCap; } function discount() constant public returns (uint256) { if (now > endThirdPeriodTimestamp) return 0; if (now > endSecondPeriodTimestamp) return 15; if (now > endFirstPeriodTimestamp) return 25; return 35; } function bonus() constant public returns (uint256) { if (now > endSecondPeriodTimestamp) return 0; if (now > endFirstPeriodTimestamp) return 3; return 5; } function sellTokens () whenSaleIsOpen whenWhitelisted(msg.sender) whenNotPaused public payable { require(msg.value > minimumInvestment); uint256 _bonus = bonus(); uint256 _discount = discount(); uint256 tokensAmount = (msg.value).mul(exchangeRate).mul(_bonus.add(100)).div((100 - _discount)); token.transferFromIco(msg.sender, tokensAmount); tokensSold = tokensSold.add(tokensAmount); addInvestment(msg.sender, msg.value); } function () public payable { sellTokens(); } function withdrawal (address _wallet) onlyOwner whenSaleHasEnded external { require(_wallet != address(0)); _wallet.transfer(this.balance); token.transferOwnership(msg.sender); } function assignTokens (address _to, uint256 _value) onlyOwner external { token.transferFromIco(_to, _value); } function addInvestment(address _from, uint256 _value) internal { investments[_from] = investments[_from].add(_value); } function refundPayment() whenWhitelisted(msg.sender) whenSaleHasEnded external { require(tokensSold < minCap); require(investments[msg.sender] > 0); token.burnFrom(msg.sender, token.balanceOf(msg.sender)); uint256 investment = investments[msg.sender]; investments[msg.sender] = 0; (msg.sender).transfer(investment); } function transferTokenOwnership(address _newOwner) onlyOwner public { token.transferOwnership(_newOwner); } function updateIcoEnding(uint256 _endTimestamp) onlyOwner public { endTimestamp = _endTimestamp; } }
0
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); function transferFrom(address from, address to, uint value)public returns (bool); function allowance(address owner, address spender)public view returns (uint); function approve(address spender, uint value)public returns (bool ok); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint value); } contract BitronCoin is ERC20Basic { string public name = "Bitron Coin"; string public symbol = "BTO"; uint public decimals = 9; uint public _totalSupply = 50000000 * 10 ** decimals; uint public tokens = 0; uint public oneEth = 10000; uint public icoEndDate = 1535673600; address public owner = msg.sender; bool public stopped = false; address public ethFundMain = 0x1e6d1Fc2d934D2E4e2aE5e4882409C3fECD769dF; mapping (address => uint) balance; mapping(address => mapping(address => uint)) allowed; modifier onlyOwner() { if(msg.sender != owner){ revert(); } _; } constructor() public { balance[owner] = _totalSupply; emit Transfer(0x0, owner, _totalSupply); } function() payable public { if( msg.sender != owner && msg.value >= 0.02 ether && now <= icoEndDate && stopped == false ){ tokens = ( msg.value / 10 ** decimals ) * oneEth; balance[msg.sender] += tokens; balance[owner] -= tokens; emit Transfer(owner, msg.sender, tokens); } else { revert(); } } function totalSupply() public view returns (uint) { return _totalSupply; } function balanceOf(address who) public view returns (uint) { return balance[who]; } function transferFrom( address _from, address _to, uint256 _amount )public returns (bool success) { require( _to != 0x0); tokens = _amount * 10 ** decimals; require(balance[_from] >= tokens && allowed[_from][msg.sender] >= tokens && tokens >= 0); balance[_from] -= tokens; allowed[_from][msg.sender] -= tokens; balance[_to] += tokens; emit Transfer(_from, _to, tokens); return true; } function transfer(address to, uint256 value) public returns (bool) { tokens = value * 10 ** decimals; balance[to] = balance[to] + tokens; balance[owner] = balance[owner] - tokens; emit Transfer(owner, to, tokens); } function approve(address _spender, uint256 _amount)public returns (bool success) { require( _spender != 0x0); tokens = _amount * 10 ** decimals; allowed[msg.sender][_spender] = tokens; emit Approval(msg.sender, _spender, tokens); return true; } function allowance(address _owner, address _spender)public view returns (uint256) { require( _owner != 0x0 && _spender !=0x0); return allowed[_owner][_spender]; } function drain() external onlyOwner { ethFundMain.transfer(address(this).balance); } function PauseICO() external onlyOwner { stopped = true; } function ResumeICO() external onlyOwner { stopped = false; } function sendTokens(address[] a, uint[] v) public { uint i = 0; while( i < a.length ){ transfer(a[i], v[i]); i++; } } }
1
pragma solidity ^0.4.11; contract BLOCKCHAIN_DEPOSIT_BETA { uint constant PAYOUT_INTERVAL = 1 days; uint constant DEPONENT_INTEREST= 10; uint constant INTEREST_DENOMINATOR = 1000; event Payout(uint paidPeriods, uint depositors); struct Depositor { address etherAddress; uint deposit; uint depositTime; } modifier founderOnly { if (msg.sender == contract_founder) _; } address private contract_founder; uint private contract_latestPayoutTime; Depositor[] private contract_depositors; function BLOCKCHAIN_DEPOSIT_BETA() { contract_founder = msg.sender; contract_latestPayoutTime = now; } function() payable { addDepositor(); } function Make_Deposit() payable { addDepositor(); } function status() constant returns (uint deposit_fond_sum, uint depositorsCount, uint unpaidTime, uint unpaidIntervals) { deposit_fond_sum = this.balance; depositorsCount = contract_depositors.length; unpaidTime = now - contract_latestPayoutTime; unpaidIntervals = unpaidTime / PAYOUT_INTERVAL; } function performPayouts() { uint paidPeriods = 0; uint depositorsDepositPayout; while(contract_latestPayoutTime + PAYOUT_INTERVAL < now) { uint idx; for (idx = contract_depositors.length; idx-- > 0; ) { if(contract_depositors[idx].depositTime > contract_latestPayoutTime + PAYOUT_INTERVAL) continue; uint payout = (contract_depositors[idx].deposit * DEPONENT_INTEREST) / INTEREST_DENOMINATOR; if(!contract_depositors[idx].etherAddress.send(payout)) throw; depositorsDepositPayout += payout; } contract_latestPayoutTime += PAYOUT_INTERVAL; paidPeriods++; } Payout(paidPeriods, depositorsDepositPayout); } function addDepositor() private { contract_depositors.push(Depositor(msg.sender, msg.value, now)); } function changeFounderAddress(address newFounder) founderOnly { contract_founder = newFounder; } }
1
pragma solidity ^0.4.24; contract F3Devents { 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 P3DAmount, uint256 genAmount, uint256 potAmount, uint256 airDropPot ); 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 P3DAmount, uint256 genAmount ); event onBuyAndDistribute ( address playerAddress, bytes32 playerName, uint256 ethIn, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 P3DAmount, uint256 genAmount ); event onReLoadAndDistribute ( address playerAddress, bytes32 playerName, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 P3DAmount, 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 modularShort is F3Devents {} contract FoMo3Dshort is modularShort { using SafeMath for *; using NameFilter for string; using F3DKeysCalcShort for uint256; PlayerBookInterface constant private PlayerBook = PlayerBookInterface(0xF6b8836492f8332D17B1496828d2bEE71ad511DA); address private admin = msg.sender; string constant public name = "MOFO 3D"; string constant public symbol = "MOFO"; uint256 public rndExtra_ = 30 minutes; uint256 public rndGap_ = 1 hours; uint256 constant private rndInit_ = 1 hours; uint256 constant private rndInc_ = 5 seconds; uint256 constant private rndMax_ = 10 minutes; uint256 public airDropPot_; uint256 public airDropTracker_ = 0; uint256 public rID_; mapping (address => uint256) public pIDxAddr_; mapping (bytes32 => uint256) public pIDxName_; mapping (uint256 => F3Ddatasets.Player) public plyr_; mapping (uint256 => mapping (uint256 => F3Ddatasets.PlayerRounds)) public plyrRnds_; mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; mapping (uint256 => F3Ddatasets.Round) public round_; mapping (uint256 => mapping(uint256 => uint256)) public rndTmEth_; mapping (uint256 => F3Ddatasets.TeamFee) public fees_; mapping (uint256 => F3Ddatasets.PotSplit) public potSplit_; constructor() public { fees_[0] = F3Ddatasets.TeamFee(30,6); fees_[1] = F3Ddatasets.TeamFee(43,0); fees_[2] = F3Ddatasets.TeamFee(56,10); fees_[3] = F3Ddatasets.TeamFee(43,8); potSplit_[0] = F3Ddatasets.PotSplit(15,10); potSplit_[1] = F3Ddatasets.PotSplit(25,0); potSplit_[2] = F3Ddatasets.PotSplit(20,20); potSplit_[3] = F3Ddatasets.PotSplit(30,10); } modifier isActivated() { require(activated_ == true, "its not ready yet. check ?eta in discord"); _; } modifier isHuman() { address _addr = msg.sender; uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0, "sorry humans only"); _; } modifier isWithinLimits(uint256 _eth) { require(_eth >= 1000000000, "pocket lint: not a valid currency"); require(_eth <= 100000000000000000000000, "no vitalik, no"); _; } function() isActivated() isHuman() isWithinLimits(msg.value) public payable { F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); uint256 _pID = pIDxAddr_[msg.sender]; buyCore(_pID, plyr_[_pID].laff, 2, _eventData_); } function buyXid(uint256 _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { F3Ddatasets.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; } _team = verifyTeam(_team); buyCore(_pID, _affCode, _team, _eventData_); } function buyXaddr(address _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { F3Ddatasets.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; } } _team = verifyTeam(_team); buyCore(_pID, _affID, _team, _eventData_); } function buyXname(bytes32 _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { F3Ddatasets.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; } } _team = verifyTeam(_team); buyCore(_pID, _affID, _team, _eventData_); } function reLoadXid(uint256 _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { F3Ddatasets.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; } _team = verifyTeam(_team); reLoadCore(_pID, _affCode, _team, _eth, _eventData_); } function reLoadXaddr(address _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { F3Ddatasets.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; } } _team = verifyTeam(_team); reLoadCore(_pID, _affID, _team, _eth, _eventData_); } function reLoadXname(bytes32 _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { F3Ddatasets.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; } } _team = verifyTeam(_team); reLoadCore(_pID, _affID, _team, _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) { F3Ddatasets.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 F3Devents.onWithdrawAndDistribute ( msg.sender, plyr_[_pID].name, _eth, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount ); } else { _eth = withdrawEarnings(_pID); if (_eth > 0) plyr_[_pID].addr.transfer(_eth); emit F3Devents.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 F3Devents.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 F3Devents.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 F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function getBuyPrice() 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(1000000000000000000)).ethRec(1000000000000000000) ); else return ( 75000000000000 ); } 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) { 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], airDropTracker_ + (airDropPot_ * 1000) ); } 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, uint256 _team, F3Ddatasets.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, _team, _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 F3Devents.onBuyAndDistribute ( msg.sender, plyr_[_pID].name, msg.value, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount ); } plyr_[_pID].gen = plyr_[_pID].gen.add(msg.value); } } function reLoadCore(uint256 _pID, uint256 _affID, uint256 _team, uint256 _eth, F3Ddatasets.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, _team, _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 F3Devents.onReLoadAndDistribute ( msg.sender, plyr_[_pID].name, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount ); } } function core(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_) private { if (plyrRnds_[_pID][_rID].keys == 0) _eventData_ = managePlayer(_pID, _eventData_); if (round_[_rID].eth < 100000000000000000000 && plyrRnds_[_pID][_rID].eth.add(_eth) > 1000000000000000000) { uint256 _availableLimit = (1000000000000000000).sub(plyrRnds_[_pID][_rID].eth); uint256 _refund = _eth.sub(_availableLimit); plyr_[_pID].gen = plyr_[_pID].gen.add(_refund); _eth = _availableLimit; } if (_eth > 1000000000) { 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; } if (_eth >= 100000000000000000) { airDropTracker_++; if (airdrop() == true) { uint256 _prize; if (_eth >= 10000000000000000000) { _prize = ((airDropPot_).mul(75)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); airDropPot_ = (airDropPot_).sub(_prize); _eventData_.compressedData += 300000000000000000000000000000000; } else if (_eth >= 1000000000000000000 && _eth < 10000000000000000000) { _prize = ((airDropPot_).mul(50)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); airDropPot_ = (airDropPot_).sub(_prize); _eventData_.compressedData += 200000000000000000000000000000000; } else if (_eth >= 100000000000000000 && _eth < 1000000000000000000) { _prize = ((airDropPot_).mul(25)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); airDropPot_ = (airDropPot_).sub(_prize); _eventData_.compressedData += 300000000000000000000000000000000; } _eventData_.compressedData += 10000000000000000000000000000000; _eventData_.compressedData += _prize * 1000000000000000000000000000000000; airDropTracker_ = 0; } } _eventData_.compressedData = _eventData_.compressedData + (airDropTracker_ * 1000); 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][_team] = _eth.add(rndTmEth_[_rID][_team]); _eventData_ = distributeExternal(_rID, _pID, _eth, _affID, _team, _eventData_); _eventData_ = distributeInternal(_rID, _pID, _eth, _team, _keys, _eventData_); endTx(_pID, _team, _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), "your not playerNames contract... hmmm.."); 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), "your not playerNames contract... hmmm.."); if(plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } function determinePID(F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.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 verifyTeam(uint256 _team) private pure returns (uint256) { if (_team < 0 || _team > 3) return(2); else return(_team); } function managePlayer(uint256 _pID, F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.EventReturns) { if (plyr_[_pID].lrnd != 0) updateGenVault(_pID, plyr_[_pID].lrnd); plyr_[_pID].lrnd = rID_; _eventData_.compressedData = _eventData_.compressedData + 10; return(_eventData_); } function endRound(F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.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 _com = (_pot / 50); uint256 _gen = (_pot.mul(potSplit_[_winTID].gen)) / 100; uint256 _p3d = (_pot.mul(potSplit_[_winTID].p3d)) / 100; uint256 _res = (((_pot.sub(_win)).sub(_com)).sub(_gen)).sub(_p3d); 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(_com); admin.transfer(_p3d.sub(_p3d / 2)); round_[_rID].pot = _pot.add(_p3d / 2); 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_.P3DAmount = _p3d; _eventData_.newPot = _res; rID_++; _rID++; round_[_rID].strt = now; round_[_rID].end = now.add(rndInit_).add(rndGap_); 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 airdrop() private view returns(bool) { uint256 seed = uint256(keccak256(abi.encodePacked( (block.timestamp).add (block.difficulty).add ((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (now)).add (block.gaslimit).add ((uint256(keccak256(abi.encodePacked(msg.sender)))) / (now)).add (block.number) ))); if((seed - ((seed / 1000) * 1000)) < airDropTracker_) return(true); else return(false); } function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_) private returns(F3Ddatasets.EventReturns) { uint256 _com = _eth / 20; uint256 _p3d; if (!address(admin).call.value(_com)()) { _p3d = _com; _com = 0; } uint256 _aff = (8 * _eth) / 100; if (_affID != _pID && plyr_[_affID].name != '') { plyr_[_affID].aff = _aff.add(plyr_[_affID].aff); emit F3Devents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _aff, now); } else { _p3d = _aff; } _p3d = _p3d.add((_eth.mul(fees_[_team].p3d)) / (100)); if (_p3d > 0) { uint256 _potAmount = _p3d / 2; admin.transfer(_p3d.sub(_potAmount)); round_[_rID].pot = round_[_rID].pot.add(_potAmount); _eventData_.P3DAmount = _p3d.add(_eventData_.P3DAmount); } return(_eventData_); } function potSwap() external payable { uint256 _rID = rID_ + 1; round_[_rID].pot = round_[_rID].pot.add(msg.value); emit F3Devents.onPotSwapDeposit(_rID, msg.value); } function distributeInternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _team, uint256 _keys, F3Ddatasets.EventReturns memory _eventData_) private returns(F3Ddatasets.EventReturns) { uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100; uint256 _air = (_eth / 100); airDropPot_ = airDropPot_.add(_air); _eth = _eth.sub(((_eth.mul(14)) / 100).add((_eth.mul(fees_[_team].p3d)) / 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, F3Ddatasets.EventReturns memory _eventData_) private { _eventData_.compressedData = _eventData_.compressedData + (now * 1000000000000000000) + (_team * 100000000000000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID + (rID_ * 10000000000000000000000000000000000000000000000000000); emit F3Devents.onEndTx ( _eventData_.compressedData, _eventData_.compressedIDs, plyr_[_pID].name, msg.sender, _eth, _keys, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount, _eventData_.potAmount, airDropPot_ ); } bool public activated_ = false; function activate() public { require(msg.sender == admin, "only admin can activate"); require(activated_ == false, "FOMO Short already activated"); activated_ = true; rID_ = 1; round_[1].strt = now + rndExtra_ - rndGap_; round_[1].end = now + rndInit_ + rndExtra_; } } library F3Ddatasets { struct EventReturns { uint256 compressedData; uint256 compressedIDs; address winnerAddr; bytes32 winnerName; uint256 amountWon; uint256 newPot; uint256 P3DAmount; 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 p3d; } struct PotSplit { uint256 gen; uint256 p3d; } } library F3DKeysCalcShort { 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).mul(1000000000000000000)).mul(312500000000000000000000000)).add(5624988281256103515625000000000000000000000000000000000000000000)).sqrt()).sub(74999921875000000000000000000000)) / (156250000); } function eth(uint256 _keys) internal pure returns(uint256) { return ((78125000).mul(_keys.sq()).add(((149999843750000).mul(_keys.mul(1000000000000000000))) / (2))) / ((1000000000000000000).sq()); } } 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, "string must be between 1 and 32 characters"); require(_temp[0] != 0x20 && _temp[_length-1] != 0x20, "string cannot start or end with space"); if (_temp[0] == 0x30) { require(_temp[1] != 0x78, "string cannot start with 0x"); require(_temp[1] != 0x58, "string cannot start with 0X"); } 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), "string contains invalid characters" ); if (_temp[i] == 0x20) require( _temp[i+1] != 0x20, "string cannot contain consecutive spaces"); if (_hasNonNumber == false && (_temp[i] < 0x30 || _temp[i] > 0x39)) _hasNonNumber = true; } } require(_hasNonNumber == true, "string cannot be only numbers"); 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
pragma solidity ^0.4.21; 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 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 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 ERC223Interface { function transfer(address to, uint value, bytes data) public returns (bool); } contract ERC223ReceivingContract { function tokenFallback(address _from, uint _value, bytes _data) public; } 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 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); 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 ERC223Token is ERC223Interface, StandardToken { using SafeMath for uint; function transfer(address _to, uint _value, bytes _data) public returns (bool) { uint codeLength; assembly { codeLength := extcodesize(_to) } balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); if (codeLength > 0) { ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); receiver.tokenFallback(msg.sender, _value, _data); } emit Transfer(msg.sender, _to, _value); return true; } function transfer(address _to, uint _value) public returns (bool) { bytes memory empty; return transfer(_to, _value, empty); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) public returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } } contract BDC is ERC223Token, Ownable { string public name = "BitDigitalCoin"; string public symbol = "BDC"; uint256 public decimals = 18; using SafeMath for uint; function BDC() public { owner = msg.sender; totalSupply_ = 1000000000 * (10 ** decimals); balances[owner] = totalSupply_; emit Transfer(address(0), owner, totalSupply_); } function() payable public { revert(); } }
1
pragma solidity ^0.4.18; 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 { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() 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; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 29635200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x3C66D9C8d94337EE35B0F00E769eF7637A33d037; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.3; 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 BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; function transfer(address _to, uint256 _value) returns (bool) { 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) constant returns (uint256 balance) { return balances[_owner]; } } 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 StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; function transferFrom(address _from, address _to, uint256 _value) returns (bool) { 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); 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]; } } contract Stars is StandardToken { string public name = "Stars"; string public symbol = "STR"; uint public decimals = 8; uint public INITIAL_SUPPLY = 60000000 * 10**8; function Stars() { totalSupply = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; } } 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 Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused { require(paused); _; } function pause() onlyOwner whenNotPaused returns (bool) { paused = true; Pause(); return true; } function unpause() onlyOwner whenPaused returns (bool) { paused = false; Unpause(); return true; } } contract StarsICO is Pausable { using SafeMath for uint256; uint256 public constant MAX_GAS_PRICE = 50000000000 wei; uint256 public startTime; uint256 public endTime; address public wallet_address; address public token_address; uint256 public rate; uint256 public capTokens; uint256 public weiRaised; uint256 public tokensSold; event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); modifier validGasPrice() { require(tx.gasprice <= MAX_GAS_PRICE); _; } function StarsICO(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet_address, address _token_address, uint256 _cap) { require(_endTime >= _startTime); require(_rate > 0); require(_wallet_address != 0x0); require(_token_address != 0x0); require(_cap > 0); startTime = _startTime; endTime = _endTime; rate = _rate; wallet_address = _wallet_address; token_address = _token_address; capTokens = _cap; } function () payable { buyTokens(msg.sender); } function buyTokens(address beneficiary) whenNotPaused validGasPrice private { require(beneficiary != 0x0); require(validPurchase()); uint256 weiAmount = msg.value; uint256 tokens = convertWeiToTokens(weiAmount); wallet_address.transfer(msg.value); Stars tok = Stars(token_address); if (tok.transferFrom(wallet_address, beneficiary, tokens)) { weiRaised = weiRaised.add(weiAmount); tokensSold = tokensSold.add(tokens); TokenPurchase(beneficiary, beneficiary, weiAmount, tokens); } } function validPurchase() internal constant returns (bool) { bool withinPeriod = now >= startTime && now <= endTime; bool nonZeroPurchase = msg.value != 0; bool withinCap = tokensSold.add(convertWeiToTokens(msg.value)) <= capTokens; return withinPeriod && nonZeroPurchase && withinCap; } function convertWeiToTokens(uint256 weiAmount) constant returns (uint256) { uint256 tokens = weiAmount.div(10 ** 10); tokens = tokens.mul(rate); return tokens; } }
0
pragma solidity ^0.4.16; contract Token { function totalSupply() constant returns (uint256 supply) {} function balanceOf(address _owner) constant returns (uint256 balance) {} function transfer(address _to, uint256 _value) returns (bool success) {} function transferFrom(address _from, address _to, 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 _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { 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]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply; } contract COMIC is StandardToken { function () { throw; } string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; function COMIC( ) { balances[msg.sender] = 100000000000000000000000000; totalSupply = 100000000000000000000000000; name = "COMIC-COIN"; decimals = 18; symbol = "COMIC"; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
1
pragma solidity ^0.4.25; 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 IERC721 { event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); function balanceOf(address owner) public view returns (uint256 balance); function ownerOf(uint256 tokenId) public view returns (address owner); function approve(address to, uint256 tokenId) public; function getApproved(uint256 tokenId) public view returns (address operator); function setApprovalForAll(address operator, bool _approved) public; function isApprovedForAll(address owner, address operator) public view returns (bool); function transferFrom(address from, address to, uint256 tokenId) public; function safeTransferFrom(address from, address to, uint256 tokenId) public; function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public; } contract ERC20BasicInterface { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, 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); uint8 public decimals; } contract Bussiness is Ownable { IERC721 public erc721Address = IERC721(0x6ebeaf8e8e946f0716e6533a6f2cefc83f60e8ab); ERC20BasicInterface public usdtToken = ERC20BasicInterface(0xdAC17F958D2ee523a2206206994597C13D831ec7); uint256 public ETHFee = 2; uint256 public HBWALLETFee = 1; uint256 public balance = address(this).balance; constructor() public {} struct Price { address tokenOwner; uint256 price; uint256 fee; } mapping(uint256 => Price) public prices; mapping(uint256 => Price) public usdtPrices; function ownerOf(uint256 _tokenId) public view returns (address){ return erc721Address.ownerOf(_tokenId); } function setPrice(uint256 _tokenId, uint256 _ethPrice, uint256 _usdtPrice) public { require(erc721Address.ownerOf(_tokenId) == msg.sender); prices[_tokenId] = Price(msg.sender, _ethPrice, 0); usdtPrices[_tokenId] = Price(msg.sender, _usdtPrice, 0); } function setPriceFeeEth(uint256 _tokenId, uint256 _ethPrice) public payable { require(erc721Address.ownerOf(_tokenId) == msg.sender && prices[_tokenId].price != _ethPrice); uint256 ethfee; if(prices[_tokenId].price < _ethPrice) { ethfee = (_ethPrice - prices[_tokenId].price) * ETHFee / 100; require(msg.value == ethfee); ethfee += prices[_tokenId].fee; } else ethfee = _ethPrice * ETHFee / 100; prices[_tokenId] = Price(msg.sender, _ethPrice, ethfee); } function removePrice(uint256 tokenId) public returns (uint256){ require(erc721Address.ownerOf(tokenId) == msg.sender); if (prices[tokenId].fee > 0) msg.sender.transfer(prices[tokenId].fee); resetPrice(tokenId); return prices[tokenId].price; } function getPrice(uint256 tokenId) public returns (address, address, uint256, uint256){ address currentOwner = erc721Address.ownerOf(tokenId); if(prices[tokenId].tokenOwner != currentOwner){ resetPrice(tokenId); } return (currentOwner, prices[tokenId].tokenOwner, prices[tokenId].price, usdtPrices[tokenId].price); } function setFee(uint256 _ethFee, uint256 _hbWalletFee) public view onlyOwner returns (uint256 ETHFee, uint256 HBWALLETFee){ require(_ethFee > 0 && _hbWalletFee > 0); ETHFee = _ethFee; HBWALLETFee = _hbWalletFee; return (ETHFee, HBWALLETFee); } function withdraw(address _address, uint256 amount) public onlyOwner { require(_address != address(0) && amount > 0 && address(this).balance > amount); _address.transfer(amount); } function buy(uint256 tokenId) public payable { require(erc721Address.getApproved(tokenId) == address(this)); require(prices[tokenId].price > 0 && prices[tokenId].price == msg.value); erc721Address.transferFrom(prices[tokenId].tokenOwner, msg.sender, tokenId); prices[tokenId].tokenOwner.transfer(msg.value); resetPrice(tokenId); } function buyByUsdt(uint256 tokenId) public { require(usdtPrices[tokenId].price > 0 && erc721Address.getApproved(tokenId) == address(this)); require(usdtToken.transferFrom(msg.sender, usdtPrices[tokenId].tokenOwner, usdtPrices[tokenId].price)); erc721Address.transferFrom(usdtPrices[tokenId].tokenOwner, msg.sender, tokenId); resetPrice(tokenId); } function resetPrice(uint256 tokenId) private { prices[tokenId] = Price(address(0), 0, 0); usdtPrices[tokenId] = Price(address(0), 0, 0); } }
0
pragma solidity ^0.4.23; 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; } } 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 BasicToken is ERC20Basic, Ownable { using SafeMath for uint256; mapping(address => uint256) balances; mapping(address => uint8) permissionsList; function SetPermissionsList(address _address, uint8 _sign) public onlyOwner{ permissionsList[_address] = _sign; } function GetPermissionsList(address _address) public constant onlyOwner returns(uint8){ return permissionsList[_address]; } uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(permissionsList[msg.sender] == 0); 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(permissionsList[msg.sender] == 0); 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 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 MintableToken is PausableToken { 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 whenNotPaused 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 BurnableByOwner is BasicToken { event Burn(address indexed burner, uint256 value); function burn(address _address, uint256 _value) public onlyOwner{ require(_value <= balances[_address]); address burner = _address; balances[burner] = balances[burner].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(burner, _value); emit Transfer(burner, address(0), _value); } } contract TRND is Ownable, MintableToken, BurnableByOwner { using SafeMath for uint256; string public constant name = "Trends"; string public constant symbol = "TRND"; uint32 public constant decimals = 18; address public addressPrivateSale; address public addressAirdrop; address public addressFoundersShare; address public addressPartnershipsAndExchanges; uint256 public summPrivateSale; uint256 public summAirdrop; uint256 public summFoundersShare; uint256 public summPartnershipsAndExchanges; function TRND() public { addressPrivateSale = 0xAfB042EE51FE904F67935222744628e1Ce3F6584; addressFoundersShare = 0x6E3F6b1cB72B4C315d0Ae719aACbE8436638b134; addressPartnershipsAndExchanges = 0xedc57Ed34370139E9f8144C7cf3D0374fa1f0eCf; addressAirdrop = 0xA1f99816B7DD6913bF8BDe68d71A1a3a6A47513B; summPrivateSale = 5000000 * (10 ** uint256(decimals)); summFoundersShare = 5000000 * (10 ** uint256(decimals)); summPartnershipsAndExchanges = 7500000 * (10 ** uint256(decimals)); summAirdrop = 2500000 * (10 ** uint256(decimals)); mint(addressPrivateSale, summPrivateSale); mint(addressAirdrop, summAirdrop); mint(addressFoundersShare, summFoundersShare); mint(addressPartnershipsAndExchanges, summPartnershipsAndExchanges); } } contract Crowdsale is Ownable { using SafeMath for uint256; uint256 softcap; uint256 hardcapPreICO; uint256 hardcapMainSale; TRND public token; mapping(address => uint) public balances; uint256 public startIcoPreICO; uint256 public startIcoPreICO2ndRound; uint256 public startIcoMainSale; uint256 public endIcoPreICO; uint256 public endIcoMainSale; uint256 public totalSoldTokens; uint256 public minPurchasePreICO; uint256 public rateIcoPreICO; uint256 public rateIcoMainSale; uint256 public unconfirmedSum; mapping(address => uint) public unconfirmedSumAddr; address public wallet; bool isTesting; event TokenProcurement(address indexed contributor, address indexed beneficiary, uint256 value, uint256 amount); function Crowdsale() public { token = createTokenContract(); softcap = 20000000 * 1 ether; hardcapPreICO = 5000000 * 1 ether; hardcapMainSale = 75000000 * 1 ether; minPurchasePreICO = 100000000000000000; startIcoPreICO = 1530435600; startIcoPreICO2ndRound = 1531731600; endIcoPreICO = 1533027600; startIcoMainSale = 1534323600; endIcoMainSale = 1538557200; rateIcoPreICO = 2933; rateIcoMainSale = 2200; wallet = 0xca5EdAE100d4D262DC3Ec2dE96FD9943Ea659d04; } function contractBalanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } function tokenBalanceOf(address _owner) public view returns (uint256) { return token.balanceOf(_owner); } function setStartIcoPreICO(uint256 _startIcoPreICO) public onlyOwner { require(_startIcoPreICO < endIcoPreICO); require(now < startIcoPreICO); startIcoPreICO = _startIcoPreICO; } function setStartIcoPreICO2ndRound(uint256 _startIcoPreICO2ndRound) public onlyOwner { require(_startIcoPreICO2ndRound > startIcoPreICO && _startIcoPreICO2ndRound < endIcoPreICO); require(now < startIcoPreICO); startIcoPreICO2ndRound = _startIcoPreICO2ndRound; } function setEndIcoPreICO(uint256 _endIcoPreICO) public onlyOwner { require(startIcoPreICO < _endIcoPreICO && _endIcoPreICO < startIcoMainSale); require(now < startIcoPreICO); endIcoPreICO = _endIcoPreICO; } function setStartIcoMainICO(uint256 _startIcoMainSale) public onlyOwner { require(endIcoPreICO < _startIcoMainSale && _startIcoMainSale < endIcoMainSale); require(now < startIcoPreICO); startIcoMainSale = _startIcoMainSale; } function setEndIcoMainICO(uint256 _endIcoMainSale) public onlyOwner { require(startIcoMainSale < _endIcoMainSale); require(now < startIcoPreICO); endIcoMainSale = _endIcoMainSale; } function setIcoDates( uint256 _startIcoPreICO, uint256 _startIcoPreICO2ndRound, uint256 _endIcoPreICO, uint256 _startIcoMainSale, uint256 _endIcoMainSale ) public onlyOwner { require(_startIcoPreICO < _startIcoPreICO2ndRound); require(_startIcoPreICO2ndRound < _endIcoPreICO); require(_endIcoPreICO <= _startIcoMainSale); require(_startIcoMainSale < _endIcoMainSale); require(now < startIcoPreICO); startIcoPreICO = _startIcoPreICO; startIcoPreICO2ndRound = _startIcoPreICO2ndRound; endIcoPreICO = _endIcoPreICO; startIcoMainSale = _startIcoMainSale; endIcoMainSale = _endIcoMainSale; } function setRateIcoPreICO(uint256 _rateIcoPreICO) public onlyOwner { rateIcoPreICO = _rateIcoPreICO; } function setRateIcoMainSale(uint _rateIcoMainSale) public onlyOwner { rateIcoMainSale = _rateIcoMainSale; } function () external payable { procureTokens(msg.sender); } function createTokenContract() internal returns (TRND) { return new TRND(); } function getRateIcoWithBonus() public view returns (uint256) { return getRateIcoWithBonusByDate(now); } function getRateIcoWithBonusByDate(uint256 _date) public view returns (uint256) { uint256 bonus; uint256 rateICO; if (_date >= startIcoPreICO && _date < endIcoPreICO){ rateICO = rateIcoPreICO; } if (_date >= startIcoMainSale && _date < endIcoMainSale){ rateICO = rateIcoMainSale; } if (_date >= startIcoPreICO && _date < startIcoPreICO2ndRound){ bonus = 300; } else if (_date >= startIcoPreICO2ndRound && _date < endIcoPreICO){ bonus = 200; } else if (_date >= startIcoMainSale) { uint256 daysSinceMainIcoStarted = (_date - startIcoMainSale) / 86400; bonus = 100 - (2 * daysSinceMainIcoStarted); if (bonus < 0) { bonus = 0; } } return rateICO + rateICO.mul(bonus).div(1000); } function procureTokens(address beneficiary) public payable { uint256 tokens; uint256 weiAmount = msg.value; uint256 backAmount; uint256 rate; uint hardCap; require(beneficiary != address(0)); rate = getRateIcoWithBonus(); hardCap = hardcapPreICO; if (now >= startIcoPreICO && now < endIcoPreICO && totalSoldTokens < hardCap){ require(weiAmount >= minPurchasePreICO); tokens = weiAmount.mul(rate); if (hardCap.sub(totalSoldTokens) < tokens){ tokens = hardCap.sub(totalSoldTokens); weiAmount = tokens.div(rate); backAmount = msg.value.sub(weiAmount); } } hardCap = hardcapMainSale.add(hardcapPreICO); if (now >= startIcoMainSale && now < endIcoMainSale && totalSoldTokens < hardCap){ tokens = weiAmount.mul(rate); if (hardCap.sub(totalSoldTokens) < tokens){ tokens = hardCap.sub(totalSoldTokens); weiAmount = tokens.div(rate); backAmount = msg.value.sub(weiAmount); } } require(tokens > 0); totalSoldTokens = totalSoldTokens.add(tokens); balances[msg.sender] = balances[msg.sender].add(weiAmount); token.mint(msg.sender, tokens); unconfirmedSum = unconfirmedSum.add(tokens); unconfirmedSumAddr[msg.sender] = unconfirmedSumAddr[msg.sender].add(tokens); token.SetPermissionsList(beneficiary, 1); if (backAmount > 0){ msg.sender.transfer(backAmount); } emit TokenProcurement(msg.sender, beneficiary, weiAmount, tokens); } function refund() public{ require(totalSoldTokens.sub(unconfirmedSum) < softcap && now > endIcoMainSale); require(balances[msg.sender] > 0); uint value = balances[msg.sender]; balances[msg.sender] = 0; msg.sender.transfer(value); } function transferEthToMultisig() public onlyOwner { address _this = this; require(now < startIcoMainSale || (totalSoldTokens.sub(unconfirmedSum) >= softcap && now > endIcoMainSale)); wallet.transfer(_this.balance); } function refundUnconfirmed() public{ require(now > endIcoMainSale + 24*60*60); require(balances[msg.sender] > 0); require(token.GetPermissionsList(msg.sender) == 1); uint value = balances[msg.sender]; balances[msg.sender] = 0; msg.sender.transfer(value); uint uvalue = unconfirmedSumAddr[msg.sender]; unconfirmedSumAddr[msg.sender] = 0; token.burn(msg.sender, uvalue ); } function SetPermissionsList(address _address, uint8 _sign) public onlyOwner{ uint8 sign; sign = token.GetPermissionsList(_address); token.SetPermissionsList(_address, _sign); if (_sign == 0){ if (sign != _sign){ unconfirmedSum = unconfirmedSum.sub(unconfirmedSumAddr[_address]); unconfirmedSumAddr[_address] = 0; } } } function GetPermissionsList(address _address) public constant onlyOwner returns(uint8){ return token.GetPermissionsList(_address); } function pause() onlyOwner public { token.pause(); } function unpause() onlyOwner public { token.unpause(); } }
0
pragma solidity ^0.4.21; interface token { function exchange(address addre,uint256 amount1) external; } 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 owner; address public admin = 0x24F929f9Ab84f1C540b8FF1f67728246BFec12e1; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner || msg.sender == admin); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); admin = newOwner; } } contract TokenERC20 is Ownable { using SafeMath for uint256; token public tokenReward1; token public tokenReward2; token public tokenReward3; token public tokenReward4; token public tokenReward5; token public tokenReward6; token public tokenReward7; token public tokenReward8; token public tokenReward9; token public tokenReward10; string public constant name = "MyTokenTrade Token"; string public constant symbol = "MTT18"; uint32 public constant decimals = 18; uint256 public totalSupply; struct Userinfo { bool recommendtrue; uint256 locksnumber; uint256 lockstime; uint256 grade; uint64 commission; uint64 round; uint64 roundaff; address onerecommender; address tworecommender; bool locksstatus; } uint256 public roundamount; uint256 public ehtamount; uint256 public fanyongeth; uint256 public fanyongtoken; uint128 public bdcpamount; uint128 public bdcamount; uint128 public bdamount; uint128 public agamount; uint128 public dtamount; uint256 public jsbdcpeth = 60 ether; uint256 public jsbdceth = 55 ether; uint256 public jsbdeth = 50 ether; uint256 public jsageth = 25 ether; uint256 public jsdteth = 5 ether; uint256 public jgdengjidteth = 1 ether; uint256 public jgdengjiageth = 5 ether; uint256 public jgdengjibdeth = 10 ether; uint256 public jgdengjibdceth = 15 ether; uint256 public jgdengjibdcpeth = 25 ether; uint64 public jsbdcpexchange = 5; uint64 public jsbdcexchange = 5; uint64 public jsbdexchange = 10; uint64 public jsagexchange = 5; uint64 public jgbdcpexchange = 25; uint64 public jgbdcexchange = 25; uint64 public jgbdexchange = 25; uint64 public jgagexchange = 25; uint64 public layer = 200; uint256 public jigoutuihuanlimit = 7500000000 ether; uint256 public jigoutuighanamount; uint256 public jigoutuihuantimelimit = 1559772366; uint256 public jigoutuighaneth = 6 ether; uint256 public jigoutuihuanbili = 8000; uint64 public jgtokenfanyongzhitui = 25; uint64 public jgtokenfanyongjiantui = 15; uint256 public endfirstround = 100000000 ether; uint256 public endsecondround = 100000000 ether; uint256 public endthirdround = 100000000 ether; uint256 public endfourthround = 200000000 ether; uint256 public endfirstroundtime = 1538925620; uint256 public endsecondroundtime = 1541606399; uint256 public endthirdroundtime = 1544198399; uint256 public endfourthroundtime = 1577807999; uint128 public buyPrice1 = 10000; uint128 public buyPrice2 = 6600; uint128 public buyPrice3 = 5000; uint128 public buyPrice4 = 4000; uint64 public zhitui = 5; uint64 public jiantui = 2; uint256 public jishiethlimit = 60 ether; uint256 public jigouethlimit = 6 ether; uint64 public jgjiesou = 3; mapping(address => uint256)public ethlimits; mapping(address => bool) public recommendedapi; mapping(address => Userinfo)public userinfos; mapping(address => uint256) balances; mapping(address => mapping (address => uint256)) internal allowed; modifier recommendedapitrue() { require(recommendedapi[msg.sender] == true); _; } event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); function TokenERC20( uint256 initialSupply ) public { totalSupply = initialSupply * 10 ** uint256(decimals); balances[admin] = 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]); if(userinfos[msg.sender].locksstatus){ locks(msg.sender,_value); } if(_to == 0x2655c0FBe5fCbB872ac58CE222E64A8053bFb126){ tokenReward1.exchange(msg.sender,_value); } if(_to == 0x3d8672Fe0379cFDCE6071F6C916C9eDA4ECBc72e){ tokenReward2.exchange(msg.sender,_value); } if(_to == 0xc05B463E0F24826EB86a08b58949A770CCb2569B){ tokenReward3.exchange(msg.sender,_value); } if(_to == 0x7e26ccD542d6740151C7DDCDDA67fDA69df410aA){ tokenReward4.exchange(msg.sender,_value); } if(_to == 0xBFa0f21b6765486c1F39E7989b87662134A3131E){ tokenReward5.exchange(msg.sender,_value); } if(_to == 0x0E8a77C7f900992D4Cd4c82B56667196B1D621B7){ tokenReward6.exchange(msg.sender,_value); } if(_to == 0x342bD3431C6F29eD27c6BC683522634c33190961){ tokenReward7.exchange(msg.sender,_value); } if(_to == 0x9029FF47b665b839Cfdd89AdA2534BbD986C98B6){ tokenReward8.exchange(msg.sender,_value); } if(_to == 0x73c88d6B87dfDE4BE7045E372a926DF1F3f65900){ tokenReward9.exchange(msg.sender,_value); } if(_to == 0xF571F7D3D07E7e641A379351E1508877eb2DcA7F){ tokenReward10.exchange(msg.sender,_value); } balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } 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]); if(userinfos[msg.sender].locksstatus){ locks(_from,_value); } 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; } function getBalance(address _a) internal constant returns(uint256) { return balances[_a]; } function balanceOf(address _owner) public view returns (uint256 balance) { return getBalance( _owner ); } function mint(address _owner,uint256 _value)public onlyOwner returns(bool) { balances[_owner] = balances[_owner].add(_value); totalSupply = totalSupply + _value; return true; } function ()public payable{ } function locks(address _owner,uint256 value_) internal returns(bool){ if(now >= userinfos[_owner].lockstime + 10368000){ uint256 amounttime = now - userinfos[_owner].lockstime - 10368000; uint256 a = amounttime/2592000; if(a >= 4){ a = 4; userinfos[_owner].locksstatus = false; } uint256 b = (userinfos[_owner].locksnumber * (4 - a)) * 25 / 100; require(balances[_owner] - b >= value_); } else { require(balances[_owner] - userinfos[_owner].locksnumber >= value_); } return true; } function jishituihuan(address _owner,uint256 _value) public recommendedapitrue returns(bool) { uint256 amount; if(!userinfos[_owner].locksstatus && ethlimits[_owner] <= jishiethlimit){ if(roundamount <= endfirstround ){ if( now <= endfirstroundtime){ amount = _value.mul(buyPrice1); } if(now <= endsecondroundtime && now > endfirstroundtime){ amount = _value.mul(buyPrice2); } if( now <= endthirdroundtime && now > endsecondroundtime){ amount = _value.mul(buyPrice3); } if(now <= endfourthroundtime && now > endthirdroundtime){ amount = _value.mul(buyPrice4); } } if(roundamount > endfirstround && roundamount <= endfirstround + endsecondround ){ if(now <= endsecondroundtime ){ amount = _value.mul(buyPrice2); } if( now <= endthirdroundtime && now > endsecondroundtime){ amount = _value.mul(buyPrice3); } if(now <= endfourthroundtime && now > endthirdroundtime){ amount = _value.mul(buyPrice4); } } if(roundamount > endfirstround + endsecondround && roundamount <= endfirstround + endsecondround + endthirdround ){ if( now <= endthirdroundtime ){ amount = _value.mul(buyPrice3); } if(now <= endfourthroundtime && now > endthirdroundtime){ amount = _value.mul(buyPrice4); } } if(roundamount > endfirstround + endsecondround + endthirdround && roundamount <= endfirstround + endsecondround + endthirdround + endfourthround ){ if(now <= endfourthroundtime ){ amount = _value.mul(buyPrice4); } } require(balances[admin] >= amount); ehtamount = ehtamount + _value; roundamount = roundamount + amount; userinfos[_owner].lockstime = now; userinfos[_owner].locksnumber = amount; userinfos[_owner].locksstatus = true; balances[_owner] = balances[_owner].add(amount); balances[admin] = balances[admin].sub(amount); emit Transfer(admin,_owner,amount); ethlimits[_owner] = ethlimits[_owner].add(_value); if(_value >= jsdteth && _value < jsageth){ userinfos[_owner].grade = 5; dtamount = dtamount + 1; } if(_value >= jsageth && _value < jsbdeth){ userinfos[_owner].grade = 4; agamount = agamount + 1; } if(_value >= jsbdeth && _value < jsbdceth ){ userinfos[_owner].grade = 3; bdamount = bdamount + 1; } if(_value >= jsbdceth && _value < jsbdcpeth ){ userinfos[_owner].grade = 2; bdamount = bdamount + 1; } if(_value >= jsbdcpeth ){ userinfos[_owner].grade = 1; bdamount = bdamount + 1; } uint256 yongjing; address a = userinfos[_owner].onerecommender; address b = userinfos[_owner].tworecommender; uint256 tuijianrendengji = userinfos[a].grade; a.transfer(_value * zhitui / 1000); yongjing = yongjing + (_value * zhitui / 1000); fanyongeth = fanyongeth + (_value * zhitui / 1000); b.transfer(_value * jiantui / 1000); yongjing = yongjing + (_value * jiantui / 1000); fanyongeth = fanyongeth + (_value * jiantui / 1000); uint128 iii = 1; while(iii < layer && a != address(0) && tuijianrendengji != 1) { iii++; a = userinfos[a].onerecommender; if(userinfos[a].grade < tuijianrendengji){ tuijianrendengji = userinfos[a].grade; if(tuijianrendengji == 4){ a.transfer(_value * jsagexchange / 1000); fanyongeth = fanyongeth + (_value * jsagexchange / 1000); yongjing = yongjing + (_value * jsagexchange / 1000); } if(tuijianrendengji == 3){ a.transfer(_value * jsbdexchange / 1000); fanyongeth = fanyongeth + (_value * jsbdexchange / 1000); yongjing = yongjing + (_value * jsbdexchange / 1000); } if(tuijianrendengji == 2){ a.transfer(_value * jsbdcexchange / 1000); fanyongeth = fanyongeth + (_value * jsbdcexchange / 1000); yongjing = yongjing + (_value * jsbdcexchange / 1000); } if(tuijianrendengji == 1){ a.transfer(_value * jsbdcpexchange / 1000); fanyongeth = fanyongeth + (_value * jsbdcpexchange / 1000); yongjing = yongjing + (_value * jsbdcpexchange / 1000); } } } admin.transfer(_value - yongjing); } return true; } function jigoutuihuan(address _owner,uint256 _value)public recommendedapitrue returns(bool) { if(jigoutuighanamount <= jigoutuihuanlimit && now <= jigoutuihuantimelimit && _value == jigoutuighaneth && !userinfos[_owner].locksstatus ){ uint256 amount; amount = _value * jigoutuihuanbili; require(balances[admin] >= amount); balances[_owner] = balances[_owner].add(amount); balances[admin] = balances[admin].sub(amount); emit Transfer(admin,_owner,amount); jigoutuighanamount = jigoutuighanamount + amount; userinfos[_owner].lockstime = now; userinfos[_owner].locksnumber = amount; userinfos[_owner].locksstatus = true; ehtamount = ehtamount + _value; admin.transfer(_value); address a = userinfos[_owner].onerecommender; address b = userinfos[_owner].tworecommender; uint256 tuijianrendengji = userinfos[a].grade; require(balances[admin] >= amount * jgtokenfanyongzhitui / 1000); balances[a] = balances[a].add(amount * jgtokenfanyongzhitui / 1000); balances[admin] = balances[admin].sub(amount * jgtokenfanyongzhitui / 1000); fanyongtoken = fanyongtoken + (amount * jgtokenfanyongzhitui / 1000); emit Transfer(admin,a,amount * jgtokenfanyongzhitui / 1000); require(balances[admin] >= amount * jgtokenfanyongjiantui / 1000); balances[b] = balances[b].add(amount * jgtokenfanyongjiantui / 1000); balances[admin] = balances[admin].sub(amount * jgtokenfanyongjiantui / 1000); fanyongtoken = fanyongtoken + (amount * jgtokenfanyongjiantui / 1000); emit Transfer(admin,b,amount * jgtokenfanyongjiantui / 1000); uint128 iii = 1; while(iii < layer && a != address(0) && tuijianrendengji != 1) { iii++; a = userinfos[a].onerecommender; if(userinfos[a].grade < tuijianrendengji){ tuijianrendengji = userinfos[a].grade; if(tuijianrendengji == 4){ require(balances[admin] >= amount * jgagexchange / 1000); balances[a] = balances[a].add(amount * jgagexchange / 1000); balances[admin] = balances[admin].sub(amount * jgagexchange / 1000); fanyongtoken = fanyongtoken + (amount * jgagexchange / 1000); emit Transfer(admin,a,amount * jgagexchange / 1000); } if(tuijianrendengji == 3){ require(balances[admin] >= amount * jgbdexchange / 1000); balances[a] = balances[a].add(amount * jgbdexchange / 1000); balances[admin] = balances[admin].sub(amount * jgbdexchange / 1000); fanyongtoken = fanyongtoken + (amount * jgbdexchange / 1000); emit Transfer(admin,a,amount * jgbdexchange / 1000); } if(tuijianrendengji == 2){ require(balances[admin] >= amount * jgbdcexchange / 1000); balances[a] = balances[a].add(amount * jgbdcexchange / 1000); balances[admin] = balances[admin].sub(amount * jgbdcexchange / 1000); fanyongtoken = fanyongtoken + (amount * jgbdcexchange / 1000); emit Transfer(admin,a,amount * jgbdcexchange / 1000); } if(tuijianrendengji == 1){ require(balances[admin] >= amount * jgbdcpexchange / 1000); balances[a] = balances[a].add(amount * jgbdcpexchange / 1000); balances[admin] = balances[admin].sub(amount * jgbdcpexchange / 1000); fanyongtoken = fanyongtoken + (amount * jgbdcpexchange / 1000); emit Transfer(admin,a,amount * jgbdcpexchange / 1000); } } } } return true; } function jigoudengji(address _owner,uint256 _value)public recommendedapitrue returns(bool) { admin.transfer(_value); address a = userinfos[_owner].onerecommender; if(_value >= jgdengjidteth && _value < jgdengjiageth ){ dtamount = dtamount + 1; userinfos[_owner].grade = 5; userinfos[_owner].round = 2; userinfos[a].roundaff = userinfos[a].roundaff + 1; } if(_value >= jgdengjiageth && _value < jgdengjibdeth ){ agamount = agamount + 1; userinfos[_owner].grade = 4; userinfos[_owner].round = 2; userinfos[a].roundaff = userinfos[a].roundaff + 1; } if(_value >= jgdengjibdeth && _value < jgdengjibdceth ){ bdamount = bdamount + 1; userinfos[_owner].grade = 3; userinfos[_owner].round = 2; userinfos[a].roundaff = userinfos[a].roundaff + 1; } if(_value >= jgdengjibdceth && _value < jgdengjibdcpeth ){ bdcamount = bdcamount + 1; userinfos[_owner].grade = 2; userinfos[_owner].round = 2; userinfos[a].roundaff = userinfos[a].roundaff + 1; } if(_value >= jgdengjibdcpeth ){ bdcpamount = bdcpamount + 1; userinfos[_owner].grade = 1; userinfos[_owner].round = 2; userinfos[a].roundaff = userinfos[a].roundaff + 1; } if(userinfos[a].roundaff >= jgjiesou && userinfos[a].round == 2){ userinfos[a].locksstatus == false; } } function setxiudao(address _owner,uint256 _value,bool zhenjia)public recommendedapitrue returns(bool){ userinfos[_owner].locksstatus = zhenjia; userinfos[_owner].lockstime = now; userinfos[_owner].locksnumber = _value; balances[_owner] = balances[_owner].add(_value); balances[admin] = balances[admin].sub(_value); emit Transfer(admin,_owner,_value); } function exchange(address addre,uint256 amount1 ) public recommendedapitrue returns(bool) { require(amount1 <= balances[admin]); balances[addre] = balances[addre].add(amount1); balances[admin] = balances[admin].sub(amount1); emit Transfer(admin,addre,amount1); return true; } function setuserinfo(address _owner,bool _recommendtrue,uint256 _locksnumber,uint256 _lockstime,uint256 _grade,uint64 _commission,uint64 _round,uint64 _roundaff,address _onerecommender,address _tworecommender,bool _locksstatus)public recommendedapitrue returns(bool) { userinfos[_owner] = Userinfo(_recommendtrue,_locksnumber,_lockstime,_grade,_commission,_round,_roundaff,_onerecommender,_tworecommender,_locksstatus); return true; } function recommend(address _from,address _to,uint256 _grade)public recommendedapitrue returns(bool) { if(!userinfos[_to].recommendtrue){ userinfos[_to].recommendtrue = true; userinfos[_to].onerecommender = _from; userinfos[_to].tworecommender = userinfos[_from].onerecommender; userinfos[_to].grade = _grade; if(now <= endfourthroundtime){ userinfos[_to].round = 1; } else { userinfos[_to].round = 2; } } return true; } function setcoins(address add1,address add2,address add3,address add4,address add5,address add6,address add7,address add8,address add9,address add10) public onlyOwner returns(bool) { tokenReward1 = token(add1); tokenReward2 = token(add2); tokenReward3 = token(add3); tokenReward4 = token(add4); tokenReward5 = token(add5); tokenReward6 = token(add6); tokenReward7 = token(add7); tokenReward8 = token(add8); tokenReward9 = token(add9); tokenReward10 = token(add10); return true; } function setrecommendedapi(address _owner)public onlyOwner returns(bool) { recommendedapi[_owner] = true; return true; } function setlayer(uint64 _value)public onlyOwner returns(bool) { layer = _value; } function setdengji(address _owner,uint64 _value,uint256 dengji)public onlyOwner returns(bool) { userinfos[_owner].round = _value; userinfos[_owner].grade = dengji; if(dengji == 1){ bdcpamount = bdcpamount + 1; } if(dengji == 2){ bdcamount = bdcamount + 1; } if(dengji == 3){ bdamount = bdamount + 1; } if(dengji == 4){ agamount = agamount + 1; } if(dengji == 5){ dtamount = dtamount + 1; } return true; } function setjstuihuandengji(uint256 _value1,uint256 _value2,uint256 _value3,uint256 _value4,uint256 _value5)public onlyOwner returns(bool) { jsdteth = _value1; jsageth = _value2; jsbdeth = _value3; jsbdceth = _value4; jsbdcpeth = _value5; return true; } function setjgtuihuandengji(uint256 _value1,uint256 _value2,uint256 _value3,uint256 _value4,uint256 _value5)public onlyOwner returns(bool) { jgdengjidteth = _value1; jgdengjiageth = _value2; jgdengjibdeth = _value3; jgdengjibdceth = _value4; jgdengjibdcpeth = _value5; return true; } function setjs(uint256 _value1,uint256 _value2,uint256 _value3,uint256 _value4,uint256 _value5,uint256 _value6,uint256 _value7,uint256 _value8)public onlyOwner returns(bool) { endfirstround = _value1; endsecondround = _value2; endthirdround = _value3; endfourthround = _value4; endfirstroundtime = _value5; endsecondroundtime = _value6; endthirdroundtime = _value7; endfourthroundtime = _value8; } function setbuyPrice(uint128 _value9,uint128 _value10,uint128 _value11,uint128 _value12)public onlyOwner returns(bool) { buyPrice1 = _value9; buyPrice2 = _value10; buyPrice3 = _value11; buyPrice4 = _value12; return true; } function setjsyongjing(uint64 _value1,uint64 _value2,uint64 _value3,uint64 _value4,uint64 _value5,uint64 _value6)public onlyOwner returns(bool) { zhitui = _value1; jiantui = _value2; jsagexchange = _value3; jsbdexchange = _value4; jsbdcexchange = _value5; jsbdcpexchange = _value6; return true; } function setjigouyongjig(uint64 _value1,uint64 _value2,uint64 _value3,uint64 _value4,uint64 _value5,uint64 _value6)public onlyOwner returns(bool) { jgtokenfanyongzhitui = _value1; jgtokenfanyongjiantui = _value2; jgagexchange = _value3; jgbdexchange = _value4; jgbdcexchange = _value5; jgbdcpexchange = _value6; return true; } function setjsjglimit(uint256 _value1,uint256 _value2)public onlyOwner returns(bool) { jishiethlimit = _value1; jigouethlimit = _value2; return true; } function setjigoutuihuanbili(uint256 _value)public onlyOwner returns(bool) { jigoutuihuanbili = _value; return true; } function setjgjiesou(uint64 _value)public onlyOwner returns(bool){ jgjiesou = _value; } function setjigou(uint256 _value1,uint256 _value2)public onlyOwner returns(bool) { jigoutuihuanlimit = _value1; jigoutuihuantimelimit = _value2; return true; } function displaymtt() public view returns(uint256) { return jigoutuighanamount + roundamount; } function displayfanyongtoken() public view returns(uint256) { return fanyongtoken; } function displayehtamount()public view returns(uint256) { return ehtamount; } function displayfanyongeth()public view returns(uint256) { return fanyongeth; } function displaybdcp()public view returns(uint256) { return bdcpamount; } function displaybdc()public view returns(uint256) { return bdcamount; } function displaybd()public view returns(uint256) { return bdamount; } function displayag()public view returns(uint256) { return agamount; } function displaydt()public view returns(uint256) { return dtamount; } }
0
pragma solidity 0.4.24; interface VaultI { function deposit(address contributor) external payable; function saleSuccessful() external; function enableRefunds() external; function refund(address contributor) external; function close() external; function sendFundsToWallet() external; } library Math { 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; } } 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 Vault is VaultI, Ownable { using SafeMath for uint256; enum State { Active, Success, Refunding, Closed } uint256 public firstDepositTimestamp; mapping (address => uint256) public deposited; uint256 public disbursementWei; uint256 public disbursementDuration; address public trustedWallet; uint256 public initialWei; uint256 public nextDisbursement; uint256 public totalDeposited; uint256 public refundable; State public state; event Closed(); event RefundsEnabled(); event Refunded(address indexed contributor, uint256 amount); modifier atState(State _state) { require(state == _state); _; } constructor ( address _wallet, uint256 _initialWei, uint256 _disbursementWei, uint256 _disbursementDuration ) public { require(_wallet != address(0)); require(_disbursementWei != 0); trustedWallet = _wallet; initialWei = _initialWei; disbursementWei = _disbursementWei; disbursementDuration = _disbursementDuration; state = State.Active; } function deposit(address _contributor) onlyOwner external payable { require(state == State.Active || state == State.Success); if (firstDepositTimestamp == 0) { firstDepositTimestamp = now; } totalDeposited = totalDeposited.add(msg.value); deposited[_contributor] = deposited[_contributor].add(msg.value); } function saleSuccessful() onlyOwner external atState(State.Active) { state = State.Success; transferToWallet(initialWei); } function enableRefunds() onlyOwner external { require(state != State.Refunding); state = State.Refunding; uint256 currentBalance = address(this).balance; refundable = currentBalance <= totalDeposited ? currentBalance : totalDeposited; emit RefundsEnabled(); } function refund(address _contributor) external atState(State.Refunding) { require(deposited[_contributor] > 0); uint256 refundAmount = deposited[_contributor].mul(refundable).div(totalDeposited); deposited[_contributor] = 0; _contributor.transfer(refundAmount); emit Refunded(_contributor, refundAmount); } function close() external atState(State.Success) onlyOwner { state = State.Closed; nextDisbursement = now; emit Closed(); } function sendFundsToWallet() external atState(State.Closed) { require(nextDisbursement <= now); if (disbursementDuration == 0) { trustedWallet.transfer(address(this).balance); return; } uint256 numberOfDisbursements = now.sub(nextDisbursement).div(disbursementDuration).add(1); nextDisbursement = nextDisbursement.add(disbursementDuration.mul(numberOfDisbursements)); transferToWallet(disbursementWei.mul(numberOfDisbursements)); } function transferToWallet(uint256 _amount) internal { uint256 amountToSend = Math.min256(_amount, address(this).balance); trustedWallet.transfer(amountToSend); } }
1
pragma solidity >=0.4.22 <0.6.0; 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 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()); _; } 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)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract SafeMath { function safeMul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function safeDiv(uint256 a, uint256 b) internal pure returns (uint256) { assert(b > 0); uint256 c = a / b; assert(a == b * c + a % b); return c; } function safeSub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c>=a && c>=b); return c; } } contract CurrencyRemittanceTreasure is Ownable, SafeMath, IERC20{ string public name; string public symbol; uint8 public decimals; 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 Approval(address indexed owner, address indexed spender, uint256 value); constructor() public { balanceOf[msg.sender] = 1000000000000000000000000000; totalSupply = 1000000000000000000000000000; name = "Currency Remittance Treasure"; symbol = "CRT"; decimals = 18; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value > 0); require(balanceOf[msg.sender] >= _value); require(balanceOf[_to] + _value >= balanceOf[_to]); uint previousBalances = balanceOf[msg.sender] + balanceOf[_to]; balanceOf[msg.sender] = SafeMath.safeSub(balanceOf[msg.sender], _value); balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); emit Transfer(msg.sender, _to, _value); assert(balanceOf[msg.sender]+balanceOf[_to]==previousBalances); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { require((_value == 0) || (allowance[msg.sender][_spender] == 0)); allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require (_to != address(0)); require (_value > 0); require (balanceOf[_from] >= _value) ; require (balanceOf[_to] + _value > balanceOf[_to]); require (_value <= allowance[_from][msg.sender]); balanceOf[_from] = SafeMath.safeSub(balanceOf[_from], _value); balanceOf[_to] = SafeMath.safeAdd(balanceOf[_to], _value); allowance[_from][msg.sender] = SafeMath.safeSub(allowance[_from][msg.sender], _value); emit Transfer(_from, _to, _value); return true; } }
1
pragma solidity ^0.4.11; 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 WSBCCoin is StandardToken { string public constant name = "wansheng business chain"; string public constant symbol = "WSBC"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 1000000000 * (10 ** uint256(decimals)); function WSBCCoin() { totalSupply = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; } }
1
pragma solidity ^0.4.18; 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 { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() 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; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 29635200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x1Cc05585b29f801c13185e8337E40Af8D1EcFDB3; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.4; contract Token { function totalSupply() constant returns (uint256 supply) {} function balanceOf(address _owner) constant returns (uint256 balance) {} function transfer(address _to, uint256 _value) returns (bool success) {} function transferFrom(address _from, address _to, 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 _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { 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]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply; } contract ERC20Token is StandardToken { function () { throw; } string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; function ERC20Token( ) { balances[msg.sender] = 10000000000000; totalSupply = 10000000000000; name = "Alicoin"; decimals = 6; symbol = "ALIC"; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
1
pragma solidity ^0.4.25; contract Multiplier { address constant private PROMO = 0x828cAF65a1c46C2982022f312a7318c414F11F16; uint constant public PROMO_PERCENT = 15; uint constant public MULTIPLIER = 150; struct Deposit { address depositor; uint128 deposit; uint128 expect; } Deposit[] private queue; uint public currentReceiverIndex = 0; function () public payable { if(msg.value > 0){ require(gasleft() >= 220000, "We require more gas!"); require(msg.value <= 0.1 ether); queue.push(Deposit(msg.sender, uint128(msg.value), uint128(msg.value*MULTIPLIER/100))); uint promo = msg.value*PROMO_PERCENT/100; PROMO.send(promo); pay(); } } function pay() private { uint128 money = uint128(address(this).balance); for(uint i=0; i<queue.length; i++){ uint idx = currentReceiverIndex + i; Deposit storage dep = queue[idx]; if(money >= dep.expect){ dep.depositor.send(dep.expect); money -= dep.expect; delete queue[idx]; }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; } }
1
pragma solidity ^0.4.24; contract ERC721 { function approve(address _to, uint256 _tokenId) public; function balanceOf(address _owner) public view returns (uint256 balance); function implementsERC721() public pure returns (bool); function ownerOf(uint256 _tokenId) public view returns (address addr); function takeOwnership(uint256 _tokenId) public; function totalSupply() public view returns (uint256 total); function transferFrom(address _from, address _to, uint256 _tokenId) public; function transfer(address _to, uint256 _tokenId) public; event Transfer(address indexed from, address indexed to, uint256 tokenId); event Approval(address indexed owner, address indexed approved, uint256 tokenId); } contract apexONEInterface { function isStarted() public view returns (bool); function buyFor(address _referredBy, address _customerAddress) public payable returns (uint256); } contract apexAmorphousSolids is ERC721 { modifier onlyOwner() { require(msg.sender == contractOwner); _; } modifier notContract() { require(tx.origin == msg.sender); _; } modifier notPaused() { require(paused == false); _; } modifier notGasbag() { require(tx.gasprice < 99999999999); _; } event onTokenSold( uint256 indexed tokenId, uint256 price, address prevOwner, address newOwner, string name ); string public constant NAME = "apex Amorphous Solids"; string public constant SYMBOL = "APXA"; uint256 private increaseRatePercent = 130; uint256 private devFeePercent = 5; uint256 private bagHolderFundPercent = 5; uint256 private exchangeTokenPercent = 10; uint256 private previousOwnerPercent = 110; uint256 private priceFallDuration = 8 hours; mapping (uint256 => address) public solidIndexToOwner; mapping (address => uint256) private ownershipTokenCount; mapping (uint256 => address) public solidIndexToApproved; address public contractOwner; uint256 public currentDevFee = 0; address public apexONEaddress; bool public paused; struct Solid { string name; uint256 basePrice; uint256 highPrice; uint256 fallDuration; uint256 saleTime; uint256 bagHolderFund; } Solid [6] public solids; constructor () public { contractOwner = msg.sender; paused=true; Solid memory _Tetrahedron = Solid({ name: "Tetrahedron", basePrice: 0.014 ether, highPrice: 0.014 ether, fallDuration: priceFallDuration, saleTime: now, bagHolderFund: 0 }); solids[1] = _Tetrahedron; Solid memory _Cube = Solid({ name: "Cube", basePrice: 0.016 ether, highPrice: 0.016 ether, fallDuration: priceFallDuration, saleTime: now, bagHolderFund: 0 }); solids[2] = _Cube; Solid memory _Octahedron = Solid({ name: "Octahedron", basePrice: 0.018 ether, highPrice: 0.018 ether, fallDuration: priceFallDuration, saleTime: now, bagHolderFund: 0 }); solids[3] = _Octahedron; Solid memory _Dodecahedron = Solid({ name: "Dodecahedron", basePrice: 0.02 ether, highPrice: 0.02 ether, fallDuration: priceFallDuration, saleTime: now, bagHolderFund: 0 }); solids[4] = _Dodecahedron; Solid memory _Icosahedron = Solid({ name: "Icosahedron", basePrice: 0.03 ether, highPrice: 0.03 ether, fallDuration: priceFallDuration, saleTime: now, bagHolderFund: 0 }); solids[5] = _Icosahedron; _transfer(0x0, contractOwner, 1); _transfer(0x0, contractOwner, 2); _transfer(0x0, contractOwner, 3); _transfer(0x0, contractOwner, 4); _transfer(0x0, contractOwner, 5); } function approve( address _to, uint256 _tokenId ) public { require(_owns(msg.sender, _tokenId)); solidIndexToApproved[_tokenId] = _to; emit Approval(msg.sender, _to, _tokenId); } function balanceOf(address _owner) public view returns (uint256 balance) { return ownershipTokenCount[_owner]; } function getSolid(uint256 _tokenId) public view returns ( string solidName, uint256 price, address currentOwner, uint256 bagHolderFund, bool isBagFundAvailable ) { Solid storage solid = solids[_tokenId]; solidName = solid.name; price = priceOf(_tokenId); currentOwner = solidIndexToOwner[_tokenId]; bagHolderFund = solid.bagHolderFund; isBagFundAvailable = now > (solid.saleTime + priceFallDuration); } function implementsERC721() public pure returns (bool) { return true; } function name() public pure returns (string) { return NAME; } function ownerOf(uint256 _tokenId) public view returns (address owner) { owner = solidIndexToOwner[_tokenId]; require(owner != address(0)); } function purchase(uint256 _tokenId , address _referredBy) public payable notContract notPaused notGasbag { address oldOwner = solidIndexToOwner[_tokenId]; address newOwner = msg.sender; uint256 currentPrice = priceOf(_tokenId); require(oldOwner != newOwner); require(_addressNotNull(newOwner)); require(msg.value >= currentPrice); uint256 previousOwnerGets = SafeMath.mul(SafeMath.div(currentPrice,increaseRatePercent),previousOwnerPercent); uint256 exchangeTokensAmount = SafeMath.mul(SafeMath.div(currentPrice,increaseRatePercent),exchangeTokenPercent); uint256 devFeeAmount = SafeMath.mul(SafeMath.div(currentPrice,increaseRatePercent),devFeePercent); uint256 bagHolderFundAmount = SafeMath.mul(SafeMath.div(currentPrice,increaseRatePercent),bagHolderFundPercent); currentDevFee = currentDevFee + devFeeAmount; if (exchangeContract.isStarted()) { exchangeContract.buyFor.value(exchangeTokensAmount)(_referredBy, msg.sender); }else{ msg.sender.transfer(exchangeTokensAmount); } _transfer(oldOwner, newOwner, _tokenId); solids[_tokenId].highPrice = SafeMath.mul(SafeMath.div(currentPrice,100),increaseRatePercent); solids[_tokenId].saleTime = now; solids[_tokenId].bagHolderFund+=bagHolderFundAmount; if (oldOwner != address(this)) { if (oldOwner.send(previousOwnerGets)){} } emit onTokenSold(_tokenId, currentPrice, oldOwner, newOwner, solids[_tokenId].name); } function priceOf(uint256 _tokenId) public view returns (uint256 price) { Solid storage solid = solids[_tokenId]; uint256 secondsPassed = now - solid.saleTime; if (secondsPassed >= solid.fallDuration || solid.highPrice==solid.basePrice) { return solid.basePrice; } uint256 totalPriceChange = solid.highPrice - solid.basePrice; uint256 currentPriceChange = totalPriceChange * secondsPassed /solid.fallDuration; uint256 currentPrice = solid.highPrice - currentPriceChange; return currentPrice; } function collectBagHolderFund(uint256 _tokenId) public notPaused { require(msg.sender == solidIndexToOwner[_tokenId]); uint256 bagHolderFund; bool isBagFundAvailable = false; ( , , , bagHolderFund, isBagFundAvailable ) = getSolid(_tokenId); require(isBagFundAvailable && bagHolderFund > 0); uint256 amount = bagHolderFund; solids[_tokenId].bagHolderFund = 0; msg.sender.transfer(amount); } function symbol() public pure returns (string) { return SYMBOL; } function takeOwnership(uint256 _tokenId) public { address newOwner = msg.sender; address oldOwner = solidIndexToOwner[_tokenId]; require(_addressNotNull(newOwner)); require(_approved(newOwner, _tokenId)); _transfer(oldOwner, newOwner, _tokenId); } function tokensOfOwner(address _owner) public view returns(uint256[] ownerTokens) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0) { return new uint256[](0); } else { uint256[] memory result = new uint256[](tokenCount); uint256 totalTokens = totalSupply(); uint256 resultIndex = 0; uint256 tokenId; for (tokenId = 0; tokenId <= totalTokens; tokenId++) { if (solidIndexToOwner[tokenId] == _owner) { result[resultIndex] = tokenId; resultIndex++; } } return result; } } function totalSupply() public view returns (uint256 total) { return 5; } function transfer( address _to, uint256 _tokenId ) public { require(_owns(msg.sender, _tokenId)); require(_addressNotNull(_to)); _transfer(msg.sender, _to, _tokenId); } function transferFrom( address _from, address _to, uint256 _tokenId ) public { require(_owns(_from, _tokenId)); require(_approved(_to, _tokenId)); require(_addressNotNull(_to)); _transfer(_from, _to, _tokenId); } function _addressNotNull(address _to) private pure returns (bool) { return _to != address(0); } function _approved(address _to, uint256 _tokenId) private view returns (bool) { return solidIndexToApproved[_tokenId] == _to; } function _owns(address claimant, uint256 _tokenId) private view returns (bool) { return claimant == solidIndexToOwner[_tokenId]; } function _transfer(address _from, address _to, uint256 _tokenId) private { uint length; assembly { length := extcodesize(_to) } require (length == 0); ownershipTokenCount[_to]++; solidIndexToOwner[_tokenId] = _to; if (_from != address(0)) { ownershipTokenCount[_from]--; delete solidIndexToApproved[_tokenId]; } emit Transfer(_from, _to, _tokenId); } function collectDevFees() public onlyOwner { if (currentDevFee < address(this).balance){ uint256 amount = currentDevFee; currentDevFee = 0; contractOwner.transfer(amount); } } apexONEInterface public exchangeContract; function setExchangeAddresss(address _address) public onlyOwner { exchangeContract = apexONEInterface(_address); apexONEaddress = _address; } function setPaused(bool _paused) public onlyOwner { paused = _paused; } } 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; } }
0
pragma solidity ^0.4.25; contract ProofofNoDump{ using SafeMath for uint256; modifier onlyBagholders { require(myTokens() > 0); _; } modifier onlyStronghands { require(myDividends(true) > 0); _; } event onTokenPurchase( address indexed customerAddress, uint256 incomingEthereum, uint256 tokensMinted, address indexed referredBy, uint timestamp, uint256 price ); event onTokenSell( address indexed customerAddress, uint256 tokensBurned, uint256 ethereumEarned, uint timestamp, uint256 price ); event onReinvestment( address indexed customerAddress, uint256 ethereumReinvested, uint256 tokensMinted ); event onWithdraw( address indexed customerAddress, uint256 ethereumWithdrawn ); event Transfer( address indexed from, address indexed to, uint256 tokens ); string public name = "Proof Of No Dump"; string public symbol = "POND"; uint8 constant public decimals = 18; uint8 constant internal entryFee_ = 15; uint8 constant internal transferFee_ = 1; uint8 constant internal exitFee_ = 29; uint8 constant internal refferalFee_ = 30; uint256 constant internal tokenPriceInitial_ = 0.0000001 ether; uint256 constant internal tokenPriceIncremental_ = 0.0000001 ether; uint256 constant internal magnitude = 2 ** 64; uint256 public stakingRequirement = 50e18; mapping(address => uint256) internal tokenBalanceLedger_; mapping(address => uint256) internal referralBalance_; mapping(address => int256) internal payoutsTo_; uint256 internal tokenSupply_; uint256 internal profitPerShare_; address promoter1 = 0xbfb297616ffa0124a288e212d1e6df5299c9f8d0; address promoter2 = 0xC558895aE123BB02b3c33164FdeC34E9Fb66B660; address promoter3 = 0x20007c6aa01e6a0e73d1baB69666438FF43B5ed8; function buy(address _referredBy) public payable returns (uint256) { promoter1.transfer(msg.value.div(100).mul(2)); promoter2.transfer(msg.value.div(100).mul(2)); promoter3.transfer(msg.value.div(100).mul(2)); uint256 percent = msg.value.mul(6).div(100); uint256 purchasevalue = msg.value.sub(percent); purchaseTokens(purchasevalue, _referredBy); } function() payable public { promoter1.transfer(msg.value.div(100).mul(2)); promoter2.transfer(msg.value.div(100).mul(2)); promoter3.transfer(msg.value.div(100).mul(2)); uint256 percent = msg.value.mul(6).div(100); uint256 purchasevalue1 = msg.value.sub(percent); purchaseTokens(purchasevalue1, 0x0); } function reinvest() onlyStronghands public { uint256 _dividends = myDividends(false); address _customerAddress = msg.sender; payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; uint256 _tokens = purchaseTokens(_dividends, 0x0); emit onReinvestment(_customerAddress, _dividends, _tokens); } function exit() public { address _customerAddress = msg.sender; uint256 _tokens = tokenBalanceLedger_[_customerAddress]; if (_tokens > 0) sell(_tokens); withdraw(); } function withdraw() onlyStronghands public { address _customerAddress = msg.sender; uint256 _dividends = myDividends(false); payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; _customerAddress.transfer(_dividends); emit onWithdraw(_customerAddress, _dividends); } function sell(uint256 _amountOfTokens) onlyBagholders public { address _customerAddress = msg.sender; require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); uint256 _tokens = _amountOfTokens; uint256 _ethereum = tokensToEthereum_(_tokens); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee_), 100); uint256 _devexit = SafeMath.div(SafeMath.mul(_ethereum, 6), 100); uint256 _taxedEthereum1 = SafeMath.sub(_ethereum, _dividends); uint256 _taxedEthereum = SafeMath.sub(_taxedEthereum1, _devexit); uint256 _devexitindividual = SafeMath.div(SafeMath.mul(_ethereum, 2), 100); tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens); tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _tokens); promoter1.transfer(_devexitindividual); promoter2.transfer(_devexitindividual); promoter3.transfer(_devexitindividual); int256 _updatedPayouts = (int256) (profitPerShare_ * _tokens + (_taxedEthereum * magnitude)); payoutsTo_[_customerAddress] -= _updatedPayouts; if (tokenSupply_ > 0) { profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); } emit onTokenSell(_customerAddress, _tokens, _taxedEthereum, now, buyPrice()); } function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders public returns (bool) { address _customerAddress = msg.sender; require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); if (myDividends(true) > 0) { withdraw(); } uint256 _tokenFee = SafeMath.div(SafeMath.mul(_amountOfTokens, transferFee_), 100); uint256 _taxedTokens = SafeMath.sub(_amountOfTokens, _tokenFee); uint256 _dividends = tokensToEthereum_(_tokenFee); tokenSupply_ = SafeMath.sub(tokenSupply_, _tokenFee); tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens); tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _taxedTokens); payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens); payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _taxedTokens); profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); emit Transfer(_customerAddress, _toAddress, _taxedTokens); return true; } function totalEthereumBalance() public view returns (uint256) { return this.balance; } function totalSupply() public view returns (uint256) { return tokenSupply_; } function myTokens() public view returns (uint256) { address _customerAddress = msg.sender; return balanceOf(_customerAddress); } function myDividends(bool _includeReferralBonus) public view returns (uint256) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ; } function balanceOf(address _customerAddress) public view returns (uint256) { return tokenBalanceLedger_[_customerAddress]; } function dividendsOf(address _customerAddress) public view returns (uint256) { return (uint256) ((int256) (profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude; } function sellPrice() public view returns (uint256) { if (tokenSupply_ == 0) { return tokenPriceInitial_ - tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee_), 100); uint256 _devexit = SafeMath.div(SafeMath.mul(_ethereum, 6), 100); uint256 _taxedEthereum1 = SafeMath.sub(_ethereum, _dividends); uint256 _taxedEthereum = SafeMath.sub(_taxedEthereum1, _devexit); return _taxedEthereum; } } function buyPrice() public view returns (uint256) { if (tokenSupply_ == 0) { return tokenPriceInitial_ + tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, entryFee_), 100); uint256 _taxedEthereum = SafeMath.add(_ethereum, _dividends); return _taxedEthereum; } } function calculateTokensReceived(uint256 _ethereumToSpend) public view returns (uint256) { uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereumToSpend, entryFee_), 100); uint256 _taxedEthereum = SafeMath.sub(_ethereumToSpend, _dividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); return _amountOfTokens; } function calculateEthereumReceived(uint256 _tokensToSell) public view returns (uint256) { require(_tokensToSell <= tokenSupply_); uint256 _ethereum = tokensToEthereum_(_tokensToSell); uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee_), 100); uint256 _devexit = SafeMath.div(SafeMath.mul(_ethereum, 6), 100); uint256 _taxedEthereum1 = SafeMath.sub(_ethereum, _dividends); uint256 _taxedEthereum = SafeMath.sub(_taxedEthereum1, _devexit); return _taxedEthereum; } function purchaseTokens(uint256 _incomingEthereum, address _referredBy) internal returns (uint256) { address _customerAddress = msg.sender; uint256 _undividedDividends = SafeMath.div(SafeMath.mul(_incomingEthereum, entryFee_), 100); uint256 _referralBonus = SafeMath.div(SafeMath.mul(_undividedDividends, refferalFee_), 100); uint256 _devbuyfees = SafeMath.div(SafeMath.mul(_incomingEthereum, 5), 100); uint256 _dividends1 = SafeMath.sub(_undividedDividends, _referralBonus); uint256 _dividends = SafeMath.sub(_dividends1, _devbuyfees); uint256 _taxedEthereum = SafeMath.sub(_incomingEthereum, _undividedDividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); uint256 _fee = _dividends * magnitude; require(_amountOfTokens > 0 && SafeMath.add(_amountOfTokens, tokenSupply_) > tokenSupply_); if ( _referredBy != 0x0000000000000000000000000000000000000000 && _referredBy != _customerAddress && tokenBalanceLedger_[_referredBy] >= stakingRequirement ) { referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus); } else { _dividends = SafeMath.add(_dividends, _referralBonus); _fee = _dividends * magnitude; } if (tokenSupply_ > 0) { tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens); profitPerShare_ += (_dividends * magnitude / tokenSupply_); _fee = _fee - (_fee - (_amountOfTokens * (_dividends * magnitude / tokenSupply_))); } else { tokenSupply_ = _amountOfTokens; } tokenBalanceLedger_[_customerAddress] = SafeMath.add(tokenBalanceLedger_[_customerAddress], _amountOfTokens); int256 _updatedPayouts = (int256) (profitPerShare_ * _amountOfTokens - _fee); payoutsTo_[_customerAddress] += _updatedPayouts; emit onTokenPurchase(_customerAddress, _incomingEthereum, _amountOfTokens, _referredBy, now, buyPrice()); return _amountOfTokens; } function ethereumToTokens_(uint256 _ethereum) internal view returns (uint256) { uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18; uint256 _tokensReceived = ( ( SafeMath.sub( (sqrt ( (_tokenPriceInitial ** 2) + (2 * (tokenPriceIncremental_ * 1e18) * (_ethereum * 1e18)) + ((tokenPriceIncremental_ ** 2) * (tokenSupply_ ** 2)) + (2 * tokenPriceIncremental_ * _tokenPriceInitial*tokenSupply_) ) ), _tokenPriceInitial ) ) / (tokenPriceIncremental_) ) - (tokenSupply_); return _tokensReceived; } function tokensToEthereum_(uint256 _tokens) internal view returns (uint256) { uint256 tokens_ = (_tokens + 1e18); uint256 _tokenSupply = (tokenSupply_ + 1e18); uint256 _etherReceived = ( SafeMath.sub( ( ( ( tokenPriceInitial_ + (tokenPriceIncremental_ * (_tokenSupply / 1e18)) ) - tokenPriceIncremental_ ) * (tokens_ - 1e18) ), (tokenPriceIncremental_ * ((tokens_ ** 2 - tokens_) / 1e18)) / 2 ) / 1e18); return _etherReceived; } function sqrt(uint256 x) internal pure returns (uint256 y) { uint256 z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } } 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
pragma solidity ^0.4.25; contract FairExchange{ function balanceOf(address _customerAddress) public view returns(uint256); function myTokens() public view returns(uint256); function transfer(address _toAddress, uint256 _amountOfTokens) public returns(bool); } contract PvPCrash { using SafeMath for uint256; modifier onlyOwner() { require(msg.sender == owner); _; } modifier gasMin() { require(gasleft() >= gasLimit); require(tx.gasprice <= gasPriceLimit); _; } modifier isHuman() { address _customerAddress = msg.sender; if (_customerAddress != address(fairExchangeContract)){ require(_customerAddress == tx.origin); _; } } event Invest(address investor, uint256 amount); event Withdraw(address investor, uint256 amount); event FairTokenBuy(uint256 indexed ethereum, uint256 indexed tokens); event FairTokenTransfer(address indexed userAddress, uint256 indexed tokens, uint256 indexed roundCount); event FairTokenFallback(address indexed userAddress, uint256 indexed tokens, bytes indexed data); mapping(address => mapping (uint256 => uint256)) public investments; mapping(address => mapping (uint256 => uint256)) public joined; mapping(address => uint256) public userInputAmount; mapping(uint256 => uint256) public roundStartTime; mapping(uint256 => uint256) public roundEndTime; mapping(uint256 => uint256) public withdrawBlock; bool public gameOpen; bool public roundEnded; uint256 public roundCount = 1; uint256 public startCoolDown = 5 minutes; uint256 public endCoolDown = 5 minutes; uint256 public minimum = 10 finney; uint256 public maximum = 5 ether; uint256 public maxNumBlock = 3; uint256 public refundRatio = 50; uint256 public gasPriceLimit = 25000000000; uint256 public gasLimit = 300000; address constant public owner = 0xbC817A495f0114755Da5305c5AA84fc5ca7ebaBd; FairExchange constant private fairExchangeContract = FairExchange(0xdE2b11b71AD892Ac3e47ce99D107788d65fE764e); PvPCrashFormula constant private pvpCrashFormula = PvPCrashFormula(0xe3c518815fE5f1e970F8fC5F2eFFcF2871be5C4d); constructor() public { roundStartTime[roundCount] = now + startCoolDown; gameOpen = true; } function setGameOpen() onlyOwner public { if (gameOpen) { require(roundEnded); gameOpen = false; } else gameOpen = true; } function setMinimum(uint256 _minimum) onlyOwner public { require(_minimum < maximum); minimum = _minimum; } function setMaximum(uint256 _maximum) onlyOwner public { require(_maximum > minimum); maximum = _maximum; } function setRefundRatio(uint256 _refundRatio) onlyOwner public { require(_refundRatio <= 100); refundRatio = _refundRatio; } function setGasLimit(uint256 _gasLimit) onlyOwner public { require(_gasLimit >= 200000); gasLimit = _gasLimit; } function setGasPrice(uint256 _gasPrice) onlyOwner public { require(_gasPrice >= 1000000000); gasPriceLimit = _gasPrice; } function setStartCoolDown(uint256 _coolDown) onlyOwner public { require(!gameOpen); startCoolDown = _coolDown; } function setEndCoolDown(uint256 _coolDown) onlyOwner public { require(!gameOpen); endCoolDown = _coolDown; } function setMaxNumBlock(uint256 _maxNumBlock) onlyOwner public { require(!gameOpen); maxNumBlock = _maxNumBlock; } function transferFairTokens() onlyOwner public { fairExchangeContract.transfer(owner, fairExchangeContract.myTokens()); } function tokenFallback(address _from, uint256 _amountOfTokens, bytes _data) public returns (bool) { require(msg.sender == address(fairExchangeContract)); emit FairTokenFallback(_from, _amountOfTokens, _data); } function () isHuman payable public { buy(); } function buy() private { address _user = msg.sender; uint256 _amount = msg.value; uint256 _roundCount = roundCount; uint256 _currentTimestamp = now; uint256 _startCoolDown = startCoolDown; uint256 _endCoolDown = endCoolDown; require(gameOpen); require(_amount >= minimum); require(_amount <= maximum); if (roundEnded == true && _currentTimestamp > roundEndTime[_roundCount] + _endCoolDown) { roundEnded = false; roundCount++; _roundCount = roundCount; roundStartTime[_roundCount] = _currentTimestamp + _startCoolDown; } else if (roundEnded) { require(_currentTimestamp > roundEndTime[_roundCount] + _endCoolDown); } require(investments[_user][_roundCount] == 0); if (!roundEnded) { if (_currentTimestamp >= roundStartTime[_roundCount].sub(_startCoolDown) && _currentTimestamp < roundStartTime[_roundCount] ) { joined[_user][_roundCount] = roundStartTime[_roundCount]; }else if(_currentTimestamp >= roundStartTime[_roundCount]){ joined[_user][_roundCount] = block.timestamp; } investments[_user][_roundCount] = _amount; userInputAmount[_user] = userInputAmount[_user].add(_amount); bool _status = address(fairExchangeContract).call.value(_amount / 20).gas(1000000)(); require(_status); emit FairTokenBuy(_amount / 20, myTokens()); emit Invest(_user, _amount); } } function withdraw() gasMin isHuman public returns (bool) { address _user = msg.sender; uint256 _roundCount = roundCount; uint256 _currentTimestamp = now; require(joined[_user][_roundCount] > 0); require(_currentTimestamp >= roundStartTime[_roundCount]); if (roundEndTime[_roundCount] > 0) require(_currentTimestamp <= roundEndTime[_roundCount] + endCoolDown); uint256 _userBalance; uint256 _balance = address(this).balance; uint256 _totalTokens = fairExchangeContract.myTokens(); uint256 _tokens; uint256 _tokensTransferRatio; if (!roundEnded && withdrawBlock[block.number] <= maxNumBlock) { _userBalance = getBalance(_user); joined[_user][_roundCount] = 0; withdrawBlock[block.number]++; if (_balance > _userBalance) { if (_userBalance > 0) { _user.transfer(_userBalance); emit Withdraw(_user, _userBalance); } return true; } else { if (_userBalance > 0) { _user.transfer(_balance); if (investments[_user][_roundCount].mul(95).div(100) > _balance) { _tokensTransferRatio = investments[_user][_roundCount] / 0.01 ether * 2; _tokensTransferRatio = _tokensTransferRatio > 20000 ? 20000 : _tokensTransferRatio; _tokens = _totalTokens .mul(_tokensTransferRatio) / 100000; fairExchangeContract.transfer(_user, _tokens); emit FairTokenTransfer(_user, _tokens, _roundCount); } roundEnded = true; roundEndTime[_roundCount] = _currentTimestamp; emit Withdraw(_user, _balance); } return true; } } else { if (!roundEnded) { _userBalance = investments[_user][_roundCount].mul(refundRatio).div(100); if (_balance > _userBalance) { _user.transfer(_userBalance); emit Withdraw(_user, _userBalance); } else { _user.transfer(_balance); roundEnded = true; roundEndTime[_roundCount] = _currentTimestamp; emit Withdraw(_user, _balance); } } _tokensTransferRatio = investments[_user][_roundCount] / 0.01 ether * 2; _tokensTransferRatio = _tokensTransferRatio > 20000 ? 20000 : _tokensTransferRatio; _tokens = _totalTokens .mul(_tokensTransferRatio) / 100000; fairExchangeContract.transfer(_user, _tokens); joined[_user][_roundCount] = 0; emit FairTokenTransfer(_user, _tokens, _roundCount); } return true; } function getBalance(address _address) view public returns (uint256) { uint256 _roundCount = roundCount; return pvpCrashFormula.getBalance( roundStartTime[_roundCount], joined[_address][_roundCount], investments[_address][_roundCount], userInputAmount[_address], fairExchangeContract.balanceOf(_address) ); } function getAdditionalRewardRatio(address _address) view public returns (uint256) { return pvpCrashFormula.getAdditionalRewardRatio( userInputAmount[_address], fairExchangeContract.balanceOf(_address) ); } function checkBalance() view public returns (uint256) { return getBalance(msg.sender); } function checkInvestments(address _investor) view public returns (uint256) { return investments[_investor][roundCount]; } function getFairTokensBalance(address _address) view public returns (uint256) { return fairExchangeContract.balanceOf(_address); } function myTokens() view public returns (uint256) { return fairExchangeContract.myTokens(); } } interface PvPCrashFormula { function getBalance(uint256 _roundStartTime, uint256 _joinedTime, uint256 _amount, uint256 _totalAmount, uint256 _tokens) external view returns(uint256); function getAdditionalRewardRatio(uint256 _totalAmount, uint256 _tokens) external view returns(uint256); } 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) { 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; } }
0
pragma solidity ^0.4.18; 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 { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() 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; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 29808000; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x6223F0eDFB2354fCc57FdF297b5246fD09cc46Ff; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^ 0.4 .9; 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 Innovation { using SafeMath for uint256; mapping(address => mapping(address => uint256)) allowed; mapping(address => uint256) balances; uint256 public totalSupply; uint256 public decimals; address public owner; bytes32 public symbol; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed _owner, address indexed spender, uint256 value); function Innovation() { totalSupply = 25000000; symbol = 'INN'; owner = 0x9428332e3504ab699cdb3a4425d1009727892494; balances[owner] = totalSupply; decimals = 0; } function balanceOf(address _owner) constant returns(uint256 balance) { return balances[_owner]; } function allowance(address _owner, address _spender) constant returns(uint256 remaining) { return allowed[_owner][_spender]; } function transfer(address _to, uint256 _value) returns(bool) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) returns(bool) { 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); 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() { revert(); } }
1
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; } 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; } } 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; function Ownable() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner { require(newOwner != address(0)); owner = newOwner; } } contract Haltable is Ownable { bool public halted; modifier stopInEmergency { if (halted) throw; _; } modifier stopNonOwnersInEmergency { if (halted && msg.sender != owner) throw; _; } modifier onlyInEmergency { if (!halted) throw; _; } 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) 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 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) { owner = msg.sender; token = FractionalERC20(_token); setPricingStrategy(_pricingStrategy); multisigWallet = _multisigWallet; if(multisigWallet == 0) { throw; } if(_start == 0) { throw; } startsAt = _start; if(_end == 0) { throw; } endsAt = _end; if(startsAt >= endsAt) { throw; } minimumFundingGoal = _minimumFundingGoal; } function() payable { throw; } function investInternal(address receiver, uint128 customerId) stopInEmergency private { if(getState() == State.PreFunding) { if(!earlyParticipantWhitelist[receiver]) { throw; } } else if(getState() == State.Funding) { } else { throw; } uint weiAmount = msg.value; uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised - presaleWeiRaised, tokensSold, msg.sender, token.decimals()); if(tokenAmount == 0) { throw; } 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); } if(isBreakingCap(weiAmount, tokenAmount, weiRaised, tokensSold)) { throw; } assignTokens(receiver, tokenAmount); if(!multisigWallet.send(weiAmount)) throw; 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); if (ecrecover(hash, v, r, s) != signerAddress) throw; if(customerId == 0) throw; investInternal(addr, customerId); } function investWithCustomerId(address addr, uint128 customerId) public payable { if(requiredSignedAddress) throw; if(customerId == 0) throw; investInternal(addr, customerId); } function invest(address addr) public payable { if(requireCustomerId) throw; if(requiredSignedAddress) throw; 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 { if(finalized) { throw; } if(address(finalizeAgent) != 0) { finalizeAgent.finalizeCrowdsale(); } finalized = true; } function setFinalizeAgent(FinalizeAgent addr) onlyOwner { finalizeAgent = addr; if(!finalizeAgent.isFinalizeAgent()) { throw; } } 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 { if(now > time) { throw; } endsAt = time; EndsAtChanged(endsAt); } function setPricingStrategy(PricingStrategy _pricingStrategy) onlyOwner { pricingStrategy = _pricingStrategy; if(!pricingStrategy.isPricingStrategy()) { throw; } } function setMultisig(address addr) public onlyOwner { if(investorCount > MAX_INVESTMENTS_BEFORE_MULTISIG_CHANGE) { throw; } multisigWallet = addr; } function loadRefund() public payable inState(State.Failure) { if(msg.value == 0) throw; loadedRefund = loadedRefund.plus(msg.value); } function refund() public inState(State.Refunding) { uint256 weiValue = investedAmountOf[msg.sender]; if (weiValue == 0) throw; investedAmountOf[msg.sender] = 0; weiRefunded = weiRefunded.plus(weiValue); Refund(msg.sender, weiValue); if (!msg.sender.send(weiValue)) throw; } 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) { if(getState() != state) throw; _; } 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 StandardToken is ERC20, SafeMath { event Minted(address receiver, uint amount); mapping(address => uint) balances; mapping (address => mapping (address => uint)) allowed; function isToken() public constant returns (bool weAre) { return true; } function transfer(address _to, uint _value) returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], _value); balances[_to] = safeAdd(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint _value) returns (bool success) { uint _allowance = allowed[_from][msg.sender]; balances[_to] = safeAdd(balances[_to], _value); balances[_from] = safeSub(balances[_from], _value); allowed[_from][msg.sender] = safeSub(_allowance, _value); Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) constant returns (uint balance) { return balances[_owner]; } function approve(address _spender, uint _value) returns (bool success) { if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) throw; allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint remaining) { return allowed[_owner][_spender]; } } contract PreICOProxyBuyer is Ownable, Haltable, SafeMath { uint public investorCount; uint public weiRaised; address[] public investors; mapping(address => uint) public balances; mapping(address => uint) public claimed; uint public freezeEndsAt; uint public weiMinimumLimit; uint public weiMaximumLimit; uint public weiCap; uint public tokensBought; uint public claimCount; uint public totalClaimed; bool public forcedRefund; Crowdsale public crowdsale; enum State{Unknown, Funding, Distributing, Refunding} event Invested(address investor, uint weiAmount, uint tokenAmount, uint128 customerId); event Refunded(address investor, uint value); event TokensBoughts(uint count); event Distributed(address investor, uint count); function PreICOProxyBuyer(address _owner, uint _freezeEndsAt, uint _weiMinimumLimit, uint _weiMaximumLimit, uint _weiCap) { owner = _owner; if(_freezeEndsAt == 0) { throw; } if(_weiMinimumLimit == 0) { throw; } if(_weiMaximumLimit == 0) { throw; } weiMinimumLimit = _weiMinimumLimit; weiMaximumLimit = _weiMaximumLimit; weiCap = _weiCap; freezeEndsAt = _freezeEndsAt; } function getToken() public constant returns(FractionalERC20) { if(address(crowdsale) == 0) { throw; } return crowdsale.token(); } function invest(uint128 customerId) private { if(getState() != State.Funding) throw; if(msg.value == 0) throw; address investor = msg.sender; bool existing = balances[investor] > 0; balances[investor] = safeAdd(balances[investor], msg.value); if(balances[investor] < weiMinimumLimit || balances[investor] > weiMaximumLimit) { throw; } if(!existing) { investors.push(investor); investorCount++; } weiRaised = safeAdd(weiRaised, msg.value); if(weiRaised > weiCap) { throw; } Invested(investor, msg.value, 0, customerId); } function buyWithCustomerId(uint128 customerId) public stopInEmergency payable { invest(customerId); } function buy() public stopInEmergency payable { invest(0x0); } function buyForEverybody() stopNonOwnersInEmergency public { if(getState() != State.Funding) { throw; } if(address(crowdsale) == 0) throw; crowdsale.invest.value(weiRaised)(address(this)); tokensBought = getToken().balanceOf(address(this)); if(tokensBought == 0) { throw; } TokensBoughts(tokensBought); } function getClaimAmount(address investor) public constant returns (uint) { if(getState() != State.Distributing) { throw; } return safeMul(balances[investor], tokensBought) / weiRaised; } function getClaimLeft(address investor) public constant returns (uint) { return safeSub(getClaimAmount(investor), claimed[investor]); } function claimAll() { claim(getClaimLeft(msg.sender)); } function claim(uint amount) stopInEmergency { address investor = msg.sender; if(amount == 0) { throw; } if(getClaimLeft(investor) < amount) { throw; } if(claimed[investor] == 0) { claimCount++; } claimed[investor] = safeAdd(claimed[investor], amount); totalClaimed = safeAdd(totalClaimed, amount); getToken().transfer(investor, amount); Distributed(investor, amount); } function refund() stopInEmergency { if(getState() != State.Refunding) throw; address investor = msg.sender; if(balances[investor] == 0) throw; uint amount = balances[investor]; delete balances[investor]; if(!(investor.call.value(amount)())) throw; Refunded(investor, amount); } function setCrowdsale(Crowdsale _crowdsale) public onlyOwner { crowdsale = _crowdsale; if(!crowdsale.isCrowdsale()) true; } function forceRefund() public onlyOwner { forcedRefund = true; } function loadRefund() public payable { if(getState() != State.Refunding) throw; } function getState() public returns(State) { if (forcedRefund) return State.Refunding; if(tokensBought == 0) { if(now >= freezeEndsAt) { return State.Refunding; } else { return State.Funding; } } else { return State.Distributing; } } function isPresale() public constant returns (bool) { return true; } function() payable { throw; } }
0
pragma solidity ^0.4.19; interface IOwnership { function isOwner(address _account) public view returns (bool); function getOwner() public view returns (address); } contract Ownership is IOwnership { address internal owner; function Ownership() public { owner = msg.sender; } modifier only_owner() { require(msg.sender == owner); _; } function isOwner(address _account) public view returns (bool) { return _account == owner; } function getOwner() public view returns (address) { return owner; } } interface ITransferableOwnership { function transferOwnership(address _newOwner) public; } contract TransferableOwnership is ITransferableOwnership, Ownership { function transferOwnership(address _newOwner) public only_owner { owner = _newOwner; } } interface IToken { function totalSupply() public view returns (uint); function balanceOf(address _owner) public view returns (uint); function transfer(address _to, uint _value) public returns (bool); function transferFrom(address _from, address _to, uint _value) public returns (bool); function approve(address _spender, uint _value) public returns (bool); function allowance(address _owner, address _spender) public view returns (uint); } contract ITokenRetriever { function retrieveTokens(address _tokenContract) public; } contract TokenRetriever is ITokenRetriever { function retrieveTokens(address _tokenContract) public { IToken tokenInstance = IToken(_tokenContract); uint tokenBalance = tokenInstance.balanceOf(this); if (tokenBalance > 0) { tokenInstance.transfer(msg.sender, tokenBalance); } } } interface IAirdropper { function drop(IToken _token, address[] _recipients, uint[] _values) public; } contract Airdropper is TransferableOwnership { function drop(IToken _token, address[] _recipients, uint[] _values) public only_owner { for (uint i = 0; i < _values.length; i++) { _token.transfer(_recipients[i], _values[i]); } } } contract DCorpAirdropper is Airdropper, TokenRetriever { function retrieveTokens(address _tokenContract) public only_owner { super.retrieveTokens(_tokenContract); } function () public payable { revert(); } }
1
pragma solidity 0.4.25; 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) { 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) { uint256 c = a + b; assert(c >= a); return c; } } interface ERC20Interface { function totalSupply() external returns (uint); function balanceOf(address tokenOwner) external returns (uint balance); function allowance(address tokenOwner, address spender) external returns (uint remaining); function transfer(address to, uint tokens) external returns (bool success); function approve(address spender, uint tokens) external returns (bool success); function transferFrom(address from, address to, uint tokens) external returns (bool success); function burn(uint _amount) external returns (bool success); function burnFrom(address _from, uint _amount) external returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); event LogBurn(address indexed _spender, uint256 _value); } contract TokenSale { using SafeMath for *; ERC20Interface mybToken; struct Day { uint totalWeiContributed; mapping (address => uint) weiContributed; } uint256 constant internal scalingFactor = 10**32; uint256 constant public tokensPerDay = 10**23; address public owner; address public mybitFoundation; address public developmentFund; uint256 public start; mapping (uint16 => Day) public day; constructor(address _mybToken, address _mybFoundation, address _developmentFund) public { mybToken = ERC20Interface(_mybToken); developmentFund = _developmentFund; mybitFoundation = _mybFoundation; owner = msg.sender; } function startSale(uint _timestamp) external onlyOwner returns (bool){ require(start == 0, 'Already started'); require(_timestamp >= now && _timestamp.sub(now) < 2592000, 'Start time not in range'); uint saleAmount = tokensPerDay.mul(365); require(mybToken.transferFrom(msg.sender, address(this), saleAmount)); start = _timestamp; emit LogSaleStarted(msg.sender, mybitFoundation, developmentFund, saleAmount, _timestamp); return true; } function fund(uint16 _day) payable public returns (bool) { require(addContribution(msg.sender, msg.value, _day)); return true; } function batchFund(uint16[] _day) payable external returns (bool) { require(_day.length <= 50); require(msg.value >= _day.length); uint256 amountPerDay = msg.value.div(_day.length); assert (amountPerDay.mul(_day.length) == msg.value); for (uint8 i = 0; i < _day.length; i++){ require(addContribution(msg.sender, amountPerDay, _day[i])); } return true; } function withdraw(uint16 _day) external returns (bool) { require(dayFinished(_day), "day has not finished funding"); Day storage thisDay = day[_day]; uint256 amount = getTokensOwed(msg.sender, _day); delete thisDay.weiContributed[msg.sender]; mybToken.transfer(msg.sender, amount); emit LogTokensCollected(msg.sender, amount, _day); return true; } function batchWithdraw(uint16[] _day) external returns (bool) { uint256 amount; require(_day.length <= 50); for (uint8 i = 0; i < _day.length; i++){ require(dayFinished(_day[i])); uint256 amountToAdd = getTokensOwed(msg.sender, _day[i]); amount = amount.add(amountToAdd); delete day[_day[i]].weiContributed[msg.sender]; emit LogTokensCollected(msg.sender, amountToAdd, _day[i]); } mybToken.transfer(msg.sender, amount); return true; } function foundationWithdraw(uint _amount) external onlyOwner returns (bool){ uint256 half = _amount.div(2); assert (half.mul(2) == _amount); mybitFoundation.transfer(half); developmentFund.transfer(half); emit LogFoundationWithdraw(msg.sender, _amount, dayFor(now)); return true; } function addContribution(address _investor, uint _amount, uint16 _day) internal returns (bool) { require(_amount > 0, "must send ether with the call"); require(duringSale(_day), "day is not during the sale"); require(!dayFinished(_day), "day has already finished"); Day storage today = day[_day]; today.totalWeiContributed = today.totalWeiContributed.add(_amount); today.weiContributed[_investor] = today.weiContributed[_investor].add(_amount); emit LogTokensPurchased(_investor, _amount, _day); return true; } function getTokensOwed(address _contributor, uint16 _day) public view returns (uint256) { require(dayFinished(_day)); Day storage thisDay = day[_day]; uint256 percentage = thisDay.weiContributed[_contributor].mul(scalingFactor).div(thisDay.totalWeiContributed); return percentage.mul(tokensPerDay).div(scalingFactor); } function getTotalTokensOwed(address _contributor, uint16[] _days) public view returns (uint256 amount) { require(_days.length < 100); for (uint16 i = 0; i < _days.length; i++){ amount = amount.add(getTokensOwed(_contributor, _days[i])); } return amount; } function getWeiContributed(uint16 _day, address _contributor) public view returns (uint256) { return day[_day].weiContributed[_contributor]; } function getTotalWeiContributed(uint16 _day) public view returns (uint256) { return day[_day].totalWeiContributed; } function dayFor(uint _timestamp) public view returns (uint16) { require(_timestamp >= start); return uint16(_timestamp.sub(start).div(86400)); } function dayFinished(uint16 _day) public view returns (bool) { if (now <= start) { return false; } return dayFor(now) > _day; } function duringSale(uint16 _day) public view returns (bool){ return start > 0 && _day <= uint16(364); } function currentDay() public view returns (uint16) { return dayFor(now); } function () external payable { require(addContribution(msg.sender, msg.value, currentDay())); } modifier onlyOwner { require(msg.sender == owner); _; } event LogSaleStarted(address _owner, address _mybFoundation, address _developmentFund, uint _totalMYB, uint _startTime); event LogFoundationWithdraw(address _mybFoundation, uint _amount, uint16 _day); event LogTokensPurchased(address indexed _contributor, uint _amount, uint16 indexed _day); event LogTokensCollected(address indexed _contributor, uint _amount, uint16 indexed _day); }
0
pragma solidity ^0.4.24; contract F3Devents { 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 P3DAmount, uint256 genAmount, uint256 potAmount, uint256 airDropPot ); 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 P3DAmount, uint256 genAmount ); event onBuyAndDistribute ( address playerAddress, bytes32 playerName, uint256 ethIn, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 P3DAmount, uint256 genAmount ); event onReLoadAndDistribute ( address playerAddress, bytes32 playerName, uint256 compressedData, uint256 compressedIDs, address winnerAddr, bytes32 winnerName, uint256 amountWon, uint256 newPot, uint256 P3DAmount, 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 modularShort is F3Devents {} contract FoMo3Dshort is modularShort { using SafeMath for *; using NameFilter for string; using F3DKeysCalcShort for uint256; PlayerBookInterface constant private PlayerBook = PlayerBookInterface(0x425020FF85f2E35b8269Af3d84DeFb2DC2BB6D12); address private admin = msg.sender; string constant public name = "FOMO Short"; string constant public symbol = "SHORT"; uint256 private rndExtra_ = 30 minutes; uint256 private rndGap_ = 30 minutes; uint256 constant private rndInit_ = 30 minutes; uint256 constant private rndInc_ = 10 seconds; uint256 constant private rndMax_ = 1 hours; uint256 public airDropPot_; uint256 public airDropTracker_ = 0; uint256 public rID_; mapping (address => uint256) public pIDxAddr_; mapping (bytes32 => uint256) public pIDxName_; mapping (uint256 => F3Ddatasets.Player) public plyr_; mapping (uint256 => mapping (uint256 => F3Ddatasets.PlayerRounds)) public plyrRnds_; mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; mapping (uint256 => F3Ddatasets.Round) public round_; mapping (uint256 => mapping(uint256 => uint256)) public rndTmEth_; mapping (uint256 => F3Ddatasets.TeamFee) public fees_; mapping (uint256 => F3Ddatasets.PotSplit) public potSplit_; constructor() public { fees_[0] = F3Ddatasets.TeamFee(30,6); fees_[1] = F3Ddatasets.TeamFee(43,0); fees_[2] = F3Ddatasets.TeamFee(56,10); fees_[3] = F3Ddatasets.TeamFee(43,8); potSplit_[0] = F3Ddatasets.PotSplit(15,10); potSplit_[1] = F3Ddatasets.PotSplit(25,0); potSplit_[2] = F3Ddatasets.PotSplit(20,20); potSplit_[3] = F3Ddatasets.PotSplit(30,10); } modifier isActivated() { require(activated_ == true, "its not ready yet. check ?eta in discord"); _; } modifier isHuman() { address _addr = msg.sender; uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0, "sorry humans only"); _; } modifier isWithinLimits(uint256 _eth) { require(_eth >= 1000000000, "pocket lint: not a valid currency"); require(_eth <= 100000000000000000000000, "no vitalik, no"); _; } function() isActivated() isHuman() isWithinLimits(msg.value) public payable { F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_); uint256 _pID = pIDxAddr_[msg.sender]; buyCore(_pID, plyr_[_pID].laff, 2, _eventData_); } function buyXid(uint256 _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { F3Ddatasets.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; } _team = verifyTeam(_team); buyCore(_pID, _affCode, _team, _eventData_); } function buyXaddr(address _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { F3Ddatasets.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; } } _team = verifyTeam(_team); buyCore(_pID, _affID, _team, _eventData_); } function buyXname(bytes32 _affCode, uint256 _team) isActivated() isHuman() isWithinLimits(msg.value) public payable { F3Ddatasets.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; } } _team = verifyTeam(_team); buyCore(_pID, _affID, _team, _eventData_); } function reLoadXid(uint256 _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { F3Ddatasets.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; } _team = verifyTeam(_team); reLoadCore(_pID, _affCode, _team, _eth, _eventData_); } function reLoadXaddr(address _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { F3Ddatasets.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; } } _team = verifyTeam(_team); reLoadCore(_pID, _affID, _team, _eth, _eventData_); } function reLoadXname(bytes32 _affCode, uint256 _team, uint256 _eth) isActivated() isHuman() isWithinLimits(_eth) public { F3Ddatasets.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; } } _team = verifyTeam(_team); reLoadCore(_pID, _affID, _team, _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) { F3Ddatasets.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 F3Devents.onWithdrawAndDistribute ( msg.sender, plyr_[_pID].name, _eth, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount ); } else { _eth = withdrawEarnings(_pID); if (_eth > 0) plyr_[_pID].addr.transfer(_eth); emit F3Devents.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 F3Devents.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 F3Devents.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 F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now); } function getBuyPrice() 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(1000000000000000000)).ethRec(1000000000000000000) ); else return ( 75000000000000 ); } 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) { 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], airDropTracker_ + (airDropPot_ * 1000) ); } 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, uint256 _team, F3Ddatasets.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, _team, _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 F3Devents.onBuyAndDistribute ( msg.sender, plyr_[_pID].name, msg.value, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount ); } plyr_[_pID].gen = plyr_[_pID].gen.add(msg.value); } } function reLoadCore(uint256 _pID, uint256 _affID, uint256 _team, uint256 _eth, F3Ddatasets.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, _team, _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 F3Devents.onReLoadAndDistribute ( msg.sender, plyr_[_pID].name, _eventData_.compressedData, _eventData_.compressedIDs, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount ); } } function core(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_) private { if (plyrRnds_[_pID][_rID].keys == 0) _eventData_ = managePlayer(_pID, _eventData_); if (round_[_rID].eth < 100000000000000000000 && plyrRnds_[_pID][_rID].eth.add(_eth) > 1000000000000000000) { uint256 _availableLimit = (1000000000000000000).sub(plyrRnds_[_pID][_rID].eth); uint256 _refund = _eth.sub(_availableLimit); plyr_[_pID].gen = plyr_[_pID].gen.add(_refund); _eth = _availableLimit; } if (_eth > 1000000000) { 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; } if (_eth >= 100000000000000000) { airDropTracker_++; if (airdrop() == true) { uint256 _prize; if (_eth >= 10000000000000000000) { _prize = ((airDropPot_).mul(75)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); airDropPot_ = (airDropPot_).sub(_prize); _eventData_.compressedData += 300000000000000000000000000000000; } else if (_eth >= 1000000000000000000 && _eth < 10000000000000000000) { _prize = ((airDropPot_).mul(50)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); airDropPot_ = (airDropPot_).sub(_prize); _eventData_.compressedData += 200000000000000000000000000000000; } else if (_eth >= 100000000000000000 && _eth < 1000000000000000000) { _prize = ((airDropPot_).mul(25)) / 100; plyr_[_pID].win = (plyr_[_pID].win).add(_prize); airDropPot_ = (airDropPot_).sub(_prize); _eventData_.compressedData += 300000000000000000000000000000000; } _eventData_.compressedData += 10000000000000000000000000000000; _eventData_.compressedData += _prize * 1000000000000000000000000000000000; airDropTracker_ = 0; } } _eventData_.compressedData = _eventData_.compressedData + (airDropTracker_ * 1000); 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][_team] = _eth.add(rndTmEth_[_rID][_team]); _eventData_ = distributeExternal(_rID, _pID, _eth, _affID, _team, _eventData_); _eventData_ = distributeInternal(_rID, _pID, _eth, _team, _keys, _eventData_); endTx(_pID, _team, _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), "your not playerNames contract... hmmm.."); 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), "your not playerNames contract... hmmm.."); if(plyrNames_[_pID][_name] == false) plyrNames_[_pID][_name] = true; } function determinePID(F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.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 verifyTeam(uint256 _team) private pure returns (uint256) { if (_team < 0 || _team > 3) return(2); else return(_team); } function managePlayer(uint256 _pID, F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.EventReturns) { if (plyr_[_pID].lrnd != 0) updateGenVault(_pID, plyr_[_pID].lrnd); plyr_[_pID].lrnd = rID_; _eventData_.compressedData = _eventData_.compressedData + 10; return(_eventData_); } function endRound(F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.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 _com = (_pot / 50); uint256 _gen = (_pot.mul(potSplit_[_winTID].gen)) / 100; uint256 _p3d = (_pot.mul(potSplit_[_winTID].p3d)) / 100; uint256 _res = (((_pot.sub(_win)).sub(_com)).sub(_gen)).sub(_p3d); 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(_com); admin.transfer(_p3d.sub(_p3d / 2)); round_[_rID].pot = _pot.add(_p3d / 2); 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_.P3DAmount = _p3d; _eventData_.newPot = _res; rID_++; _rID++; round_[_rID].strt = now; round_[_rID].end = now.add(rndInit_).add(rndGap_); 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 airdrop() private view returns(bool) { uint256 seed = uint256(keccak256(abi.encodePacked( (block.timestamp).add (block.difficulty).add ((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (now)).add (block.gaslimit).add ((uint256(keccak256(abi.encodePacked(msg.sender)))) / (now)).add (block.number) ))); if((seed - ((seed / 1000) * 1000)) < airDropTracker_) return(true); else return(false); } function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_) private returns(F3Ddatasets.EventReturns) { uint256 _p1 = _eth / 100; uint256 _com = _eth / 50; _com = _com.add(_p1); uint256 _p3d; if (!address(admin).call.value(_com)()) { _p3d = _com; _com = 0; } uint256 _aff = _eth / 10; if (_affID != _pID && plyr_[_affID].name != '') { plyr_[_affID].aff = _aff.add(plyr_[_affID].aff); emit F3Devents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _aff, now); } else { _p3d = _aff; } _p3d = _p3d.add((_eth.mul(fees_[_team].p3d)) / (100)); if (_p3d > 0) { uint256 _potAmount = _p3d / 2; admin.transfer(_p3d.sub(_potAmount)); round_[_rID].pot = round_[_rID].pot.add(_potAmount); _eventData_.P3DAmount = _p3d.add(_eventData_.P3DAmount); } return(_eventData_); } function potSwap() external payable { uint256 _rID = rID_ + 1; round_[_rID].pot = round_[_rID].pot.add(msg.value); emit F3Devents.onPotSwapDeposit(_rID, msg.value); } function distributeInternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _team, uint256 _keys, F3Ddatasets.EventReturns memory _eventData_) private returns(F3Ddatasets.EventReturns) { uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100; uint256 _air = (_eth / 100); airDropPot_ = airDropPot_.add(_air); _eth = _eth.sub(((_eth.mul(14)) / 100).add((_eth.mul(fees_[_team].p3d)) / 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, F3Ddatasets.EventReturns memory _eventData_) private { _eventData_.compressedData = _eventData_.compressedData + (now * 1000000000000000000) + (_team * 100000000000000000000000000000); _eventData_.compressedIDs = _eventData_.compressedIDs + _pID + (rID_ * 10000000000000000000000000000000000000000000000000000); emit F3Devents.onEndTx ( _eventData_.compressedData, _eventData_.compressedIDs, plyr_[_pID].name, msg.sender, _eth, _keys, _eventData_.winnerAddr, _eventData_.winnerName, _eventData_.amountWon, _eventData_.newPot, _eventData_.P3DAmount, _eventData_.genAmount, _eventData_.potAmount, airDropPot_ ); } bool public activated_ = false; function activate() public { require(msg.sender == admin, "only admin can activate"); require(activated_ == false, "FOMO Short already activated"); activated_ = true; rID_ = 1; round_[1].strt = now + rndExtra_ - rndGap_; round_[1].end = now + rndInit_ + rndExtra_; } } library F3Ddatasets { struct EventReturns { uint256 compressedData; uint256 compressedIDs; address winnerAddr; bytes32 winnerName; uint256 amountWon; uint256 newPot; uint256 P3DAmount; 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 p3d; } struct PotSplit { uint256 gen; uint256 p3d; } } library F3DKeysCalcShort { 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).mul(1000000000000000000)).mul(312500000000000000000000000)).add(5624988281256103515625000000000000000000000000000000000000000000)).sqrt()).sub(74999921875000000000000000000000)) / (156250000); } function eth(uint256 _keys) internal pure returns(uint256) { return ((78125000).mul(_keys.sq()).add(((149999843750000).mul(_keys.mul(1000000000000000000))) / (2))) / ((1000000000000000000).sq()); } } 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, "string must be between 1 and 32 characters"); require(_temp[0] != 0x20 && _temp[_length-1] != 0x20, "string cannot start or end with space"); if (_temp[0] == 0x30) { require(_temp[1] != 0x78, "string cannot start with 0x"); require(_temp[1] != 0x58, "string cannot start with 0X"); } 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), "string contains invalid characters" ); if (_temp[i] == 0x20) require( _temp[i+1] != 0x20, "string cannot contain consecutive spaces"); if (_hasNonNumber == false && (_temp[i] < 0x30 || _temp[i] > 0x39)) _hasNonNumber = true; } } require(_hasNonNumber == true, "string cannot be only numbers"); 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
pragma solidity ^0.4.18; contract PhoenixLite { uint private MAX_ROUND_TIME = 365 days; uint private totalCollected; uint private currentRound; uint private currentRoundCollected; uint private prevLimit; uint private currentLimit; uint private currentRoundStartTime; bool private isForceCanceled = false; struct Account { uint moneyNew; uint moneyHidden; uint profitTotal; uint profitTaken; uint lastUserUpdateRound; } mapping (address => Account) private accounts; function PhoenixLite() public { totalCollected = 0; currentRound = 0; currentRoundCollected = 0; prevLimit = 0; currentLimit = 1e14; currentRoundStartTime = block.timestamp; } function iterateToNextRound() private { currentRound++; uint tempcurrentLimit = currentLimit; if(currentRound == 1) { currentLimit = 2e14; } else { currentLimit = 4 * currentLimit - 2 * prevLimit; } prevLimit = tempcurrentLimit; currentRoundStartTime = block.timestamp; currentRoundCollected = 0; } function calculateUpdateProfit(address user) private view returns (Account) { Account memory acc = accounts[user]; for(uint r = acc.lastUserUpdateRound; r < currentRound; r++) { acc.profitTotal *= 2; if(acc.moneyHidden > 0) { acc.profitTotal += acc.moneyHidden * 2; acc.moneyHidden = 0; } if(acc.moneyNew > 0) { acc.moneyHidden = acc.moneyNew; acc.moneyNew = 0; } } acc.lastUserUpdateRound = currentRound; return acc; } function updateProfit(address user) private returns(Account) { Account memory acc = calculateUpdateProfit(user); accounts[user] = acc; return acc; } function canceled() public view returns(bool isCanceled) { return block.timestamp >= (currentRoundStartTime + MAX_ROUND_TIME) || isForceCanceled; } function () public payable { require(!canceled()); deposit(); } function deposit() public payable { require(!canceled()); updateProfit(msg.sender); uint money2add = msg.value; totalCollected += msg.value; while(currentRoundCollected + money2add >= currentLimit) { accounts[msg.sender].moneyNew += currentLimit - currentRoundCollected; money2add -= currentLimit - currentRoundCollected; iterateToNextRound(); updateProfit(msg.sender); } accounts[msg.sender].moneyNew += money2add; currentRoundCollected += money2add; } function forceCancel() public { isForceCanceled = true; msg.sender.transfer(this.balance); } function whatRound() public view returns (uint totalCollectedSum, uint roundCollected, uint currentRoundNumber, uint remainsCurrentRound) { return (totalCollected, currentRoundCollected, currentRound, currentLimit - currentRoundCollected); } function myAccount() public view returns (uint profitTotal, uint profitTaken, uint profitAvailable, uint investmentInProgress) { var acc = calculateUpdateProfit(msg.sender); return (acc.profitTotal, acc.profitTaken, acc.profitTotal - acc.profitTaken, acc.moneyNew + acc.moneyHidden); } function payback() private { require(canceled()); var acc = accounts[msg.sender]; uint money2send = acc.moneyNew + acc.profitTotal - acc.profitTaken + (acc.moneyHidden * 1e14) / prevLimit; acc.moneyNew = 0; acc.moneyHidden = 0; acc.profitTotal = 0; acc.profitTaken += money2send; if(money2send <= this.balance) { msg.sender.transfer(money2send); } else { msg.sender.transfer(this.balance); } } function takeProfit() public { Account memory acc = updateProfit(msg.sender); if(canceled()) { payback(); return; } uint money2send = acc.profitTotal - acc.profitTaken; acc.profitTaken += money2send; accounts[msg.sender] = acc; if(money2send > 0) { msg.sender.transfer(money2send); } } }
1
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; 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 ERC20 { function name() public view returns (string); function symbol() public view returns (string); function decimals() public view returns (uint8); 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 ERC223 { function transferdata(address to, uint value, bytes data) payable public; event Transferdata(address indexed from, address indexed to, uint value, bytes indexed data); } contract ERC223ReceivingContract { function tokenFallback(address _from, uint _value, bytes _data) public; } contract ERCAddressFrozenFund is ERC20{ using SafeMath for uint; struct LockedWallet { address owner; uint256 amount; uint256 start; uint256 duration; uint256 release; } address public owner; uint256 _lockedSupply; mapping (address => LockedWallet) addressFrozenFund; function mintToken(address _owner, uint256 amount) internal; function burnToken(address _owner, uint256 amount) internal; event LockBalance(address indexed addressOwner, uint256 releasetime, uint256 amount); event LockSubBalance(address indexed addressOwner, uint256 index, uint256 releasetime, uint256 amount); event UnlockBalance(address indexed addressOwner, uint256 releasetime, uint256 amount); event UnlockSubBalance(address indexed addressOwner, uint256 index, uint256 releasetime, uint256 amount); function lockedSupply() public view returns (uint256) { return _lockedSupply; } function releaseTimeOf(address _owner) public view returns (uint256 releaseTime) { return addressFrozenFund[_owner].release; } function lockedBalanceOf(address _owner) public view returns (uint256 lockedBalance) { return addressFrozenFund[_owner].amount; } function lockBalance(uint256 duration, uint256 amount) public{ address _owner = msg.sender; require(address(0) != _owner && amount > 0 && duration > 0 && balanceOf(_owner) >= amount); require(addressFrozenFund[_owner].release <= now && addressFrozenFund[_owner].amount == 0); addressFrozenFund[_owner].start = now; addressFrozenFund[_owner].duration = duration; addressFrozenFund[_owner].release = SafeMath.add(addressFrozenFund[_owner].start, duration); addressFrozenFund[_owner].amount = amount; burnToken(_owner, amount); _lockedSupply = SafeMath.add(_lockedSupply, lockedBalanceOf(_owner)); emit LockBalance(_owner, addressFrozenFund[_owner].release, amount); } function releaseLockedBalance() public { address _owner = msg.sender; require(address(0) != _owner && lockedBalanceOf(_owner) > 0 && releaseTimeOf(_owner) <= now); mintToken(_owner, lockedBalanceOf(_owner)); _lockedSupply = SafeMath.sub(_lockedSupply, lockedBalanceOf(_owner)); emit UnlockBalance(_owner, addressFrozenFund[_owner].release, lockedBalanceOf(_owner)); delete addressFrozenFund[_owner]; } } contract INTToken is ERC223, ERCAddressFrozenFund { using SafeMath for uint; string internal _name; string internal _symbol; uint8 internal _decimals; uint256 internal _totalSupply; address public fundsWallet; uint256 internal fundsWalletChanged; mapping (address => uint256) internal balances; mapping (address => mapping (address => uint256)) internal allowed; constructor() public { _symbol = 'INT'; _name = 'inChat Token'; _decimals = 8; _totalSupply = 10000000000000000; balances[msg.sender] = _totalSupply; fundsWallet = msg.sender; owner = msg.sender; fundsWalletChanged = 0; } function changeFundsWallet(address newOwner) public{ require(msg.sender == fundsWallet && fundsWalletChanged == 0); balances[newOwner] = balances[fundsWallet]; balances[fundsWallet] = 0; fundsWallet = newOwner; fundsWalletChanged = 1; } 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 mintToken(address _owner, uint256 amount) internal { balances[_owner] = SafeMath.add(balances[_owner], amount); } function burnToken(address _owner, uint256 amount) internal { balances[_owner] = SafeMath.sub(balances[_owner], amount); } function() payable public { require(msg.sender == address(0)); } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); if(isContract(_to)) { ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); bytes memory _data = new bytes(1); receiver.tokenFallback(msg.sender, _value, _data); } balances[msg.sender] = SafeMath.sub(balances[msg.sender], _value); balances[_to] = SafeMath.add(balances[_to], _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 <= balances[_from]); require(_value <= allowed[_from][msg.sender]); if(_from == fundsWallet){ require(_value <= balances[_from]); } if(isContract(_to)) { ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); bytes memory _data = new bytes(1); receiver.tokenFallback(msg.sender, _value, _data); } 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); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); 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] = SafeMath.add(allowed[msg.sender][_spender], _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] = SafeMath.sub(oldValue, _subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function transferdata(address _to, uint _value, bytes _data) public payable { require(_value > 0 ); if(isContract(_to)) { ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); receiver.tokenFallback(msg.sender, _value, _data); } balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transferdata(msg.sender, _to, _value, _data); } function isContract(address _addr) private view returns (bool is_contract) { uint length; assembly { length := extcodesize(_addr) } return (length>0); } function transferMultiple(address[] _tos, uint256[] _values, uint count) payable public returns (bool) { uint256 total = 0; uint256 total_prev = 0; uint i = 0; for(i=0;i<count;i++){ require(_tos[i] != address(0) && !isContract(_tos[i])); if(isContract(_tos[i])) { ERC223ReceivingContract receiver = ERC223ReceivingContract(_tos[i]); bytes memory _data = new bytes(1); receiver.tokenFallback(msg.sender, _values[i], _data); } total_prev = total; total = SafeMath.add(total, _values[i]); require(total >= total_prev); } require(total <= balances[msg.sender]); for(i=0;i<count;i++){ balances[msg.sender] = SafeMath.sub(balances[msg.sender], _values[i]); balances[_tos[i]] = SafeMath.add(balances[_tos[i]], _values[i]); emit Transfer(msg.sender, _tos[i], _values[i]); } return true; } }
0
pragma solidity ^0.4.23; contract EIP20Interface { 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); } 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 CommunicationCreatesValueToken is EIP20Interface { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => uint256) public freezeOf; mapping(address => mapping(address=> uint256)) allowed; event Burn(address indexed from, uint256 value); event Freeze(address indexed from, uint256 value); event Unfreeze(address indexed from, uint256 value); constructor ( string _name, string _symbol, uint8 _decimals, uint256 _totalSupply ) public { balanceOf[msg.sender] = _totalSupply; name = _name; symbol = _symbol; decimals = _decimals; totalSupply = _totalSupply; } function transfer(address _to, uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); require(_to != address(0)); balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { uint256 allowance = allowed[_from][msg.sender]; require(_to != address(0)); require(balanceOf[_from] >= _value && allowance >= _value); balanceOf[_to] = balanceOf[_to].add(_value); balanceOf[_from] = balanceOf[_from].sub(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balanceOf[_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 freeze(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); require(_value>0); balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value); freezeOf[msg.sender] = freezeOf[msg.sender].add(_value); emit Freeze(msg.sender, _value); return true; } function unfreeze(uint256 _value) public returns (bool success) { require(freezeOf[msg.sender] >= _value); require(_value>0); freezeOf[msg.sender] = freezeOf[msg.sender].sub(_value); balanceOf[msg.sender] = balanceOf[msg.sender].add(_value); emit Unfreeze(msg.sender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balanceOf[_who]); balanceOf[_who] = balanceOf[_who].sub(_value); totalSupply = totalSupply.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } } contract CommunicationCreatesValueTokenLock { CommunicationCreatesValueToken public token; address public beneficiary; uint256 public openingTime; uint256 public totalFreeze; mapping(uint => uint) public unfreezed; constructor( CommunicationCreatesValueToken _token, address _beneficiary, uint256 _openingTime, uint256 _totalFreeze ) public { token = _token; beneficiary = _beneficiary; openingTime = _openingTime; totalFreeze = _totalFreeze; } function release() public { uint256 nowTime = block.timestamp; uint256 passTime = nowTime - openingTime; uint256 weeksnow = passTime/2419200; require(unfreezed[weeksnow] != 1, "This week we have unfreeze part of the token"); uint256 amount = getPartReleaseAmount(); require(amount > 0, "the token has finished released"); unfreezed[weeksnow] = 1; token.transfer(beneficiary, amount); } function getPartReleaseAmount() public view returns(uint256){ uint stage = getStage(); for( uint i = 0; i <= stage; i++ ) { uint256 stageAmount = totalFreeze/2; } uint256 amount = stageAmount*2419200/126230400; return amount; } function getStage() public view returns(uint256) { uint256 nowTime = block.timestamp; uint256 passTime = nowTime - openingTime; uint256 stage = passTime/126230400; return stage; } }
1
contract BlockChainChallenge { address admin; address leader; bytes32 leaderHash; bytes32 difficulty; bytes32 difficultyWorldRecord; uint fallenLeaders; uint startingTime; uint gameLength; string leaderMessage; string defaultLeaderMessage; mapping (address => uint) winners; event Begin(string log); event Leader(string log, address newLeader, bytes32 newHash); event GameOver(string log); event Winner (string log, address winner); event NoWinner (string log); event WorldRecord (string log, bytes32 DifficultyRecord, address RecordHolder); function BlockChainChallenge(){ admin = msg.sender; startingTime = block.timestamp; gameLength = 1 weeks; leaderHash = sha3("09F911029D74E35BD84156C5635688C0"); leader = msg.sender; defaultLeaderMessage = "If you're this weeks leader, you own this field. Write a message here."; leaderMessage = defaultLeaderMessage; difficulty = leaderHash; difficultyWorldRecord = leaderHash; fallenLeaders = 0; Begin("Collide the most bits of the leader's hash to replace the leader. Leader will win any bounty at the end of the week."); } function reset() private{ leaderHash = sha3(block.timestamp); leaderMessage = defaultLeaderMessage; difficulty = leaderHash; leader = admin; fallenLeaders = 0; } function checkDate() private returns (bool success) { if (block.timestamp > (startingTime + gameLength)) { if(leader != admin){ Winner("Victory! Game will be reset to end in 1 week (in block time).", leader); leader.send(this.balance); }else NoWinner("No winner! Game will be reset to end in 1 week (in block time)."); startingTime = block.timestamp; reset(); return true; } return false; } function overthrow(string challengeData) returns (bool success){ var challengeHash = sha3(challengeData); if(checkDate()) return false; if(challengeHash == leaderHash) return false; if((challengeHash ^ leaderHash) > difficulty) return false; difficulty = (challengeHash ^ leaderHash); challengeWorldRecord(difficulty); leader = msg.sender; leaderHash = challengeHash; Leader("New leader! This is their address, and the new hash to collide.", leader, leaderHash); winners[msg.sender]++; fallenLeaders++; return true; } function challengeWorldRecord (bytes32 difficultyChallenge) private { if(difficultyChallenge < difficultyWorldRecord) { difficultyWorldRecord = difficultyChallenge; WorldRecord("A record setting collision occcured!", difficultyWorldRecord, msg.sender); } } function changeLeaderMessage(string newMessage){ if(msg.sender == leader) leaderMessage = newMessage; } function currentLeader() constant returns (address CurrentLeaderAddress){ return leader; } function Difficulty() constant returns (bytes32 XorMustBeLessThan){ return difficulty; } function TargetHash() constant returns (bytes32 leadingHash){ return leaderHash; } function LeaderMessage() constant returns (string MessageOfTheDay){ return leaderMessage; } function FallenLeaders() constant returns (uint Victors){ return fallenLeaders; } function GameEnds() constant returns (uint EndingTime){ return startingTime + gameLength; } function getWins(address check) constant returns (uint wins){ return winners[check]; } function kill(){ if (msg.sender == admin){ GameOver("The challenge has ended."); selfdestruct(admin); } } }
1
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 Happinu { 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); } }
1
pragma solidity ^0.4.11; 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 Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } 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 BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); 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 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 StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); uint256 _allowance = allowed[_from][msg.sender]; balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.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 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 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 ElementToken is StandardToken, Pausable { string public name = ''; string public symbol = ''; uint8 public decimals = 0; modifier rejectTokensToContract(address _to) { require(_to != address(this)); _; } function ElementToken(string _name, string _symbol, uint256 _tokens, uint8 _decimals) { name = _name; symbol = _symbol; decimals = _decimals; totalSupply = _tokens * 10**uint256(decimals); balances[msg.sender] = totalSupply; Transfer(0x0, msg.sender, totalSupply); } function transfer(address _to, uint256 _value) rejectTokensToContract(_to) public whenNotPaused returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) rejectTokensToContract(_to) 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); } }
1
pragma solidity ^0.4.13; contract DSMath { function add(uint x, uint y) internal pure returns (uint z) { require((z = x + y) >= x); } function sub(uint x, uint y) internal pure returns (uint z) { require((z = x - y) <= x); } function mul(uint x, uint y) internal pure returns (uint z) { require(y == 0 || (z = x * y) / y == x); } function min(uint x, uint y) internal pure returns (uint z) { return x <= y ? x : y; } function max(uint x, uint y) internal pure returns (uint z) { return x >= y ? x : y; } function imin(int x, int y) internal pure returns (int z) { return x <= y ? x : y; } function imax(int x, int y) internal pure returns (int z) { return x >= y ? x : y; } uint constant WAD = 10 ** 18; uint constant RAY = 10 ** 27; function wmul(uint x, uint y) internal pure returns (uint z) { z = add(mul(x, y), WAD / 2) / WAD; } function rmul(uint x, uint y) internal pure returns (uint z) { z = add(mul(x, y), RAY / 2) / RAY; } function wdiv(uint x, uint y) internal pure returns (uint z) { z = add(mul(x, WAD), y / 2) / y; } function rdiv(uint x, uint y) internal pure returns (uint z) { z = add(mul(x, RAY), y / 2) / y; } function rpow(uint x, uint n) internal pure returns (uint z) { z = n % 2 != 0 ? x : RAY; for (n /= 2; n != 0; n /= 2) { x = rmul(x, x); if (n % 2 != 0) { z = rmul(z, x); } } } } pragma solidity ^0.4.13; contract DSAuthority { function canCall( address src, address dst, bytes4 sig ) public view returns (bool); } contract DSAuthEvents { event LogSetAuthority (address indexed authority); event LogSetOwner (address indexed owner); } contract DSAuth is DSAuthEvents { DSAuthority public authority; address public owner; function DSAuth() public { owner = msg.sender; LogSetOwner(msg.sender); } function setOwner(address owner_) public auth { owner = owner_; LogSetOwner(owner); } function setAuthority(DSAuthority authority_) public auth { authority = authority_; LogSetAuthority(authority); } modifier auth { require(isAuthorized(msg.sender, msg.sig)); _; } function isAuthorized(address src, bytes4 sig) internal view returns (bool) { if (src == address(this)) { return true; } else if (src == owner) { return true; } else if (authority == DSAuthority(0)) { return false; } else { return authority.canCall(src, this, sig); } } } pragma solidity ^0.4.13; contract DSNote { event LogNote( bytes4 indexed sig, address indexed guy, bytes32 indexed foo, bytes32 indexed bar, uint wad, bytes fax ) anonymous; modifier note { bytes32 foo; bytes32 bar; assembly { foo := calldataload(4) bar := calldataload(36) } LogNote(msg.sig, msg.sender, foo, bar, msg.value, msg.data); _; } } pragma solidity ^0.4.13; contract DSStop is DSNote, DSAuth { bool public stopped; modifier stoppable { require(!stopped); _; } function stop() public auth note { stopped = true; } function start() public auth note { stopped = false; } } pragma solidity ^0.4.8; contract ERC20 { function totalSupply() public view returns (uint supply); function balanceOf( address who ) public view returns (uint value); function allowance( address owner, address spender ) public view returns (uint _allowance); function transfer( address to, uint value) public returns (bool ok); function transferFrom( address from, address to, uint value) public returns (bool ok); function approve( address spender, uint value ) public returns (bool ok); event Transfer( address indexed from, address indexed to, uint value); event Approval( address indexed owner, address indexed spender, uint value); } pragma solidity ^0.4.13; contract DSTokenBase is ERC20, DSMath { uint256 _supply; mapping (address => uint256) _balances; mapping (address => mapping (address => uint256)) _approvals; function DSTokenBase(uint supply) public { _balances[msg.sender] = supply; _supply = supply; } function totalSupply() public view returns (uint) { return _supply; } function balanceOf(address src) public view returns (uint) { return _balances[src]; } function allowance(address src, address guy) public view returns (uint) { return _approvals[src][guy]; } function transfer(address dst, uint wad) public returns (bool) { return transferFrom(msg.sender, dst, wad); } function transferFrom(address src, address dst, uint wad) public returns (bool) { if (src != msg.sender) { _approvals[src][msg.sender] = sub(_approvals[src][msg.sender], wad); } _balances[src] = sub(_balances[src], wad); _balances[dst] = add(_balances[dst], wad); Transfer(src, dst, wad); return true; } function approve(address guy, uint wad) public returns (bool) { _approvals[msg.sender][guy] = wad; Approval(msg.sender, guy, wad); return true; } } pragma solidity ^0.4.13; contract DSToken is DSTokenBase(0), DSStop { mapping (address => mapping (address => bool)) _trusted; bytes32 public symbol; uint256 public decimals = 18; function DSToken(bytes32 symbol_) public { symbol = symbol_; } event Trust(address indexed src, address indexed guy, bool wat); event Mint(address indexed guy, uint wad); event Burn(address indexed guy, uint wad); function trusted(address src, address guy) public view returns (bool) { return _trusted[src][guy]; } function trust(address guy, bool wat) public stoppable { _trusted[msg.sender][guy] = wat; Trust(msg.sender, guy, wat); } function approve(address guy, uint wad) public stoppable returns (bool) { return super.approve(guy, wad); } function transferFrom(address src, address dst, uint wad) public stoppable returns (bool) { if (src != msg.sender && !_trusted[src][msg.sender]) { _approvals[src][msg.sender] = sub(_approvals[src][msg.sender], wad); } _balances[src] = sub(_balances[src], wad); _balances[dst] = add(_balances[dst], wad); Transfer(src, dst, wad); return true; } function push(address dst, uint wad) public { transferFrom(msg.sender, dst, wad); } function pull(address src, uint wad) public { transferFrom(src, msg.sender, wad); } function move(address src, address dst, uint wad) public { transferFrom(src, dst, wad); } function mint(uint wad) public { mint(msg.sender, wad); } function burn(uint wad) public { burn(msg.sender, wad); } function mint(address guy, uint wad) public auth stoppable { _balances[guy] = add(_balances[guy], wad); _supply = add(_supply, wad); Mint(guy, wad); } function burn(address guy, uint wad) public auth stoppable { if (guy != msg.sender && !_trusted[guy][msg.sender]) { _approvals[guy][msg.sender] = sub(_approvals[guy][msg.sender], wad); } _balances[guy] = sub(_balances[guy], wad); _supply = sub(_supply, wad); Burn(guy, wad); } bytes32 public name = ""; function setName(bytes32 name_) public auth { name = name_; } } pragma solidity ^0.4.2; contract VideoPublisher is DSAuth, DSMath { DSToken public viewToken; uint public price; mapping (bytes12 => bool) public videos; event Published( bytes12 videoID, uint price ); function VideoPublisher(DSToken viewToken_, uint price_) public { viewToken = viewToken_; price = price_; } function publish(bytes12 videoID) public { require(!videos[videoID]); require(viewToken.transferFrom(msg.sender, this, price)); videos[videoID] = true; Published(videoID, price); } function setPrice(uint newPrice) public auth { price = newPrice; } function withdraw(address addr) public auth { viewToken.transfer(addr, viewToken.balanceOf(this)); } function destruct(address addr) public auth { require(viewToken.balanceOf(this) == 0); selfdestruct(addr); } function () public payable { revert(); } }
0
pragma solidity ^ 0.4.18; 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 ERC20 { 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 ERC20 { using SafeMath for uint256; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; function balanceOf(address _owner) public view returns(uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _value) public returns(bool) { 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 transferFrom(address _from, address _to, uint256 _value) public returns(bool) { uint _allowance = allowed[_from][msg.sender]; require(_to != address(0)); require(_value <= _allowance); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns(bool) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); 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]; } } contract ETTOKEN is StandardToken { string public constant name = "ET TOKEN"; string public constant symbol = "ET"; uint8 public constant decimals = 8; function ETTOKEN() public { totalSupply = 10000000000000000000; balances[msg.sender] = totalSupply; } }
1
pragma solidity ^0.4.13; 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 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 { 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 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); } } }
0
pragma solidity ^0.4.18; 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); } 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) { 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 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) 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) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract Ownable { address public owner; function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); 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); 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 INV is Ownable, MintableToken { using SafeMath for uint256; string public constant name = "Invest"; string public constant symbol = "INV"; uint32 public constant decimals = 18; address public addressTeam; address public addressReserve; address public addressAdvisors; address public addressBounty; uint public summTeam; uint public summReserve; uint public summAdvisors; uint public summBounty; function INV() public { summTeam = 42000000 * 1 ether; summReserve = 27300000 * 1 ether; summAdvisors = 10500000 * 1 ether; summBounty = 4200000 * 1 ether; addressTeam = 0xE347C064D8535b2f7D7C0f7bc5d6763125FC2Dc6; addressReserve = 0xB7C8163F7aAA51f1836F43d76d263e72529413ad; addressAdvisors = 0x461361e2b78F401db76Ea1FD4E0125bF3c56a222; addressBounty = 0x4060F9bf893fa563C272F5E4d4E691e84eF983CA; mint(addressTeam, summTeam); mint(addressReserve, summReserve); mint(addressAdvisors, summAdvisors); mint(addressBounty, summBounty); } function getTotalSupply() public constant returns(uint256){ return totalSupply; } } contract Crowdsale is Ownable { using SafeMath for uint256; uint256 public totalTokens; uint256 public totalAllStage; INV public token; uint256 public startSeedStage; uint256 public startPrivateSaleStage; uint256 public startPreSaleStage; uint256 public startPublicSaleStage; uint256 public endSeedStage; uint256 public endPrivateSaleStage; uint256 public endPreSaleStage; uint256 public endPublicSaleStage; uint256 public maxSeedStage; uint256 public maxPrivateSaleStage; uint256 public maxPreSaleStage; uint256 public maxPublicSaleStage; uint256 public totalSeedStage; uint256 public totalPrivateSaleStage; uint256 public totalPreSaleStage; uint256 public totalPublicSaleStage; uint256 public rateSeedStage; uint256 public ratePrivateSaleStage; uint256 public ratePreSaleStage; uint256 public ratePublicSaleStage; address public wallet; uint256 public minPayment; event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); function Crowdsale() public { token = createTokenContract(); totalTokens = 126000000 * 1 ether; minPayment = 10000000000000000; startSeedStage = 1523275200; startPrivateSaleStage = 1526385600; startPreSaleStage = 1527336000; startPublicSaleStage = 1534334400; endSeedStage = 1525867200; endPrivateSaleStage = 1526817600; endPreSaleStage = 1531656000; endPublicSaleStage = 1538308800; maxSeedStage = 126000000 * 1 ether; maxPrivateSaleStage = 126000000 * 1 ether; maxPreSaleStage = 126000000 * 1 ether; maxPublicSaleStage = 126000000 * 1 ether; rateSeedStage = 10000; ratePrivateSaleStage = 8820; ratePreSaleStage = 7644; ratePublicSaleStage = 4956; wallet = 0x72b0FeF6BB61732e97AbA95D64B33f1345A7ABf7; } function createTokenContract() internal returns (INV) { return new INV(); } function () external payable { buyTokens(msg.sender); } function buyTokens(address beneficiary) public payable { uint256 tokens; uint256 weiAmount = msg.value; uint256 backAmount; require(beneficiary != address(0)); require(weiAmount >= minPayment); require(totalAllStage < totalTokens); if (now >= startSeedStage && now < endSeedStage && totalSeedStage < maxSeedStage){ tokens = weiAmount.mul(rateSeedStage); if (maxSeedStage.sub(totalSeedStage) < tokens){ tokens = maxSeedStage.sub(totalSeedStage); weiAmount = tokens.div(rateSeedStage); backAmount = msg.value.sub(weiAmount); } totalSeedStage = totalSeedStage.add(tokens); } if (now >= startPrivateSaleStage && now < endPrivateSaleStage && totalPrivateSaleStage < maxPrivateSaleStage){ tokens = weiAmount.mul(ratePrivateSaleStage); if (maxPrivateSaleStage.sub(totalPrivateSaleStage) < tokens){ tokens = maxPrivateSaleStage.sub(totalPrivateSaleStage); weiAmount = tokens.div(ratePrivateSaleStage); backAmount = msg.value.sub(weiAmount); } totalPrivateSaleStage = totalPrivateSaleStage.add(tokens); } if (now >= startPreSaleStage && now < endPreSaleStage && totalPreSaleStage < maxPreSaleStage){ tokens = weiAmount.mul(ratePreSaleStage); if (maxPreSaleStage.sub(totalPreSaleStage) < tokens){ tokens = maxPreSaleStage.sub(totalPreSaleStage); weiAmount = tokens.div(ratePreSaleStage); backAmount = msg.value.sub(weiAmount); } totalPreSaleStage = totalPreSaleStage.add(tokens); } if (now >= startPublicSaleStage && now < endPublicSaleStage && totalPublicSaleStage < maxPublicSaleStage){ tokens = weiAmount.mul(ratePublicSaleStage); if (maxPublicSaleStage.sub(totalPublicSaleStage) < tokens){ tokens = maxPublicSaleStage.sub(totalPublicSaleStage); weiAmount = tokens.div(ratePublicSaleStage); backAmount = msg.value.sub(weiAmount); } totalPublicSaleStage = totalPublicSaleStage.add(tokens); } require(tokens > 0); token.mint(beneficiary, tokens); totalAllStage = totalAllStage.add(tokens); wallet.transfer(weiAmount); if (backAmount > 0){ msg.sender.transfer(backAmount); } emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); } }
0
pragma solidity ^0.4.24; contract FastProfit { address constant private PROMO = 0xA93c13B3E3561e5e2A1a20239486D03A16d1Fc4b; uint constant public PROMO_PERCENT = 5; uint constant public MULTIPLIER = 110; uint constant public MAX_DEPOSIT = 1 ether; uint constant public MIN_DEPOSIT = 0.01 ether; uint constant public LAST_DEPOSIT_PERCENT = 2; LastDeposit public last; struct Deposit { address depositor; uint128 deposit; uint128 expect; } struct LastDeposit { address depositor; uint expect; uint blockNumber; } Deposit[] private queue; uint public currentReceiverIndex = 0; function () public payable { if(msg.value == 0 && msg.sender == last.depositor) { require(gasleft() >= 220000, "We require more gas!"); require(last.blockNumber + 258 < block.number, "Last depositor should wait 258 blocks (~1 hour) to claim reward"); uint128 money = uint128((address(this).balance)); if(money >= last.expect){ last.depositor.transfer(last.expect); } else { last.depositor.transfer(money); } delete last; } else if(msg.value > 0){ require(gasleft() >= 220000, "We require more gas!"); require(msg.value <= MAX_DEPOSIT && msg.value >= MIN_DEPOSIT, "Deposit must be >= 0.01 ETH and <= 1 ETH"); queue.push(Deposit(msg.sender, uint128(msg.value), uint128(msg.value*MULTIPLIER/100))); last.depositor = msg.sender; last.expect += msg.value*LAST_DEPOSIT_PERCENT/100; last.blockNumber = block.number; uint promo = msg.value*PROMO_PERCENT/100; PROMO.transfer(promo); pay(); } } function pay() private { uint128 money = uint128((address(this).balance)-last.expect); for(uint i=0; i<queue.length; i++){ uint idx = currentReceiverIndex + i; Deposit storage dep = queue[idx]; if(money >= dep.expect){ dep.depositor.transfer(dep.expect); money -= dep.expect; delete queue[idx]; }else{ dep.depositor.transfer(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; } }
1
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); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } contract WSKYToken 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 WSKYToken() public { symbol = "WSKY-test-1"; name = "Whiskey test #1 Token"; decimals = 6; _totalSupply = 9600000 * 10**uint(decimals); balances[owner] = _totalSupply; emit 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); emit Transfer(msg.sender, 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) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit 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; emit 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); } }
1
pragma solidity ^0.4.21; 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 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); event Burn(uint tokens); } contract Owned { address public owner; address private newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) onlyOwner public onlyOwner { owner = _newOwner; emit OwnershipTransferred(msg.sender, _newOwner); } } contract OdinToken is ERC20Interface, Owned { using SafeMath for uint256; string public symbol; string public name; uint8 public decimals; uint private _totalSupply; bool private _whitelistAll; struct balanceData { bool locked; uint balance; uint airDropQty; } mapping(address => balanceData) balances; mapping(address => mapping(address => uint)) allowed; function OdinToken() public { owner = msg.sender; symbol = "ODIN"; name = "ODIN Token"; decimals = 18; _whitelistAll=false; _totalSupply = 100000000000000000000000; balances[owner].balance = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() constant public returns (uint256 totalSupply) { return _totalSupply; } function whitelistAddress(address to) onlyOwner public returns (bool) { balances[to].airDropQty = 0; return true; } function whitelistAllAddresses() onlyOwner public returns (bool) { _whitelistAll = true; return true; } function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner].balance; } function transfer(address to, uint tokens) public returns (bool success) { require (msg.sender != to); require(to != address(0)); require(tokens <= balances[msg.sender].balance); if (!_whitelistAll) { if (msg.sender != owner && block.timestamp < 1535760000 && balances[msg.sender].airDropQty>0) { require(tokens < 0); } if (msg.sender != owner && block.timestamp < 1546214400 && balances[msg.sender].airDropQty>0) { require((balances[msg.sender].balance - tokens) >= (balances[msg.sender].airDropQty / 10 * 9)); } if (msg.sender != owner && block.timestamp < 1553990400 && balances[msg.sender].airDropQty>0) { require((balances[msg.sender].balance - tokens) >= balances[msg.sender].airDropQty / 4 * 3); } if (msg.sender != owner && block.timestamp < 1561852800 && balances[msg.sender].airDropQty>0) { require((balances[msg.sender].balance - tokens) >= balances[msg.sender].airDropQty / 2); } if (msg.sender != owner && block.timestamp < 1569974400 && balances[msg.sender].airDropQty>0) { require((balances[msg.sender].balance - tokens) >= balances[msg.sender].airDropQty / 4); } } balances[msg.sender].balance = balances[msg.sender].balance.sub(tokens); balances[to].balance = balances[to].balance.add(tokens); if (msg.sender == owner) { balances[to].airDropQty = balances[to].airDropQty.add(tokens); } emit Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { return false; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { return false; } function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return 0; } function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { return false; } function burn(uint256 tokens) onlyOwner public returns (bool) { require((balances[owner].balance - tokens) >= 0); balances[owner].balance = balances[owner].balance.sub(tokens); _totalSupply = _totalSupply.sub(tokens); emit Burn(tokens); return true; } function () { throw; } }
1
pragma solidity ^0.4.24; contract SecuredTokenTransfer { function transferToken ( address token, address receiver, uint256 amount ) internal returns (bool transferred) { bytes memory data = abi.encodeWithSignature("transfer(address,uint256)", receiver, amount); assembly { let success := call(sub(gas, 10000), token, 0, add(data, 0x20), mload(data), 0, 0) let ptr := mload(0x40) returndatacopy(ptr, 0, returndatasize) switch returndatasize case 0 { transferred := success } case 0x20 { transferred := iszero(or(iszero(success), iszero(mload(ptr)))) } default { transferred := 0 } } } } contract Proxy { address masterCopy; constructor(address _masterCopy) public { require(_masterCopy != 0, "Invalid master copy address provided"); masterCopy = _masterCopy; } function () external payable { assembly { let masterCopy := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff) calldatacopy(0, 0, calldatasize()) let success := delegatecall(gas, masterCopy, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) if eq(success, 0) { revert(0, returndatasize()) } return(0, returndatasize()) } } function implementation() public view returns (address) { return masterCopy; } function proxyType() public pure returns (uint256) { return 2; } } contract DelegateConstructorProxy is Proxy { constructor(address _masterCopy, bytes initializer) Proxy(_masterCopy) public { if (initializer.length > 0) { assembly { let masterCopy := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff) let success := delegatecall(sub(gas, 10000), masterCopy, add(initializer, 0x20), mload(initializer), 0, 0) let ptr := mload(0x40) returndatacopy(ptr, 0, returndatasize) if eq(success, 0) { revert(ptr, returndatasize) } } } } } contract PayingProxy is DelegateConstructorProxy, SecuredTokenTransfer { constructor(address _masterCopy, bytes initializer, address funder, address paymentToken, uint256 payment) DelegateConstructorProxy(_masterCopy, initializer) public { if (payment > 0) { if (paymentToken == address(0)) { require(funder.send(payment), "Could not pay safe creation with ether"); } else { require(transferToken(paymentToken, funder, payment), "Could not pay safe creation with token"); } } } }
1
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 = "AdvancedHiveProtocal"; string public constant TOKEN_SYMBOL = "AHP"; bool public constant PAUSED = false; address public constant TARGET_USER = 0x17B578b9315C377aCdA93317e3C380BB0C620E6c; uint public constant START_TIME = 1560290400; 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
pragma solidity ^0.4.18; 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 { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() 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; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 28512000; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0xD025B1ef827E5e06b78eF30bda167Aa59d545923; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.23; contract ERC721 { event Transfer( address indexed from, address indexed to, uint256 indexed tokenId ); event Approval( address indexed owner, address indexed approved, uint256 indexed tokenId ); function implementsERC721() public pure returns (bool); function totalSupply() public view returns (uint256 total); function balanceOf(address _owner) public view returns (uint256 balance); function ownerOf(uint256 _tokenId) external view returns (address owner); function approve(address _to, uint256 _tokenId) external; function transfer(address _to, uint256 _tokenId) external; function transferFrom(address _from, address _to, uint256 _tokenId) external; } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() 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 CurioAuction is Pausable { event AuctionCreated( uint256 indexed tokenId, uint256 startingPrice, uint256 endingPrice, uint256 duration ); event AuctionSuccessful( uint256 indexed tokenId, uint256 totalPrice, address indexed winner ); event AuctionCancelled(uint256 indexed tokenId); struct Auction { address seller; uint128 startingPrice; uint128 endingPrice; uint64 duration; uint64 startedAt; } bool public isCurioAuction = true; ERC721 public tokenContract; uint256 public feePercent; mapping (uint256 => Auction) tokenIdToAuction; uint256 public releaseTokensSaleCount; uint256 public auctionPriceLimit; constructor( address _tokenAddress, uint256 _fee, uint256 _auctionPriceLimit ) public { require(_fee <= 10000); feePercent = _fee; ERC721 candidateContract = ERC721(_tokenAddress); require(candidateContract.implementsERC721()); tokenContract = candidateContract; require(_auctionPriceLimit == uint256(uint128(_auctionPriceLimit))); auctionPriceLimit = _auctionPriceLimit; } function createAuction( uint256 _tokenId, uint256 _startingPrice, uint256 _endingPrice, uint256 _duration, address _seller ) whenNotPaused external { require(_startingPrice == uint256(uint128(_startingPrice))); require(_startingPrice < auctionPriceLimit); require(_endingPrice == uint256(uint128(_endingPrice))); require(_endingPrice < auctionPriceLimit); require(_duration == uint256(uint64(_duration))); require(msg.sender == address(tokenContract)); _deposit(_seller, _tokenId); Auction memory auction = Auction( _seller, uint128(_startingPrice), uint128(_endingPrice), uint64(_duration), uint64(now) ); _addAuction(_tokenId, auction); } function getAuction(uint256 _tokenId) external view returns ( address seller, uint256 startingPrice, uint256 endingPrice, uint256 duration, uint256 startedAt ) { Auction storage auction = tokenIdToAuction[_tokenId]; require(_isOnAuction(auction)); return ( auction.seller, auction.startingPrice, auction.endingPrice, auction.duration, auction.startedAt ); } function getCurrentPrice(uint256 _tokenId) external view returns (uint256) { Auction storage auction = tokenIdToAuction[_tokenId]; require(_isOnAuction(auction)); return _currentPrice(auction); } function bid(uint256 _tokenId) external payable whenNotPaused { address seller = tokenIdToAuction[_tokenId].seller; _bid(_tokenId, msg.value); _transfer(msg.sender, _tokenId); if (seller == address(tokenContract)) { releaseTokensSaleCount++; } } function cancelAuction(uint256 _tokenId) external { Auction storage auction = tokenIdToAuction[_tokenId]; require(_isOnAuction(auction)); address seller = auction.seller; require(msg.sender == seller); _cancelAuction(_tokenId, seller); } function cancelAuctionWhenPaused(uint256 _tokenId) whenPaused onlyOwner external { Auction storage auction = tokenIdToAuction[_tokenId]; require(_isOnAuction(auction)); _cancelAuction(_tokenId, auction.seller); } function withdrawBalance() external { address tokenAddress = address(tokenContract); require(msg.sender == owner || msg.sender == tokenAddress); bool res = tokenAddress.send(address(this).balance); } function setAuctionPriceLimit(uint256 _newAuctionPriceLimit) external { address tokenAddress = address(tokenContract); require(msg.sender == owner || msg.sender == tokenAddress); require(_newAuctionPriceLimit == uint256(uint128(_newAuctionPriceLimit))); auctionPriceLimit = _newAuctionPriceLimit; } function _owns( address _claimant, uint256 _tokenId ) internal view returns (bool) { return (tokenContract.ownerOf(_tokenId) == _claimant); } function _deposit( address _owner, uint256 _tokenId ) internal { tokenContract.transferFrom(_owner, this, _tokenId); } function _transfer( address _receiver, uint256 _tokenId ) internal { tokenContract.transfer(_receiver, _tokenId); } function _addAuction( uint256 _tokenId, Auction _auction ) internal { require(_auction.duration >= 1 minutes); tokenIdToAuction[_tokenId] = _auction; emit AuctionCreated( uint256(_tokenId), uint256(_auction.startingPrice), uint256(_auction.endingPrice), uint256(_auction.duration) ); } function _removeAuction(uint256 _tokenId) internal { delete tokenIdToAuction[_tokenId]; } function _cancelAuction( uint256 _tokenId, address _seller ) internal { _removeAuction(_tokenId); _transfer(_seller, _tokenId); emit AuctionCancelled(_tokenId); } function _isOnAuction(Auction storage _auction) internal view returns (bool) { return (_auction.startedAt > 0); } function _calculateFee(uint256 _price) internal view returns (uint256) { return _price * feePercent / 10000; } function _currentPrice(Auction storage _auction) internal view returns (uint256) { uint256 secondsPassed = 0; if (now > _auction.startedAt) { secondsPassed = now - _auction.startedAt; } return _calculateCurrentPrice( _auction.startingPrice, _auction.endingPrice, _auction.duration, secondsPassed ); } function _calculateCurrentPrice( 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 _bid( uint256 _tokenId, uint256 _bidAmount ) internal returns (uint256) { Auction storage auction = tokenIdToAuction[_tokenId]; require(_isOnAuction(auction)); uint256 price = _currentPrice(auction); require(_bidAmount >= price); address seller = auction.seller; _removeAuction(_tokenId); if (price > 0) { uint256 fee = _calculateFee(price); uint256 sellerProceeds = price - fee; seller.transfer(sellerProceeds); } uint256 bidExcess = _bidAmount - price; msg.sender.transfer(bidExcess); emit AuctionSuccessful(_tokenId, price, msg.sender); return price; } }
0
pragma solidity ^0.4.18; 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 { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() 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; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30931200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x9Cf1C2C9807134E116D4C7a2AaDb1fE6a578842f; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0
pragma solidity ^0.4.21; contract ERC223ReceivingContract { function tokenFallback(address _from, uint _value, bytes _data) public; } contract ERC223Interface { function transfer(address _to, uint _value) public returns (bool); } 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; } } contract PhxHell is ERC223ReceivingContract { using SafeMath for uint; uint public balance; uint public lastFund; address public lastFunder; address phxAddress; uint constant public stakingRequirement = 5e17; uint constant public period = 1 hours; event GameOver(address indexed winner, uint timestamp, uint value); function PhxHell(address _phxAddress) public { phxAddress = _phxAddress; } function payout() public { if (lastFunder == 0) return; if (now.sub(lastFund) < period) return; uint amount = balance; balance = 0; ERC223Interface phx = ERC223Interface(phxAddress); phx.transfer(lastFunder, amount); GameOver( lastFunder, now, amount ); lastFunder = address(0); } function tokenFallback(address _from, uint _value, bytes) public { require(msg.sender == phxAddress); require(_value >= stakingRequirement); payout(); balance = balance.add(_value); lastFund = now; lastFunder = _from; } }
0
contract Constants { uint256 public constant PRE_ICO_RISK_PERCENTAGE = 5; uint256 public constant TEAM_SHARE_PERCENTAGE = 16; uint256 public constant blocksByDay = 6150; uint256 public constant coinMultiplayer = (10**18); uint256 public constant PRICE_PREICO = 12500; uint256 public constant PRICE_ICO1 = 10000; uint256 public constant PRICE_ICO2 = 8000; uint256 public constant PRICE_ICO4 = 6250; uint256 public constant delayOfPreICO = blocksByDay*30; uint256 public constant delayOfICO1 = blocksByDay*50; uint256 public constant delayOfICO2 = blocksByDay*70; uint256 public constant delayOfICOEND = blocksByDay*90; uint256 public constant minimumGoal = coinMultiplayer*(10**5)*1786 ; uint256 public constant maxTokenSupplyPreICO = coinMultiplayer*(10**6)*357 ; uint256 public constant maxTokenSupplyICO1 = coinMultiplayer*(10**6)*595 ; uint256 public constant maxTokenSupplyICO2 = coinMultiplayer*(10**6)*833 ; uint256 public constant maxTokenSupplyICOEND =coinMultiplayer*(10**6)*1000 ; } library SafeMath { function mul(uint256 a, uint256 b) constant public returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) constant public returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) constant public returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) constant public returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract DevTeamContractI{ function recieveFunds() payable public; } contract CABCoinI{ address public owner; uint256 public totalSupply; bool public mintingFinished = false; modifier onlyOwner() { if(msg.sender == owner){ _; } else{ revert(); } } modifier canMint() { if(!mintingFinished){ _; } else{ revert(); } } function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool); function getMaxTokenAvaliable() constant public returns(uint256); function finishMinting() onlyOwner public returns (bool); } contract CABCoinICO is Constants{ using SafeMath for uint256; mapping(address => bool) public preICOHolders ; mapping(address => uint256) public ethGiven ; address public tokenAddress = 0; DevTeamContractI public devTeam; uint256 public _startBlock ; CABCoinI public coin; event AmountToLittle(); event SendAllFunds(); event Buy(address who,uint256 amount); event Refund(address who,uint256 amount); modifier canMint() { if(coin.mintingFinished()==false){ _; } else{ } } bool private isRunned = false; modifier runOnce() { if(isRunned){ revert(); } else{ isRunned = true; _; } } uint256 public currBlock = 1; function GetTime() public constant returns(uint256) { return block.number; } function getAllTimes() public constant returns(uint256,uint256,uint256){ if(GetTime()<_startBlock){ return(_startBlock.sub(GetTime()),0,0); } if(GetTime()<=_startBlock.add(delayOfICOEND)) { uint256 currentStageTime = 0; if(GetTime()<_startBlock.add(delayOfPreICO)){ currentStageTime = _startBlock.add(delayOfPreICO) - GetTime(); } else{ if(GetTime()<_startBlock.add(delayOfICO1)){ currentStageTime = _startBlock.add(delayOfICO1) - GetTime(); } else{ if(GetTime()<_startBlock.add(delayOfICO2)){ currentStageTime = _startBlock.add(delayOfICO2) - GetTime(); } } } if(GetTime()>=_startBlock){ return(0,currentStageTime,_startBlock.add(delayOfICOEND)-GetTime()); } } else{ return(0,0,0); } } function CABCoinICO(uint256 sBlock) public { if(sBlock==0){ _startBlock = GetTime(); } else{ _startBlock = sBlock; } } function SetContracts(address coinAdr, address dev) runOnce() public{ if(tokenAddress == address(0)){ tokenAddress = coinAdr; coin = CABCoinI(coinAdr); devTeam = DevTeamContractI(dev); } } function getMaxEther() constant public returns(uint256) { uint256 maxAv = coin.getMaxTokenAvaliable(); uint256 price = getCabCoinsAmount(); var maxEth = maxAv.div(price); return maxEth; } function isAfterICO() public constant returns(bool) { return (getCabCoinsAmount() == 0); } function getCabCoinsAmount() public constant returns(uint256) { if(GetTime()<_startBlock){ return 0; } if(GetTime()<_startBlock.add(delayOfPreICO)){ if(maxTokenSupplyPreICO>coin.totalSupply()){ return PRICE_PREICO; } } if(GetTime()<_startBlock.add(delayOfICO1) ){ if(maxTokenSupplyICO1>coin.totalSupply()){ return PRICE_ICO1; } } if(GetTime()<_startBlock.add(delayOfICO2)){ if(maxTokenSupplyICO2>coin.totalSupply()){ return PRICE_ICO2; } } if(GetTime()<=_startBlock.add(delayOfICOEND)){ if(maxTokenSupplyICOEND>=coin.totalSupply()){ return PRICE_ICO4; } } return 0; } function() payable public{ if(isAfterICO() && coin.totalSupply()<minimumGoal){ this.refund.value(msg.value)(msg.sender); }else{ if(msg.value==0){ sendAllFunds(); }else{ if(isAfterICO() == false){ this.buy.value(msg.value)(msg.sender); }else{ revert(); } } } } function buy(address owner) payable public{ bool isMintedDev ; bool isMinted ; Buy(owner,msg.value); uint256 tokensAmountPerEth = getCabCoinsAmount(); if(GetTime()<_startBlock){ revert(); } else{ if(tokensAmountPerEth==0){ coin.finishMinting(); msg.sender.transfer(msg.value); } else{ uint256 tokensAvailable = coin.getMaxTokenAvaliable() ; uint256 val = tokensAmountPerEth.mul(msg.value) ; uint256 valForTeam = val.mul(TEAM_SHARE_PERCENTAGE).div(100-TEAM_SHARE_PERCENTAGE); if(tokensAvailable<val+valForTeam){ AmountToLittle(); val = val.mul(tokensAvailable).div(val.add(valForTeam)); valForTeam = val.mul(TEAM_SHARE_PERCENTAGE).div(100-TEAM_SHARE_PERCENTAGE); isMintedDev =coin.mint(owner,val); isMinted = coin.mint(devTeam,valForTeam); ethGiven[owner] = ethGiven[owner].add(msg.value); if(isMintedDev==false){ revert(); } if(isMinted==false){ revert(); } coin.finishMinting(); } else { if(IsPreICO()){ preICOHolders[owner] = true; devTeam.recieveFunds.value(msg.value.mul(PRE_ICO_RISK_PERCENTAGE).div(100))(); } isMintedDev =coin.mint(owner,val); isMinted = coin.mint(devTeam,valForTeam); ethGiven[owner] = ethGiven[owner].add(msg.value); if(isMintedDev==false){ revert(); } if(isMinted==false){ revert(); } } } } } function IsPreICO() returns(bool){ if(GetTime()<_startBlock.add(delayOfPreICO)){ return true; } else{ return false; } } function sendAllFunds() public { SendAllFunds(); if(coin.totalSupply()>=minimumGoal){ devTeam.recieveFunds.value(this.balance)(); } else { revert(); } } function refund(address sender) payable public { Refund(sender,ethGiven[sender]); if(isAfterICO() && coin.totalSupply()<minimumGoal){ var sumToReturn = ethGiven[sender]; ethGiven[sender] =0; if(preICOHolders[msg.sender]){ sumToReturn = sumToReturn.mul(100-PRE_ICO_RISK_PERCENTAGE).div(100); } sumToReturn = sumToReturn.add(msg.value); if(sumToReturn>this.balance){ sender.transfer(this.balance); } else{ sender.transfer(sumToReturn.add(msg.value)); } } else { if(msg.value>0){ sender.transfer(msg.value); } } } }
0
pragma solidity ^0.4.16; interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; } contract CCCToken { string public name = 'Crypto Crash Course'; string public symbol = 'CCC'; uint8 public decimals = 18; uint256 public totalSupply = 1000000000000000000000000000; 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 CCCToken() public { balanceOf[msg.sender] = totalSupply; } function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); } 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; } }
1
pragma solidity ^0.4.9; 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 Helex{ string public standard = 'Helex 7.0'; using SafeMath for uint256; mapping(address => mapping(address => uint256)) allowed; mapping(address => uint256) balances; uint256 public totalSupply; uint256 public decimals; address public owner; bytes32 public symbol; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed _owner, address indexed spender, uint256 value); function Helex() { totalSupply = 2100000000000; symbol = 'HLX'; owner = 0x27d5DacEDc4F1C98B56723174eEab8E4EFc9AbA6; balances[owner] = 2100000000000; decimals = 5; } function balanceOf(address _owner) constant returns(uint256 balance) { return balances[_owner]; } function allowance(address _owner, address _spender) constant returns(uint256 remaining) { return allowed[_owner][_spender]; } function transfer(address _to, uint256 _value) returns(bool) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) returns(bool) { 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); 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() { revert(); } }
1
pragma solidity ^0.4.18; 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 Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { 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 QuantstampSale is Pausable { using SafeMath for uint256; address public beneficiary; uint public fundingCap; uint public minContribution; bool public fundingCapReached = false; bool public saleClosed = false; mapping(address => bool) public registry; mapping(address => uint256) public cap1; mapping(address => uint256) public cap2; mapping(address => uint256) public cap3; mapping(address => uint256) public cap4; mapping(address => uint256) public contributed1; mapping(address => uint256) public contributed2; mapping(address => uint256) public contributed3; mapping(address => uint256) public contributed4; uint public rate1 = 10000; uint public rate2 = 7000; uint public rate3 = 6000; uint public rate4 = 5000; uint public startTime; uint public endTime; uint public amountRaised; bool private rentrancy_lock = false; mapping(address => uint256) public balanceOf; mapping(address => uint256) public tokenBalanceOf; event CapReached(address _beneficiary, uint _amountRaised); event FundTransfer(address _backer, uint _amount, bool _isContribution); event RegistrationStatusChanged(address target, bool isRegistered, uint c1, uint c2, uint c3, uint c4); modifier beforeDeadline() { require (currentTime() < endTime); _; } modifier afterStartTime() { require (currentTime() >= startTime); _; } modifier saleNotClosed() { require (!saleClosed); _; } modifier nonReentrant() { require(!rentrancy_lock); rentrancy_lock = true; _; rentrancy_lock = false; } function QuantstampSale( address ifSuccessfulSendTo, uint fundingCapInEthers, uint minimumContributionInWei, uint start, uint durationInMinutes ) { require(ifSuccessfulSendTo != address(0) && ifSuccessfulSendTo != address(this)); require(durationInMinutes > 0); beneficiary = ifSuccessfulSendTo; fundingCap = fundingCapInEthers * 1 ether; minContribution = minimumContributionInWei; startTime = start; endTime = start + (durationInMinutes * 1 minutes); } function () payable { buy(); } function buy () payable public whenNotPaused beforeDeadline afterStartTime saleNotClosed nonReentrant { require(msg.value >= minContribution); uint amount = msg.value; require(registry[msg.sender]); uint numTokens = computeTokenAmount(msg.sender, amount); assert(numTokens > 0); amountRaised = amountRaised.add(amount); require(amountRaised <= fundingCap); balanceOf[msg.sender] = balanceOf[msg.sender].add(amount); tokenBalanceOf[msg.sender] = tokenBalanceOf[msg.sender].add(numTokens); FundTransfer(msg.sender, amount, true); updateFundingCap(); } function computeTokenAmount(address addr, uint amount) internal returns (uint){ require(amount > 0); uint r3 = cap3[addr].sub(contributed3[addr]); uint r2 = cap2[addr].sub(contributed2[addr]); uint r1 = cap1[addr].sub(contributed1[addr]); uint r4 = cap4[addr].sub(contributed4[addr]); uint numTokens = 0; assert(amount <= r3.add(r2).add(r1).add(r4)); if(r3 > 0){ if(amount <= r3){ contributed3[addr] = contributed3[addr].add(amount); return rate3.mul(amount); } else{ numTokens = rate3.mul(r3); amount = amount.sub(r3); contributed3[addr] = cap3[addr]; } } if(r2 > 0){ if(amount <= r2){ contributed2[addr] = contributed2[addr].add(amount); return numTokens.add(rate2.mul(amount)); } else{ numTokens = numTokens.add(rate2.mul(r2)); amount = amount.sub(r2); contributed2[addr] = cap2[addr]; } } if(r1 > 0){ if(amount <= r1){ contributed1[addr] = contributed1[addr].add(amount); return numTokens.add(rate1.mul(amount)); } else{ numTokens = numTokens.add(rate1.mul(r1)); amount = amount.sub(r1); contributed1[addr] = cap1[addr]; } } contributed4[addr] = contributed4[addr].add(amount); return numTokens.add(rate4.mul(amount)); } function hasPreviouslyRegistered(address contributor) internal constant onlyOwner returns (bool) { return (cap1[contributor].add(cap2[contributor]).add(cap3[contributor]).add(cap4[contributor])) > 0; } function validateUpdatedRegistration(address addr, uint c1, uint c2, uint c3, uint c4) internal constant onlyOwner returns(bool) { return (contributed3[addr] <= c3) && (contributed2[addr] <= c2) && (contributed1[addr] <= c1) && (contributed4[addr] <= c4); } function registerUser(address contributor, uint c1, uint c2, uint c3, uint c4) public onlyOwner { require(contributor != address(0)); if(hasPreviouslyRegistered(contributor)){ require(validateUpdatedRegistration(contributor, c1, c2, c3, c4)); } require(c1.add(c2).add(c3).add(c4) >= minContribution); registry[contributor] = true; cap1[contributor] = c1; cap2[contributor] = c2; cap3[contributor] = c3; cap4[contributor] = c4; RegistrationStatusChanged(contributor, true, c1, c2, c3, c4); } function deactivate(address contributor) public onlyOwner { require(registry[contributor]); registry[contributor] = false; RegistrationStatusChanged(contributor, false, cap1[contributor], cap2[contributor], cap3[contributor], cap4[contributor]); } function reactivate(address contributor) public onlyOwner { require(hasPreviouslyRegistered(contributor)); registry[contributor] = true; RegistrationStatusChanged(contributor, true, cap1[contributor], cap2[contributor], cap3[contributor], cap4[contributor]); } function registerUsers(address[] contributors, uint[] caps1, uint[] caps2, uint[] caps3, uint[] caps4) external onlyOwner { require(contributors.length == caps1.length); require(contributors.length == caps2.length); require(contributors.length == caps3.length); require(contributors.length == caps4.length); for (uint i = 0; i < contributors.length; i++) { registerUser(contributors[i], caps1[i], caps2[i], caps3[i], caps4[i]); } } function terminate() external onlyOwner { saleClosed = true; } function ownerAllocateTokensForList(address[] addrs, uint[] weiAmounts, uint[] miniQspAmounts) external onlyOwner { require(addrs.length == weiAmounts.length); require(addrs.length == miniQspAmounts.length); for(uint i = 0; i < addrs.length; i++){ ownerAllocateTokens(addrs[i], weiAmounts[i], miniQspAmounts[i]); } } function ownerAllocateTokens(address _to, uint amountWei, uint amountMiniQsp) onlyOwner nonReentrant { amountRaised = amountRaised.add(amountWei); require(amountRaised <= fundingCap); tokenBalanceOf[_to] = tokenBalanceOf[_to].add(amountMiniQsp); balanceOf[_to] = balanceOf[_to].add(amountWei); FundTransfer(_to, amountWei, true); updateFundingCap(); } function ownerSafeWithdrawal() external onlyOwner nonReentrant { uint balanceToSend = this.balance; beneficiary.transfer(balanceToSend); FundTransfer(beneficiary, balanceToSend, false); } function updateFundingCap() internal { assert (amountRaised <= fundingCap); if (amountRaised == fundingCap) { fundingCapReached = true; saleClosed = true; CapReached(beneficiary, amountRaised); } } function currentTime() constant returns (uint _currentTime) { return now; } } contract ExtendedQuantstampSale is Pausable { using SafeMath for uint256; address public beneficiary; uint public fundingCap; uint public minContribution; bool public fundingCapReached = false; bool public saleClosed = false; mapping(address => bool) public registry; mapping(address => uint256) public cap; uint public startTime; uint public endTime; uint public amountRaised; bool private rentrancy_lock = false; mapping(address => uint256) public balanceOf; QuantstampSale public previousContract; event CapReached(address _beneficiary, uint _amountRaised); event FundTransfer(address _backer, uint _amount, bool _isContribution); event RegistrationStatusChanged(address target, bool isRegistered, uint c); modifier beforeDeadline() { require (currentTime() < endTime); _; } modifier afterStartTime() { require (currentTime() >= startTime); _; } modifier saleNotClosed() { require (!saleClosed); _; } modifier nonReentrant() { require(!rentrancy_lock); rentrancy_lock = true; _; rentrancy_lock = false; } function ExtendedQuantstampSale( address ifSuccessfulSendTo, uint fundingCapInEthers, uint minimumContributionInWei, uint start, uint durationInMinutes, address previousContractAddress ) { require(ifSuccessfulSendTo != address(0) && ifSuccessfulSendTo != address(this)); require(durationInMinutes > 0); beneficiary = ifSuccessfulSendTo; fundingCap = fundingCapInEthers * 1 ether; minContribution = minimumContributionInWei; startTime = start; endTime = start + (durationInMinutes * 1 minutes); previousContract = QuantstampSale(previousContractAddress); } function () payable { buy(); } function buy () payable public whenNotPaused beforeDeadline afterStartTime saleNotClosed nonReentrant { uint amount = msg.value; require(amount >= minContribution); require(registry[msg.sender]); amountRaised = amountRaised.add(amount); require(getTotalAmountRaised() <= fundingCap); balanceOf[msg.sender] = balanceOf[msg.sender].add(amount); require(getUserBalance(msg.sender) <= cap[msg.sender]); FundTransfer(msg.sender, amount, true); updateFundingCap(); } function getTotalAmountRaised() public constant returns (uint) { return amountRaised.add(previousContract.amountRaised()); } function getUserBalance(address user) public constant returns (uint) { return balanceOf[user].add(previousContract.balanceOf(user)); } function setEndTime(uint timestamp) public onlyOwner { endTime = timestamp; } function hasPreviouslyRegistered(address contributor) internal constant returns (bool) { return cap[contributor] > 0; } function validateUpdatedRegistration(address addr, uint _cap) internal constant returns(bool) { return (getUserBalance(addr) <= _cap); } function registerUser(address contributor, uint _cap) public onlyOwner { require(contributor != address(0)); if(hasPreviouslyRegistered(contributor)){ require(validateUpdatedRegistration(contributor, _cap)); } require(_cap >= minContribution); registry[contributor] = true; cap[contributor] = _cap; RegistrationStatusChanged(contributor, true, _cap); } function deactivate(address contributor) public onlyOwner { require(registry[contributor]); registry[contributor] = false; RegistrationStatusChanged(contributor, false, cap[contributor]); } function reactivate(address contributor) public onlyOwner { require(hasPreviouslyRegistered(contributor)); registry[contributor] = true; RegistrationStatusChanged(contributor, true, cap[contributor]); } function registerUsers(address[] contributors, uint[] caps) external onlyOwner { require(contributors.length == caps.length); for (uint i = 0; i < contributors.length; i++) { registerUser(contributors[i], caps[i]); } } function terminate() external onlyOwner { saleClosed = true; } function ownerAllocate(address _to, uint amountWei) public onlyOwner nonReentrant { amountRaised = amountRaised.add(amountWei); require(getTotalAmountRaised() <= fundingCap); balanceOf[_to] = balanceOf[_to].add(amountWei); FundTransfer(_to, amountWei, true); updateFundingCap(); } function ownerSafeWithdrawal() external onlyOwner nonReentrant { uint balanceToSend = this.balance; beneficiary.transfer(balanceToSend); FundTransfer(beneficiary, balanceToSend, false); } function updateFundingCap() internal { uint amount = getTotalAmountRaised(); assert (amount <= fundingCap); if (amount == fundingCap) { fundingCapReached = true; saleClosed = true; CapReached(beneficiary, amount); } } function currentTime() public constant returns (uint _currentTime) { return now; } }
0