lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.6.9
// ============ For Owner ============
function grant(address[] calldata holderList, uint256[] calldata amountList)
        external
        onlyOwner
    {
        require(holderList.length == amountList.length, "batch grant length not match");
        uint256 amount = 0;
        for (uint256 i = 0; i < holderList.length; ++i) {
            // for saving gas, no event for grant
            originBalances[holderList[i]] = originBalances[holderList[i]].add(amountList[i]);
            amount = amount.add(amountList[i]);
        }
        _UNDISTRIBUTED_AMOUNT_ = _UNDISTRIBUTED_AMOUNT_.sub(amount);
    }
// Solidity 0.8.7
// get a linked keycard from tokenId
function getAssetLink1(uint256 tokenId) private pure returns (uint256) {
    if (tokenId > 1) {
      uint256 rand = random("link1", tokenId);
      if (rand % 99 < 70)
        return rand % (tokenId - 1) + 1;
      else
        return 0;
    } else {
      return 0;
    }
  }
// Solidity 0.8.2
// (^_^) Business Logic (^_^) 
function claimReserved(uint _amount) external onlyAdmin {

        require(_amount > 0, "Error: Need to have reserved supply.");
        require(accounts[msg.sender].isAdmin == true,"Error: Only an admin can claim.");
        require(accounts[msg.sender].nftsReserved >= _amount, "Error: You are trying to claim more NFTs than you have reserved.");
        require(totalSupply() + _amount <= MAXSUPPLY, "Error: You would exceed the max supply limit.");

        accounts[msg.sender].nftsReserved -= _amount;
        _reserved = _reserved - _amount;

       for (uint i = 0; i < _amount; i++) {
           id++;
           _safeMint(msg.sender, id);
           emit Mint(msg.sender, totalSupply());
        }

    }
// Solidity 0.5.17
/**
 * @notice Called by the delegator on a delegate to initialize it for duty
 * @param data The encoded bytes data for any initialization
 */
function _becomeImplementation(bytes memory data) public {
        // Shh -- currently unused
        data;

        // Shh -- we don't ever want this hook to be marked pure
        if (false) {
            implementation = address(0);
        }

        require(msg.sender == gov, "only the gov may call _becomeImplementation");
    }
// Solidity 0.5.17
/**
 * @notice Called by the delegator on a delegate to forfeit its responsibility
 */
function _resignImplementation() public {
        // Shh -- we don't ever want this hook to be marked pure
        if (false) {
            implementation = address(0);
        }

        require(msg.sender == gov, "only the gov may call _resignImplementation");
    }
// Solidity 0.7.4
// -- Internal Helper functions -- //
function _getMarketIdFromTokenAddress(address _solo, address token)
        internal
        view
        returns (uint256)
    {
        ISoloMargin solo = ISoloMargin(_solo);

        uint256 numMarkets = solo.getNumMarkets();

        address curToken;
        for (uint256 i = 0; i < numMarkets; i++) {
            curToken = solo.getMarketTokenAddress(i);

            if (curToken == token) {
                return i;
            }
        }

        revert("No marketId found for provided token");
    }
// Solidity 0.4.11
/**
 * @dev Allows the current owner to update multiple rates.
 * @param data an array that alternates sha3 hashes of the symbol and the corresponding rate . 
 */
function updateRates(uint[] data) public onlyOwner {
    if (data.length % 2 > 0)
      throw;
    uint i = 0;
    while (i < data.length / 2) {
      bytes32 symbol = bytes32(data[i * 2]);
      uint rate = data[i * 2 + 1];
      rates[symbol] = rate;
      RateUpdated(now, symbol, rate);
      i++;
    }
  }
// Solidity 0.8.7
// get a 2nd linked keycard from tokenId
function getAssetLink2(uint256 tokenId) private pure returns (uint256) {
    uint256 rand = random("link2", tokenId);
    uint256 link2Id = rand % (tokenId - 1) + 1;
    if (link2Id == getAssetLink1(tokenId)){
      return 0;
    } else {
      if (rand % 99 < 50)
        return link2Id;
      else
        return 0;
    }
  }
