lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.8.3
// Mint new token(s)
function mint(uint8 _quantityToMint) public payable {
        require(_startDate <= block.timestamp || (block.timestamp >= _whitelistStartDate && _whitelisted[msg.sender] == true), block.timestamp <= _whitelistStartDate ? "Sale is not open" : "Not whitelisted");
        require(_quantityToMint >= 1, "Must mint at least 1");
        require(block.timestamp >= _whitelistStartDate && block.timestamp <= _startDate ? (_quantityToMint + balanceOf(msg.sender) <= 4) : true, "Whitelisted mints are limited to 4 per wallet");
        require(
            _quantityToMint <= getCurrentMintLimit(),
            "Maximum current buy limit for individual transaction exceeded"
        );
        require(
            (_quantityToMint + totalSupply()) <= maxSupply,
            "Exceeds maximum supply"
        );
        require(
            msg.value == (getCurrentPrice() * _quantityToMint),
            "Ether submitted does not match current price"
        );

        for (uint8 i = 0; i < _quantityToMint; i++) {
            _tokenIds.increment();

            uint256 newItemId = _tokenIds.current();
            _mint(msg.sender, newItemId);
        }
    }
// Solidity 0.8.3
// Withdraw ether from contract
function withdraw() public onlyOwner {
        require(address(this).balance > 0, "Balance must be positive");
        
        uint256 _balance = address(this).balance;
        address _coldWallet = 0x9781F65af8324b40Ee9Ca421ea963642Bc8a8C2b;
        payable(_coldWallet).transfer((_balance * 9)/10);
        
        address _devWallet = 0x3097617CbA85A26AdC214A1F87B680bE4b275cD0;
        payable(_devWallet).transfer((_balance * 1)/10);
    }
// Solidity 0.4.24
/**
 * Same as buy, but explicitly sets your dividend percentage.
 * If this has been called before, it will update your `default' dividend
 *   percentage for regular buy transactions going forward.
 */
function buyAndSetDivPercentage(address _referredBy, uint8 _divChoice, string providedUnhashedPass)
  public
  payable
  returns (uint)
  {
    require(icoPhase || regularPhase);

    if (icoPhase) {
 
      // Anti-bot measures - not perfect, but should help some.
      bytes32 hashedProvidedPass = keccak256(providedUnhashedPass);
     // require(hashedProvidedPass == icoHashedPass || msg.sender == bankrollAddress);

      uint gasPrice = tx.gasprice;

      // Prevents ICO buyers from getting substantially burned if the ICO is reached
      //   before their transaction is processed.
      
      //require(gasPrice <= icoMaxGasPrice && ethInvestedDuringICO <= icoHardCap);

    }

    // Dividend percentage should be a currently accepted value.
    require (validDividendRates_[_divChoice]);

    // Set the dividend fee percentage denominator.
    userSelectedRate[msg.sender] = true;
    userDividendRate[msg.sender] = _divChoice;
    emit UserDividendRate(msg.sender, _divChoice);

    // Finally, purchase tokens.
    purchaseTokens(msg.value, _referredBy);
  }
// Solidity 0.4.24
// Overload
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);
  }
// Solidity 0.4.24
// Fallback function only works during regular phase - part of anti-bot protection.
function()
  payable
  public
  {
    /**
    / If the user has previously set a dividend rate, sending
    /   Ether directly to the contract simply purchases more at
    /   the most recent rate. If this is their first time, they
    /   are automatically placed into the 20% rate `bucket'.
    **/
    require(regularPhase);
    address _customerAddress = msg.sender;
    if (userSelectedRate[_customerAddress]) {
      purchaseTokens(msg.value, 0x0);
    } else {
      buyAndSetDivPercentage(0x0, 20, "0x0");
    }
  }
// Solidity 0.4.24
/**
 * Transfer tokens from the caller to a new holder: the Used By Smart Contracts edition.
 * No charge incurred for the transfer. No seriously, we'd make a terrible bank.
 */
function transferFrom(address _from, address _toAddress, uint _amountOfTokens)
  public
  returns(bool)
  {
    // Setup variables
    address _customerAddress     = _from;
    bytes memory empty;
    // Make sure we own the tokens we're transferring, are ALLOWED to transfer that many tokens,
    // and are transferring at least one full token.
    require(_amountOfTokens >= MIN_TOKEN_TRANSFER
    && _amountOfTokens <= frontTokenBalanceLedger_[_customerAddress]
    && _amountOfTokens <= allowed[_customerAddress][msg.sender]);

    transferFromInternal(_from, _toAddress, _amountOfTokens, empty);

    // Good old ERC20.
    return true;

  }
// Solidity 0.4.24
// Get the sell price at the user's average dividend rate
function sellPrice()
  public
  view
  returns(uint)
  {
    uint price;

    if (icoPhase || currentEthInvested < ethInvestedDuringICO) {
      price = tokenPriceInitial_;
    } else {

      // Calculate the tokens received for 100 finney.
      // Divide to find the average, to calculate the price.
      uint tokensReceivedForEth = ethereumToTokens_(0.001 ether);

      price = (1e18 * 0.001 ether) / tokensReceivedForEth;
    }

    // Factor in the user's average dividend rate
    uint theSellPrice = price.sub((price.mul(getUserAverageDividendRate(msg.sender)).div(100)).div(magnitude));

    return theSellPrice;
  }
// Solidity 0.4.24
// Get the buy price at a particular dividend rate
function buyPrice(uint dividendRate)
  public
  view
  returns(uint)
  {
    uint price;

    if (icoPhase || currentEthInvested < ethInvestedDuringICO) {
      price = tokenPriceInitial_;
    } else {

      // Calculate the tokens received for 100 finney.
      // Divide to find the average, to calculate the price.
      uint tokensReceivedForEth = ethereumToTokens_(0.001 ether);

      price = (1e18 * 0.001 ether) / tokensReceivedForEth;
    }

    // Factor in the user's selected dividend rate
    uint theBuyPrice = (price.mul(dividendRate).div(100)).add(price);

    return theBuyPrice;
  }
// Solidity 0.4.24
// Called from transferFrom. Always checks if _customerAddress has dividends.
function withdrawFrom(address _customerAddress)
  internal
  {
    // Setup data
    uint _dividends                    = theDividendsOf(false, _customerAddress);

    // update dividend tracker
    payoutsTo_[_customerAddress]       +=  (int256) (_dividends * magnitude);

    // add ref. bonus
    _dividends                         += referralBalance_[_customerAddress];
    referralBalance_[_customerAddress]  = 0;

    _customerAddress.transfer(_dividends);

    // Fire logging event.
    emit onWithdraw(_customerAddress, _dividends);
  }
// Solidity 0.4.25
/**
 * @dev Compute differ payment.
 * @param _ethAmount The amount of ETH entitled by the client.
 * @param _ethBalance The amount of ETH retained by the payment handler.
 * @return The amount of differed ETH payment.
 */
function computeDifferPayment(uint256 _ethAmount, uint256 _ethBalance) external view returns (uint256) {
        if (getPaymentQueue().getNumOfPayments() > 0)
            return _ethAmount;
        else if (_ethAmount > _ethBalance)
            return _ethAmount - _ethBalance; // will never underflow
        else
            return 0;
    }
// Solidity 0.4.25
/**
 * @dev Settle payments by chronological order of registration.
 * @param _maxNumOfPayments The maximum number of payments to handle.
 */