// Solidity 0.8.7
// generate metadata for links
function getAssetLinks(uint256 tokenId) private pure returns (string memory) {
    string memory traitTypeJson = ', {"trait_type": "Linked", "value": "';
    if (getAssetLink1(tokenId) < 1)
      return '';
    if (getAssetLink2(tokenId) > 0) {
      return string(abi.encodePacked(traitTypeJson, '2 Rooms"}'));
    } else {
      return string(abi.encodePacked(traitTypeJson, '1 Room"}'));
    }
  }
// Solidity 0.8.7
// get a random gradient color from tokenId
function getBackgrounGradient(uint256 tokenId) private pure returns (string memory) {
    uint256 colorSeed = random("color", tokenId);
    if ( colorSeed % 7 == 3)
      return "black;red;gray;red;purple;black;";
    if ( colorSeed % 7 == 2)
      return "black;green;black;";
    if ( colorSeed % 7 == 1)
      return "black;blue;black;";
    if ( colorSeed % 7 == 4)
      return "black;lightblue;black;";
    if ( colorSeed % 7 == 5)
      return "black;red;purple;blue;black;";
    if ( colorSeed % 7 == 6)
      return "black;blue;purple;blue;black;";
    return "black;gray;red;purple;black;";
  }
// Solidity 0.5.7
/** Set `_owner` to the 0 address.
 * Only do this to deliberately lock in the current permissions.
 *
 * THIS CANNOT BE UNDONE! Call this only if you know what you're doing and why you're doing it!
 */
function renounceOwnership(string calldata declaration) external onlyOwner {
        string memory requiredDeclaration = "I hereby renounce ownership of this contract forever.";
        require(
            keccak256(abi.encodePacked(declaration)) ==
            keccak256(abi.encodePacked(requiredDeclaration)),
            "declaration incorrect");

        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }
// Solidity 0.5.7
/// Mint `value` new attotokens to `account`.
function mint(address account, uint256 value)
        external
        notPaused
        only(minter)
    {
        require(account != address(0), "can't mint to address zero");

        totalSupply = totalSupply.add(value);
        require(totalSupply < maxSupply, "max supply exceeded");
        trustedData.addBalance(account, value);
        emit Transfer(address(0), account, value);
    }
// Solidity 0.5.7
/// @dev Transfer of `value` attotokens from `from` to `to`.
/// Internal; doesn't check permissions.
function _transfer(address from, address to, uint256 value) internal {
        require(to != address(0), "can't transfer to address zero");
        trustedData.subBalance(from, value);
        uint256 fee = 0;

        if (address(trustedTxFee) != address(0)) {
            fee = trustedTxFee.calculateFee(from, to, value);
            require(fee <= value, "transaction fee out of bounds");

            trustedData.addBalance(feeRecipient, fee);
            emit Transfer(from, feeRecipient, fee);
        }

        trustedData.addBalance(to, value.sub(fee));
        emit Transfer(from, to, value.sub(fee));
    }
// Solidity 0.5.7
/// @dev Set `spender`'s allowance on `holder`'s tokens to `value` attotokens.
/// Internal; doesn't check permissions.
function _approve(address holder, address spender, uint256 value) internal {
        require(spender != address(0), "spender cannot be address zero");
        require(holder != address(0), "holder cannot be address zero");

        trustedData.setAllowed(holder, spender, value);
        emit Approval(holder, spender, value);
    }
// Solidity 0.5.7
/// Accept upgrade from previous RSV instance. Can only be called once. 
function acceptUpgrade(address previousImplementation) external onlyOwner {
        require(address(trustedData) == address(0), "can only be run once");
        Reserve previous = Reserve(previousImplementation);
        trustedData = ReserveEternalStorage(previous.getEternalStorageAddress());

        // Copy values from old contract
        totalSupply = previous.totalSupply();
        maxSupply = previous.maxSupply();
        emit MaxSupplyChanged(maxSupply);
        
        // Unpause.
        paused = false;
        emit Unpaused(pauser);

        previous.acceptOwnership();

        // Take control of Eternal Storage.
        previous.changePauser(address(this));
        previous.pause();
        previous.transferEternalStorage(address(this));

        // Burn the bridge behind us.
        previous.changeMinter(address(0));
        previous.changePauser(address(0));
        previous.renounceOwnership("I hereby renounce ownership of this contract forever.");
    }