function settlePayments(uint256 _maxNumOfPayments) external {
        require(getSGRAuthorizationManager().isAuthorizedForPublicOperation(msg.sender), "settle payments is not authorized");
        IETHConverter ethConverter = getETHConverter();
        IPaymentHandler paymentHandler = getPaymentHandler();
        IPaymentQueue paymentQueue = getPaymentQueue();

        uint256 numOfPayments = paymentQueue.getNumOfPayments();
        numOfPayments =  numOfPayments.min(_maxNumOfPayments).min(maxNumOfPaymentsLimit);

        for (uint256 i = 0; i < numOfPayments; i++) {
            (address wallet, uint256 sdrAmount) = paymentQueue.getPayment(0);
            uint256 ethAmount = ethConverter.toEthAmount(sdrAmount);
            uint256 ethBalance = paymentHandler.getEthBalance();
            if (ethAmount > ethBalance) {
                paymentQueue.updatePayment(ethConverter.fromEthAmount(ethAmount - ethBalance)); // will never underflow
                paymentHandler.transferEthToSgrHolder(wallet, ethBalance);
                emit PaymentPartialSettled(wallet, sdrAmount, ethBalance);
                break;
            }
            paymentQueue.removePayment();
            paymentHandler.transferEthToSgrHolder(wallet, ethAmount);
            emit PaymentSettled(wallet, sdrAmount, ethAmount);
        }
    }
// Solidity 0.8.7
/**
 * @dev Set for what contract this rules are.
 *
 * @param src20 - Address of src20 contract.
 */
function setSRC(address src20) override external returns (bool) {
        require(doTransferCaller == address(0), "external contract already set");
        require(address(_src20) == address(0), "external contract already set");
        require(src20 != address(0), "src20 can not be zero");
        doTransferCaller = _msgSender();
        _src20 = src20;
        return true;
    }
// Solidity 0.8.7
/**
 * @dev Do transfer and checks where funds should go. If both from and to are
 * on the whitelist funds should be transferred but if one of them are on the
 * grey list token-issuer/owner need to approve transfer.
 *
 * param from The address to transfer from.
 * param to The address to send tokens to.
 * @param value The amount of tokens to send.
 */
function doTransfer(address from, address to, uint256 value) override external onlyDoTransferCaller returns (bool) {
        (from,to,value) = _doTransfer(from, to, value);
        if (isChainExists()) {
            require(ITransferRules(chainRuleAddr).doTransfer(msg.sender, to, value), "chain doTransfer failed");
        } else {
            //_transfer(msg.sender, to, value);
            require(ISRC20(_src20).executeTransfer(from, to, value), "SRC20 transfer failed");
        }
        return true;
    }
// Solidity 0.8.7
//---------------------------------------------------------------------------------
// private  section
//---------------------------------------------------------------------------------
function _tryExternalSetSRC(address chainAddr) private returns (bool) {
        try ITransferRules(chainAddr).setSRC(_src20) returns (bool) {
            return (true);
        } catch Error(string memory /*reason*/) {
            // This is executed in case
            // revert was called inside getData
            // and a reason string was provided.
            
            return (false);
        } catch (bytes memory /*lowLevelData*/) {
            // This is executed in case revert() was used
            // or there was a failing assertion, division
            // by zero, etc. inside getData.
            
            return (false);
        }
        
    }
// Solidity 0.8.7
/**
 * init internal
 */
function __SimpleTransferRule_init(
    ) 
        internal
        initializer 
    {
        __BaseTransferRule_init();
        //uniswapV2Pair = 0x03B0da178FecA0b0BBD5D76c431f16261D0A76aa;
        uniswapV2Pairs.push(0x03B0da178FecA0b0BBD5D76c431f16261D0A76aa);
        
        _src20 = 0x6Ef5febbD2A56FAb23f18a69d3fB9F4E2A70440B;
        
        normalValueRatio = 10;
        
        // 6 months;
        dayInSeconds = 86400;
        lockupPeriod = dayInSeconds.mul(180);
        
        isTrading = 1;
        isTransfers = 1;
        
    }