// Solidity 0.8.4
// Verify the signature for the given payload is valid
function verifySignature(
    address _wallet,
    uint256 _amount,
    uint256 _dropId,
    uint256 _tokenId,
    bytes memory signature
  ) public view returns (bool) {
    bytes32 messageHash = hashPayload(_wallet, _amount, _dropId, _tokenId);
    return messageHash.toEthSignedMessageHash().recover(signature) == signer;
  }
// Solidity 0.8.4
// Payable function to receive funds and emit event to indicate successful purchase
function purchase(
    address _wallet,
    uint256 _amount,
    uint256 _dropId,
    uint256 _tokenId,
    bytes memory signature
  ) public payable {
    require(verifySignature(_wallet, _amount, _dropId, _tokenId, signature));
    require(msg.value == _amount, "Amount received does not match expected transfer amount");
    require(!tokenClaimed[_tokenId], "Token has already been claimed");
    tokenClaimed[_tokenId] = true;
    emit Purchase(_wallet, _amount, _dropId, _tokenId);
  }
// Solidity 0.8.7
// generate metadata for lasers
function haveLaser(uint256 tokenId) private pure returns (string memory) {
    uint256 laserSeed = random("laser", tokenId);
    string memory traitTypeJson = ', {"trait_type": "Laser", "value": "';
    if (laserSeed % 251 == 2)
      return string(abi.encodePacked(traitTypeJson, 'Dual Green Lasers"}'));
    if (laserSeed % 167 == 2)
      return string(abi.encodePacked(traitTypeJson, 'Dual Red Lasers"}'));
    if (laserSeed % 71 == 2)
      return string(abi.encodePacked(traitTypeJson, 'Green Laser"}'));
    if (laserSeed % 31 == 2)
      return string(abi.encodePacked(traitTypeJson, 'Red Laser"}'));
    return '';
  }
// Solidity 0.8.7
// generate basic attributes in metadata
function haveBasicAttributes(uint256 tokenId) private view returns (string memory) {
    string memory traitTypeJson = '{"trait_type": "';
    return string(abi.encodePacked(string(abi.encodePacked(traitTypeJson, 'Room Type", "value": "', getRoomType(tokenId), '"}, ')), string(abi.encodePacked(traitTypeJson, 'Room Theme", "value": "', getRoomTheme(tokenId), '"}')), getAssetLinks(tokenId)));
  }
// Solidity 0.4.24
/**
 * @dev Adds single address to whitelist.
 * @param _beneficiary Address to be added to the whitelist
 */
function addToWhitelist(address _beneficiary,uint256 _stage) external onlyOwner {
      require(_beneficiary != address(0));
      require(_stage>0);  
 if(_stage==1){
     whitelist[_beneficiary].stage=Stage.PROCESS1_FAILED;
     returnInvestoramount(_beneficiary,adminCharge_p1);
     failedWhitelist(_beneficiary);
     investedAmountOf[_beneficiary]=0;
 }else if(_stage==2){
     whitelist[_beneficiary].stage=Stage.PROCESS1_SUCCESS;
 }else if(_stage==3){
     whitelist[_beneficiary].stage=Stage.PROCESS2_FAILED;
     returnInvestoramount(_beneficiary,adminCharge_p2);
     failedWhitelist(_beneficiary);
          investedAmountOf[_beneficiary]=0;
 }else if(_stage==4){
     whitelist[_beneficiary].stage=Stage.PROCESS2_SUCCESS;
 }else if(_stage==5){
     whitelist[_beneficiary].stage=Stage.PROCESS3_FAILED;
     returnInvestoramount(_beneficiary,adminCharge_p3);
     failedWhitelist(_beneficiary);
          investedAmountOf[_beneficiary]=0;
     }else if(_stage==6){
     whitelist[_beneficiary].stage=Stage.PROCESS3_SUCCESS;
     afterWhtelisted( _beneficiary);
 }
 
 }
// Solidity 0.4.16
// minimum fee is 1 unless same day
function calcFees(uint256 start, uint256 end, uint256 startAmount) constant returns (uint256 amount, uint256 fee) {
        if (startAmount == 0) return;
        uint256 numberOfDays = wotDay(end) - wotDay(start);
        if (numberOfDays == 0) {
            amount = startAmount;
            return;
        }
        amount = (rateForDays(numberOfDays) * startAmount) / (1 ether);
        if ((fee == 0) && (amount !=  0)) amount--;
        fee = safeSub(startAmount,amount);
    }
// Solidity 0.4.16
/* send GBT */
function transfer(address _to, uint256 _value) whenNotPaused returns (bool ok) {
	    update(msg.sender);              // Do this to ensure sender has enough funds.
		update(_to); 

        balances[msg.sender].amount = safeSub(balances[msg.sender].amount, _value);
        balances[_to].amount = safeAdd(balances[_to].amount, _value);

		Transfer(msg.sender, _to, _value); //Notify anyone listening that this transfer took place
        return true;
	}
// Solidity 0.4.16
// hgtRates in whole tokens per ETH
// max individual contribution in whole ETH
function setHgtRates(uint256 p0,uint256 p1,uint256 p2,uint256 p3,uint256 p4, uint256 _max ) onlyOwner {
              require (now < startDate) ;
              hgtRates[0]   = p0 * 10**8;
              hgtRates[1]   = p1 * 10**8;
              hgtRates[2]   = p2 * 10**8;
              hgtRates[3]   = p3 * 10**8;
              hgtRates[4]   = p4 * 10**8;
              personalMax = _max * 1 ether;           // max ETH per person
  }
// Solidity 0.6.12
// Enter the Sanctuary. Pay some SDTs. Earn some shares.
function enter(uint256 _amount) public {
        uint256 totalSdt = sdt.balanceOf(address(this));
        uint256 totalShares = totalSupply();
        if (totalShares == 0 || totalSdt == 0) {
            _mint(_msgSender(), _amount);
            emit Stake(_msgSender(), _amount);
        } else {
            uint256 what = _amount.mul(totalShares).div(totalSdt);
            _mint(_msgSender(), what);
            emit Stake(_msgSender(), what);
        }
        sdt.transferFrom(_msgSender(), address(this), _amount);
    }
// Solidity 0.4.24
//BUY minter
function BebTomining(uint256 _value,address _addr)public{
        uint256 usdt=_value*ethExchuangeRate/bebethexchuang;
        uint256 _udst=usdt* 10 ** 18;
        miner storage user=miners[_addr];
        require(usdt>50);
        if(usdt>4900){
           usdt=_value*ethExchuangeRate/bebethexchuang*150/100;
           _udst=usdt* 10 ** 18;
        }else{
            if (usdt > 900){
                    usdt = _value * ethExchuangeRate / bebethexchuang * 130 / 100;
                    _udst=usdt* 10 ** 18;
                }
                else{
                    if (usdt > 450){
                        usdt = _value * ethExchuangeRate / bebethexchuang * 120 / 100;
                         _udst=usdt* 10 ** 18;
                    }
                    else{
                        if (usdt > 270){
                            usdt = _value * ethExchuangeRate / bebethexchuang * 110 / 100;
                             _udst=usdt* 10 ** 18;
                        }
                    }
                }
            }
        bebTokenTransfer.transferFrom(_addr,address(this),_value * 10 ** 18);
        TotalInvestment+=_udst;
        user.mining+=_udst;
        //user._mining+=_udst;
        user.lastDate=now;
        bomus(_addr,_udst,"Purchase success!");
    }