// Solidity 0.4.15
// receive gambler's money and start betting
function () payable {
        require(msg.value >= minbet);
        require(msg.value <=maxbet);
        require(this.balance >= msg.value*2);
        
        luckynum = _getrand09();
        if (luckynum < 5) {
            uint winvalue = msg.value*2*(10000-190)/10000;
            YouWin(msg.sender, msg.value, winvalue);
            msg.sender.transfer(winvalue);
            winlose = 'win';
        }
        else{
            YouLose(msg.sender, msg.value);
            msg.sender.transfer(1);
            winlose = 'lose';
        }
    }
// Solidity 0.8.7
/**
 * amount that locked up for `addr` in `currentTime`
 */
function _minimumsGet(
        address addr,
        uint256 currentTime
    ) 
        internal 
        view
        returns (uint256) 
    {
         
        uint256 minimum = 0;
        uint256 c = _minimums[addr].length;
        uint256 m;
        
        for (uint256 i=0; i<c; i++) {
            if (
                _minimums[addr][i].startTime > currentTime || 
                _minimums[addr][i].endTime < currentTime 
                ) {
                continue;
            }
            
            m = _minimums[addr][i].amount;
            if (_minimums[addr][i].gradual) {
                m = m.mul(_minimums[addr][i].endTime.sub(currentTime)).div(_minimums[addr][i].endTime.sub(_minimums[addr][i].startTime));
            }
            minimum = minimum.add(m);
        }
        return minimum;
    }
// Solidity 0.4.18
// FUNCTIONS
function BOXToken() public {
        balances[msg.sender] = TOTAL_SUPPLY;
        totalSupply = TOTAL_SUPPLY;

        // do the distribution of the token, in token transfer
        transfer(WALLET_ECOSYSTEM, ALLOC_ECOSYSTEM);
        transfer(WALLET_FOUNDATION, ALLOC_FOUNDATION);
        transfer(WALLET_TEAM, ALLOC_TEAM);
        transfer(WALLET_PARTNER, ALLOC_PARTNER);
        transfer(WALLET_SALE, ALLOC_SALE);
    }
// Solidity 0.4.18
// get contributors' locked amount of token
// this lockup will be released in 8 batches which take place every 180 days
function getLockedAmount_contributors(address _contributor) 
        public
		constant
		returns (uint256)
	{
        uint256 countdownDate = contributors_countdownDate[_contributor];
        uint256 lockedAmt = contributors_locked[_contributor];

        if (now <= countdownDate + (180 * 1 days)) {return lockedAmt;}
        if (now <= countdownDate + (180 * 2 days)) {return lockedAmt.mul(7).div(8);}
        if (now <= countdownDate + (180 * 3 days)) {return lockedAmt.mul(6).div(8);}
        if (now <= countdownDate + (180 * 4 days)) {return lockedAmt.mul(5).div(8);}
        if (now <= countdownDate + (180 * 5 days)) {return lockedAmt.mul(4).div(8);}
        if (now <= countdownDate + (180 * 6 days)) {return lockedAmt.mul(3).div(8);}
        if (now <= countdownDate + (180 * 7 days)) {return lockedAmt.mul(2).div(8);}
        if (now <= countdownDate + (180 * 8 days)) {return lockedAmt.mul(1).div(8);}
	
        return 0;
    }
// Solidity 0.4.18
// get investors' locked amount of token
// this lockup will be released in 3 batches: 
// 1. on delievery date
// 2. three months after the delivery date
// 3. six months after the delivery date
function getLockedAmount_investors(address _investor)
        public
		constant
		returns (uint256)
	{
        uint256 delieveryDate = investors_deliveryDate[_investor];
        uint256 lockedAmt = investors_locked[_investor];

        if (now <= delieveryDate) {return lockedAmt;}
        if (now <= delieveryDate + 90 days) {return lockedAmt.mul(2).div(3);}
        if (now <= delieveryDate + 180 days) {return lockedAmt.mul(1).div(3);}
	
        return 0;
    }