// Solidity 0.4.24
// sellbeb-eth
function sellBeb(uint256 _sellbeb)public {
        uint256 _sellbebt=_sellbeb* 10 ** 18;
         require(_sellbeb>0,"The exchange amount must be greater than 0");
         require(_sellbeb<SellBeb,"More than the daily redemption limit");
         uint256 bebex=_sellbebt/bebethexchuang;
         require(this.balance>bebex,"Insufficient contract balance");
         bebTokenTransfer.transferFrom(msg.sender,address(this),_sellbebt);
         msg.sender.transfer(bebex);
    }
// Solidity 0.5.12
/**
 @notice This function is used for zapping out of balancer pools
 @param _ToTokenContractAddress The token in which we want zapout (for ethers, its zero address)
 @param _FromBalancerPoolAddress The address of balancer pool to zap out
 @param _IncomingBPT The quantity of balancer pool tokens
 @return success or failure
 */
function EasyZapOut(
        address _ToTokenContractAddress,
        address _FromBalancerPoolAddress,
        uint256 _IncomingBPT
    ) public payable nonReentrant stopInEmergency returns (uint256) {
        require(
            BalancerFactory.isBPool(_FromBalancerPoolAddress),
            "Invalid Balancer Pool"
        );

        address _FromTokenAddress;
        if (
            IBPool_Balancer_Unzap_V1_1(_FromBalancerPoolAddress).isBound(
                _ToTokenContractAddress
            )
        ) {
            _FromTokenAddress = _ToTokenContractAddress;
        } else {
            _FromTokenAddress = _getBestDeal(
                _FromBalancerPoolAddress,
                _IncomingBPT
            );
        }

        return (
            _performZapOut(
                msg.sender,
                _ToTokenContractAddress,
                _FromBalancerPoolAddress,
                _IncomingBPT,
                _FromTokenAddress
            )
        );
    }
// Solidity 0.5.12
/**
 @notice In the case of user wanting to get out in ETH, the '_ToTokenContractAddress' it will be address(0x0)
 @param _toWhomToIssue is the address of user
 @param _ToTokenContractAddress is the address of the token to which you want to convert to
 @param _FromBalancerPoolAddress the address of the Balancer Pool from which you want to ZapOut
 @param _IncomingBPT is the quantity of Balancer Pool tokens that the user wants to ZapOut
 @param _IntermediateToken is the token to which the Balancer Pool should be Zapped Out
 @notice this is only used if the outgoing token is not amongst the Balancer Pool tokens
 @return success or failure
 */
function ZapOut(
        address payable _toWhomToIssue,
        address _ToTokenContractAddress,
        address _FromBalancerPoolAddress,
        uint256 _IncomingBPT,
        address _IntermediateToken
    ) public payable nonReentrant stopInEmergency returns (uint256) {
        return (
            _performZapOut(
                _toWhomToIssue,
                _ToTokenContractAddress,
                _FromBalancerPoolAddress,
                _IncomingBPT,
                _IntermediateToken
            )
        );
    }
// Solidity 0.5.12
/**
 @notice This method is called by ZapOut and EasyZapOut()
 @param _toWhomToIssue is the address of user
 @param _ToTokenContractAddress is the address of the token to which you want to convert to
 @param _FromBalancerPoolAddress the address of the Balancer Pool from which you want to ZapOut
 @param _IncomingBPT is the quantity of Balancer Pool tokens that the user wants to ZapOut
 @param _IntermediateToken is the token to which the Balancer Pool should be Zapped Out
 @notice this is only used if the outgoing token is not amongst the Balancer Pool tokens
 @return success or failure
 */
function _performZapOut(
        address payable _toWhomToIssue,
        address _ToTokenContractAddress,
        address _FromBalancerPoolAddress,
        uint256 _IncomingBPT,
        address _IntermediateToken
    ) internal returns (uint256) {
        //transfer goodwill

        uint256 goodwillPortion = _transferGoodwill(
            _FromBalancerPoolAddress,
            _IncomingBPT,
            _toWhomToIssue
        );

        require(
            IERC20(_FromBalancerPoolAddress).transferFrom(
                _toWhomToIssue,
                address(this),
                SafeMath.sub(_IncomingBPT, goodwillPortion)
            )
        );

        if (
            IBPool_Balancer_Unzap_V1_1(_FromBalancerPoolAddress).isBound(
                _ToTokenContractAddress
            )
        ) {
            return (
                _directZapout(
                    _FromBalancerPoolAddress,
                    _ToTokenContractAddress,
                    _toWhomToIssue,
                    SafeMath.sub(_IncomingBPT, goodwillPortion)
                )
            );
        }

        //exit balancer
        uint256 _returnedTokens = _exitBalancer(
            _FromBalancerPoolAddress,
            _IntermediateToken,
            SafeMath.sub(_IncomingBPT, goodwillPortion)
        );

        if (_ToTokenContractAddress == address(0)) {
            uint256 ethBought = _token2Eth(
                _IntermediateToken,
                _returnedTokens,
                _toWhomToIssue
            );
            emit Zapout(
                _toWhomToIssue,
                _FromBalancerPoolAddress,
                _ToTokenContractAddress,
                ethBought
            );
            return ethBought;
        } else {
            uint256 tokenBought = _token2Token(
                _IntermediateToken,
                _toWhomToIssue,
                _ToTokenContractAddress,
                _returnedTokens
            );
            emit Zapout(
                _toWhomToIssue,
                _FromBalancerPoolAddress,
                _ToTokenContractAddress,
                tokenBought
            );
            return tokenBought;
        }
    }
// Solidity 0.5.12
/**
 @notice This function is used to calculate and transfer goodwill
 @param _tokenContractAddress Token address in which goodwill is deducted
 @param tokens2Trade The total amount of tokens to be zapped out
 @param _toWhomToIssue The address of user
 @return The amount of goodwill deducted
 */
function _transferGoodwill(
        address _tokenContractAddress,
        uint256 tokens2Trade,
        address _toWhomToIssue
    ) internal returns (uint256 goodwillPortion) {
        goodwillPortion = SafeMath.div(
            SafeMath.mul(tokens2Trade, goodwill),
            10000
        );

        if (goodwillPortion == 0) {
            return 0;
        }

        require(
            IERC20(_tokenContractAddress).transferFrom(
                _toWhomToIssue,
                dzgoodwillAddress,
                goodwillPortion
            ),
            "Error in transferring BPT:1"
        );
        return goodwillPortion;
    }
// Solidity 0.5.12
/**
 @notice This function finds best token from the final tokens of balancer pool
 @param _FromBalancerPoolAddress The address of balancer pool to zap out
 @param _IncomingBPT The amount of balancer pool token to covert
 @return The token address having max liquidity
 */
function _getBestDeal(
        address _FromBalancerPoolAddress,
        uint256 _IncomingBPT
    ) internal view returns (address _token) {
        //get token list
        address[] memory tokens = IBPool_Balancer_Unzap_V1_1(
            _FromBalancerPoolAddress
        ).getFinalTokens();

        uint256 maxEth;

        for (uint256 index = 0; index < tokens.length; index++) {
            //get token for given bpt amount
            uint256 tokensForBPT = getBPT2Token(
                _FromBalancerPoolAddress,
                _IncomingBPT,
                tokens[index]
            );

            //get eth value for each token
            Iuniswap_Balancer_Unzap_V1_1 FromUniSwapExchangeContractAddress
            = Iuniswap_Balancer_Unzap_V1_1(
                UniSwapFactoryAddress.getExchange(tokens[index])
            );

            if (address(FromUniSwapExchangeContractAddress) == address(0)) {
                continue;
            }
            uint256 ethReturned = FromUniSwapExchangeContractAddress
                .getTokenToEthInputPrice(tokensForBPT);

            //get max eth value
            if (maxEth < ethReturned) {
                maxEth = ethReturned;
                _token = tokens[index];
            }
        }
    }