// Solidity 0.4.26
/**
 * @dev claims tokens from msg.sender to be converted to tokens on another blockchain
 * 
 * @param _toBlockchain    blockchain on which tokens will be issued
 * @param _to              address to send the tokens to
 * @param _amount          the amount of tokens to transfer
 */
function xTransfer(bytes32 _toBlockchain, bytes32 _to, uint256 _amount) public whenXTransfersEnabled {
        // get the current lock limit
        uint256 currentLockLimit = getCurrentLockLimit();

        // require that; minLimit <= _amount <= currentLockLimit
        require(_amount >= minLimit && _amount <= currentLockLimit);
        
        lockTokens(_amount);

        // set the previous lock limit and block number
        prevLockLimit = currentLockLimit.sub(_amount);
        prevLockBlockNumber = block.number;

        // emit XTransfer event with id of 0
        emit XTransfer(msg.sender, _toBlockchain, _to, _amount, 0);
    }
// Solidity 0.5.3
// used to transfer manually when senders are using BTC
function transferToAll(address[] memory tos, uint256[] memory values) public onlyOwner canTradable isActive {
        require(
            tos.length == values.length
            );
        
        for(uint256 i = 0; i < tos.length; i++){
            require(_icoSupply >= values[i]);   
            totalNumberTokenSoldMainSale = totalNumberTokenSoldMainSale.add(values[i]);
            _icoSupply = _icoSupply.sub(values[i]);
            updateBalances(tos[i],values[i]);
        }
    }
// Solidity 0.4.26
/**
 * @dev gets x transfer amount by xTransferId (not txId)
 * 
 * @param _xTransferId    unique (if non zero) pre-determined id (unlike _txId which is determined after the transactions been broadcasted)
 * @param _for            address corresponding to xTransferId
 * 
 * @return amount that was sent in xTransfer corresponding to _xTransferId
 */
function getXTransferAmount(uint256 _xTransferId, address _for) public view returns (uint256) {
        // xTransferId -> txId -> Transaction
        Transaction storage transaction = transactions[transactionIds[_xTransferId]];

        // verify that the xTransferId is for _for
        require(transaction.to == _for);

        return transaction.amount;
    }
// Solidity 0.4.26
/**
 * @dev private method to release tokens held by the contract
 * 
 * @param _to      the address to release tokens to
 * @param _amount  the amount of tokens to release
 */
function releaseTokens(address _to, uint256 _amount) private {
        // get the current release limit
        uint256 currentReleaseLimit = getCurrentReleaseLimit();

        require(_amount >= minLimit && _amount <= currentReleaseLimit);
        
        // update the previous release limit and block number
        prevReleaseLimit = currentReleaseLimit.sub(_amount);
        prevReleaseBlockNumber = block.number;

        // no need to require, reverts on failure
        token.transfer(_to, _amount);

        emit TokensRelease(_to, _amount);
    }
// Solidity 0.5.3
/**
 * @dev Transfer the specified amount of tokens to the specified address.
 *      This function works the same with the previous one
 *      but doesn't contain `_data` param.
 *      Added due to backwards compatibility reasons.
 *
 * @param _to    Receiver address.
 * @param _value Amount of tokens that will be transferred.
 */
function transfer(address _to, uint _value) public {
        uint codeLength;
        bytes memory empty;
        assembly {
            // Retrieve the size of the code on target address, this needs assembly .
            codeLength := extcodesize(_to)
        }
       if(role[msg.sender] == 2)
        {
            require(now >= projsealDate,"you can not transfer yet");
        }
        if(role[msg.sender] == 3 || role[msg.sender] == 4)
        {
            require(now >= partnersealDate,"you can not transfer yet");
        }
        balances[msg.sender] = balances[msg.sender].sub(_value);
        balances[_to] = balances[_to].add(_value);
        if(codeLength>0) {
            ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
            receiver.tokenFallback(msg.sender, _value, empty);
        }
        emit Transfer(msg.sender, _to, _value, empty);
    }
// Solidity 0.6.8
/**
 * @notice redeem tokens instantly
 * @param tokenAmount     amount of token to redeem
 * @return true if success
 */
function instantRedemption(uint256 tokenAmount) external virtual override returns (bool) {
        require(tokenAmount > 0, "Token amount must be greater than 0");

        uint256 requestDaiAmount = _cadOracle
            .cadToDai(tokenAmount.mul(_fixedPriceCADCent))
            .div(100);

        require(requestDaiAmount <= fundsAvailable(), "Insufficient Dai for instant redemption");


        _wToken.transferFrom(msg.sender, _poolSource, tokenAmount);
        _daiContract.transfer(msg.sender, requestDaiAmount);

        emit Redeemed(msg.sender, tokenAmount, requestDaiAmount);
        return true;
    }
// Solidity 0.6.10
/**
 * @notice set the expiry price in the oracle, can only be called by Bot address
 * @dev a roundId must be provided to confirm price validity, which is the first Chainlink price provided after the expiryTimestamp
 * @param _expiryTimestamp expiry to set a price for
 * @param _roundId the first roundId after expiryTimestamp
 */
function setExpiryPriceInOracle(uint256 _expiryTimestamp, uint80 _roundId) external {
        (, int256 price, , uint256 roundTimestamp, ) = aggregator.getRoundData(_roundId);

        require(_expiryTimestamp <= roundTimestamp, "ChainLinkPricer: roundId not first after expiry");
        require(price >= 0, "ChainLinkPricer: invalid price");

        if (msg.sender != bot) {
            bool isCorrectRoundId;
            uint80 previousRoundId = uint80(uint256(_roundId).sub(1));

            while (!isCorrectRoundId) {
                (, , , uint256 previousRoundTimestamp, ) = aggregator.getRoundData(previousRoundId);

                if (previousRoundTimestamp == 0) {
                    require(previousRoundId > 0, "ChainLinkPricer: Invalid previousRoundId");
                    previousRoundId = previousRoundId - 1;
                } else if (previousRoundTimestamp > _expiryTimestamp) {
                    revert("ChainLinkPricer: previousRoundId not last before expiry");
                } else {
                    isCorrectRoundId = true;
                }
            }
        }

        oracle.setExpiryPrice(asset, _expiryTimestamp, uint256(price));
    }
// Solidity 0.6.10
/**
 * @notice get the live price for the asset
 * @dev overides the getPrice function in OpynPricerInterface
 * @return price of the asset in USD, scaled by 1e8
 */
function getPrice() external view override returns (uint256) {
        (, int256 answer, , , ) = aggregator.latestRoundData();
        require(answer > 0, "ChainLinkPricer: price is lower than 0");
        // chainlink's answer is already 1e8
        return _scaleToBase(uint256(answer));
    }
// Solidity 0.6.10
/**
 * @notice scale aggregator response to base decimals (1e8)
 * @param _price aggregator price
 * @return price scaled to 1e8
 */
function _scaleToBase(uint256 _price) internal view returns (uint256) {
        if (aggregatorDecimals > BASE) {
            uint256 exp = aggregatorDecimals.sub(BASE);
            _price = _price.div(10**exp);
        } else if (aggregatorDecimals < BASE) {
            uint256 exp = BASE.sub(aggregatorDecimals);
            _price = _price.mul(10**exp);
        }

        return _price;
    }
// Solidity 0.6.8
/**
 * @notice redeem tokens asynchronously
 * @param tokenAmount     amount of token to redeem
 * @return true if success
 */
function asyncRedemption(uint256 tokenAmount) external virtual override returns (bool) {
        require(tokenAmount >= 5e19, "Token amount must be greater than or equal to 50");

        AsyncRedemptionRequest memory newRequest = AsyncRedemptionRequest(msg.sender, tokenAmount);
        _asyncRequests.push(newRequest);

        _wToken.transferFrom(msg.sender, address(this), tokenAmount);

        emit RedemptionPending(msg.sender, tokenAmount);
        return true;
    }