lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.24
// ------------------------------------------------------------------------
// Vip Agreement
// ------------------------------------------------------------------------
function createVip(address _vip, uint _durance, uint _frequence, uint _salary) public onlyAdmin returns (uint) {
        Vip memory _Vip = Vip ({
           vip: _vip,
           durance: uint(now) + _durance,
           frequence: _frequence,
           salary: _salary,
           timestamp: now + _frequence
        });
        uint newVipId = vips.push(_Vip) - 1;
        emit VipAgreementSign(newVipId, _vip, _durance, _frequence, _salary);
        
        return newVipId;
    }
// Solidity 0.4.16
/**
 * @dev Transfer tokens from one address to another
 * @param _from address The address which you want to send tokens from
 * @param _to address The address which you want to transfer to
 * @param _value uint256 the amout of tokens to be transfered
 */
function transferFrom(address _from, address _to, uint256 _value) returns (bool) {
    var _allowance = allowed[_from][msg.sender];

    // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
    // require (_value <= _allowance);

    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;
  }
// Solidity 0.4.16
/**
 * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender.
 * @param _spender The address which will spend the funds.
 * @param _value The amount of tokens to be spent.
 */
function approve(address _spender, uint256 _value) returns (bool) {

    // To change the approve amount you first have to reduce the addresses`
    //  allowance to zero by calling `approve(_spender, 0)` if it is not
    //  already 0 to mitigate the race condition described here:
    //  https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
    require((_value == 0) || (allowed[msg.sender][_spender] == 0));

    allowed[msg.sender][_spender] = _value;
    Approval(msg.sender, _spender, _value);
    return true;
  }
// Solidity 0.6.2
/**
 * @dev Burns a NFT.
 * @notice This is an internal function which should be called from user-implemented external
 * burn function. Its purpose is to show and properly initialize data structures when using this
 * implementation. Also, note that this burn implementation allows the minter to re-mint a burned
 * NFT.
 * @param _tokenId ID of the NFT to be burned.
 */
function _burn(
    uint256 _tokenId
  )
    internal
    override
    virtual
  {
    super._burn(_tokenId);
    
    if (bytes(idToUri[_tokenId]).length != 0)
    {
      delete idToUri[_tokenId];
    }
    
    if (bytes(idToPayload[_tokenId]).length != 0)
    {
      delete idToPayload[_tokenId];
    }
    
    uint256 tokenIndex = idToIndex[_tokenId];
    uint256 lastTokenIndex = tokens.length - 1;
    uint256 lastToken = tokens[lastTokenIndex];

    tokens[tokenIndex] = lastToken;

    tokens.pop();
    // This wastes gas if you are burning the last token but saves a little gas if you are not.
    idToIndex[lastToken] = tokenIndex;
    idToIndex[_tokenId] = 0;
  }
// Solidity 0.6.2
/**
 * @dev Removes a NFT from an address.
 * @notice Use and override this function with caution. Wrong usage can have serious consequences.
 * @param _from Address from wich we want to remove the NFT.
 * @param _tokenId Which NFT we want to remove.
 */
function _removeNFToken(
    address _from,
    uint256 _tokenId
  )
    internal
    override
    virtual
  {
    require(idToOwner[_tokenId] == _from, NOT_OWNER);
    delete idToOwner[_tokenId];

    uint256 tokenToRemoveIndex = idToOwnerIndex[_tokenId];
    uint256 lastTokenIndex = ownerToIds[_from].length - 1;

    if (lastTokenIndex != tokenToRemoveIndex)
    {
      uint256 lastToken = ownerToIds[_from][lastTokenIndex];
      ownerToIds[_from][tokenToRemoveIndex] = lastToken;
      idToOwnerIndex[lastToken] = tokenToRemoveIndex;
    }

    ownerToIds[_from].pop();
  }
// Solidity 0.5.10
/**
 * @dev Function to unlock timelocked tokens
 * If block.timestap passed tokens are sent to owner and lock is removed from database
 */
function unlock() external
    {
        require(timeLocks[msg.sender].length > 0, "Unlock: No locks!");
        Locker[] storage l = timeLocks[msg.sender];
        for (uint i = 0; i < l.length; i++)
        {
            // solium-disable-next-line security/no-block-members
            if (l[i].locktime < block.timestamp) {
                uint amount = l[i].amount;
                require(amount <= lockedBalance && amount <= _balances[address(this)], "Unlock: Not enough coins on contract!");
                lockedBalance = lockedBalance.sub(amount);
                _transfer(address(this), msg.sender, amount);
                for (uint j = i; j < l.length - 1; j++)
                {
                    l[j] = l[j + 1];
                }
                l.length--;
                i--;
            }
        }
    }
// Solidity 0.8.9
/**
 * Gas spent here starts off proportional to the maximum mint batch size.
 * It gradually moves to O(1) as tokens get transferred around in the collection over time.
 */
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
        uint256 curr = tokenId;

        unchecked {
            if (curr < _currentIndex) {
                TokenOwnership memory ownership = _ownerships[curr];
                if (!ownership.burned) {
                    if (ownership.addr != address(0)) {
                        return ownership;
                    }
                    // Invariant: 
                    // There will always be an ownership that has an address and is not burned 
                    // before an ownership that does not have an address and is not burned.
                    // Hence, curr will not underflow.
                    while (true) {
                        curr--;
                        ownership = _ownerships[curr];
                        if (ownership.addr != address(0)) {
                            return ownership;
                        }
                    }
                }
            }
        }
        revert OwnerQueryForNonexistentToken();
    }
// Solidity 0.8.9
/**
 * @dev Mints `quantity` tokens and transfers them to `to`.
 *
 * Requirements:
 *
 * - `to` cannot be the zero address.
 * - `quantity` must be greater than 0.
 *
 * Emits a {Transfer} event.
 */
function _mint(
        address to,
        uint256 quantity,
        bytes memory _data,
        bool safe
    ) internal {
        uint256 startTokenId = _currentIndex;
        if (to == address(0)) revert MintToZeroAddress();
        if (quantity == 0) revert MintZeroQuantity();

        _beforeTokenTransfers(address(0), to, startTokenId, quantity);

        // Overflows are incredibly unrealistic.
        // balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1
        // updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1
        unchecked {
            _addressData[to].balance += uint64(quantity);
            _addressData[to].numberMinted += uint64(quantity);

            _ownerships[startTokenId].addr = to;
            _ownerships[startTokenId].startTimestamp = uint64(block.timestamp);

            uint256 updatedIndex = startTokenId;

            for (uint256 i; i < quantity; i++) {
                emit Transfer(address(0), to, updatedIndex);
                if (safe && !_checkOnERC721Received(address(0), to, updatedIndex, _data)) {
                    revert TransferToNonERC721ReceiverImplementer();
                }
                updatedIndex++;
            }

            _currentIndex = updatedIndex;
        }
        _afterTokenTransfers(address(0), to, startTokenId, quantity);
    }
// Solidity 0.4.24
/**
 * @dev Fallback function allowing to perform a delegatecall to the given implementation.
 * This function will return whatever the implementation call returns
 */
function () payable public {
    bytes32 implementationPosition = implementationPosition_;
    address _impl;
    assembly {
      _impl := sload(implementationPosition)
    }

    assembly {
      let ptr := mload(0x40)
      calldatacopy(ptr, 0, calldatasize)
      let result := delegatecall(gas, _impl, ptr, calldatasize, 0, 0)
      let size := returndatasize
      returndatacopy(ptr, 0, size)

      switch result
      case 0 { revert(ptr, size) }
      default { return(ptr, size) }
    }
  }
// Solidity 0.6.12
/**
 * @return Allowed address list.
 */
function accessList() external view returns (address[] memory) {
        address[] memory result = new address[](allowed.length());

        for (uint256 i = 0; i < allowed.length(); i++) {
            result[i] = allowed.at(i);
        }

        return result;
    }
// Solidity 0.4.21
/**
 * @dev transfers IXT 
 * @param from User address
 * @param to Recipient
 * @param action Service the user is paying for 
 */
function transferIXT(address from, address to, string action) public allowedOnly isNotPaused returns (bool) {
    if (isOldVersion) {
      IXTPaymentContract newContract = IXTPaymentContract(nextContract);
      return newContract.transferIXT(from, to, action);
    } else {
      uint price = actionPrices[action];

      if(price != 0 && !tokenContract.transferFrom(from, to, price)){
        return false;
      } else {
        emit IXTPayment(from, to, price, action);     
        return true;
      }
    }
  }
// Solidity 0.7.2
// ------------------------------------------------------------------------
// Token owner can approve for `spender` to transferFrom(...) `tokens`
// from the token owner's account. The `spender` contract function
// `receiveApproval(...)` is then executed
// ------------------------------------------------------------------------
function approveAndCall(
        address spender,
        uint256 tokens,
        bytes memory data
    ) public returns (bool success) {
        allowed[msg.sender][spender] = tokens;
        emit Approval(msg.sender, spender, tokens);
        ApproveAndCallFallBack(spender).receiveApproval(
            msg.sender,
            tokens,
            address(0),
            data
        );
        return true;
    }
// Solidity 0.7.2
// ------------------------------------------------------------------------
// Send tokens to owner for airdrop
// ------------------------------------------------------------------------
function getAirdropTokens() public onlyOwner {
        require(block.timestamp >= startDate && block.timestamp <= endDate);
        require(!airdropTokensWithdrawn);
        uint256 tokens = 5000000000000000000000;
        balances[owner] = safeAdd(balances[owner], tokens);
        _totalSupply = safeAdd(_totalSupply, tokens);
        emit Transfer(address(0), owner, tokens);
        airdropTokensWithdrawn = true;
    }
// Solidity 0.6.2
/**
 * @dev Actually perform the safeTransferFrom.
 * @param _from The current owner of the NFT.
 * @param _to The new owner.
 * @param _tokenId The NFT to transfer.
 * @param _data Additional data with no specified format, sent in call to `_to`.
 */
function _safeTransferFrom(
    address _from,
    address _to,
    uint256 _tokenId,
    bytes memory _data
  )
    private
    canTransfer(_tokenId)
    validNFToken(_tokenId)
  {
    address tokenOwner = idToOwner[_tokenId];
    require(tokenOwner == _from, NOT_OWNER);
    require(_to != address(0), ZERO_ADDRESS);

    _transfer(_to, _tokenId);

    if (_to.isContract())
    {
      bytes4 retval = ERC721TokenReceiver(_to).onERC721Received(msg.sender, _from, _tokenId, _data);
      require(retval == MAGIC_ON_ERC721_RECEIVED, NOT_ABLE_TO_RECEIVE_NFT);
    }
  }
// Solidity 0.5.16
/**
 * Notifies all the pools, safe guarding the notification amount.
 */
function notifyPools(uint256[] memory amounts, address[] memory pools) public onlyGovernance {
    require(amounts.length == pools.length, "Amounts and pools lengths mismatch");
    for (uint i = 0; i < pools.length; i++) {
      require(amounts[i] > 0, "Notify zero");
      NoMintRewardPool pool = NoMintRewardPool(pools[i]);
      IERC20 token = IERC20(pool.rewardToken());
      uint256 limit = token.balanceOf(pools[i]);
      require(amounts[i] <= limit, "Notify limit hit");
      NoMintRewardPool(pools[i]).notifyRewardAmount(amounts[i]);
    }
  }
// Solidity 0.6.12
/**
 * @return Assets list.
 */
function assets() external view returns (Asset[] memory) {
        Asset[] memory result = new Asset[](size());

        for (uint256 i = 0; i < size(); i++) {
            result[i] = portfolio[i];
        }

        return result;
    }
// Solidity 0.6.12
/**
 * @notice Update information of asset.
 * @param id Asset identificator.
 * @param amount Amount of asset.
 * @param price Cost of one asset in base currency.
 * @param updatedAt Timestamp of updated.
 * @param proofData Signed data.
 * @param proofSignature Data signature.
 */
function put(
        string calldata id,
        uint256 amount,
        uint256 price,
        uint256 updatedAt,
        string calldata proofData,
        string calldata proofSignature
    ) external onlyAllowed {
        require(size() < maxSize, "RealAssetDepositaryBalanceView::put: too many assets");

        uint256 valueIndex = portfolioIndex[id];
        if (valueIndex != 0) {
            portfolio[valueIndex.sub(1)] = Asset(id, amount, price, block.number);
        } else {
            portfolio.push(Asset(id, amount, price, block.number));
            portfolioIndex[id] = size();
        }
        emit AssetUpdated(id, updatedAt, Proof(proofData, proofSignature));
    }
// Solidity 0.6.12
/**
 * @notice Remove information of asset.
 * @param id Asset identificator.
 */
function remove(string calldata id) external onlyAllowed {
        uint256 valueIndex = portfolioIndex[id];
        require(valueIndex != 0, "RealAssetDepositaryBalanceView::remove: asset already removed");

        uint256 toDeleteIndex = valueIndex.sub(1);
        uint256 lastIndex = size().sub(1);
        Asset memory lastValue = portfolio[lastIndex];
        portfolio[toDeleteIndex] = lastValue;
        portfolioIndex[lastValue.id] = toDeleteIndex.add(1);
        portfolio.pop();
        delete portfolioIndex[id];

        emit AssetRemoved(id);
    }
// Solidity 0.4.19
/**
 * @dev Transfer the specified amount of tokens to the specified address.
 *      Invokes the `tokenFallback` function if the recipient is a contract.
 *      The token transfer fails if the recipient is a contract
 *      but does not implement the `tokenFallback` function
 *      or the fallback function to receive funds.
 *
 * @param _to    Receiver address.
 * @param _value Amount of tokens that will be transferred.
 * @param _data  Transaction metadata.
 */
function transfer(address _to, uint _value, bytes _data) public returns (bool) {
        uint codeLength;

        assembly {
            codeLength := extcodesize(_to)
        }

        balances[msg.sender] = balances[msg.sender].sub(_value);
        balances[_to] = balances[_to].add(_value);
        if(codeLength>0) {
            ContractReceiver receiver = ContractReceiver(_to);
            receiver.tokenFallback(msg.sender, _value, _data);
        }
		
		Transfer(msg.sender, _to, _value);
        Transfer(msg.sender, _to, _value, _data);
    }
// Solidity 0.8.4
//adopts multiple cats at once
function adoptCats(uint256 _howMany) public payable {
		require(_howMany <= 10, "max 10 cats at once");
		require(itemPrice.mul(_howMany) == msg.value, "insufficient ETH");

		for (uint256 i = 0; i < _howMany; i++) {
			adopt();
		}
	}
// Solidity 0.7.4
/// @dev Adds investors. This function doesn't limit max gas consumption,
/// so adding too many investors can cause it to reach the out-of-gas error.
/// @param _investors The addresses of new investors.
/// @param _tokenAllocations The amounts of the tokens that belong to each investor.
function addInvestors(
        address[] calldata _investors,
        uint256[] calldata _tokenAllocations,
        uint256[] calldata _withdrawnTokens
    ) external onlyOwner {
        require(_investors.length == _tokenAllocations.length, "different arrays sizes");
        for (uint256 i = 0; i < _investors.length; i++) {
            _addInvestor(_investors[i], _tokenAllocations[i], _withdrawnTokens[i]);
        }
        emit InvestorsAdded(_investors, _tokenAllocations, msg.sender);
    }
// Solidity 0.7.4
// 25% at TGE, 75% released daily over 120 Days after 30 Days Cliff
function withdrawTokens() external onlyInvestor() initialized() {
        Investor storage investor = investorsInfo[_msgSender()];

        uint256 tokensAvailable = withdrawableTokens(_msgSender());

        require(tokensAvailable > 0, "no tokens available for withdrawl");

        investor.withdrawnTokens = investor.withdrawnTokens.add(tokensAvailable);
        _blankToken.safeTransfer(_msgSender(), tokensAvailable);

        emit WithdrawnTokens(_msgSender(), tokensAvailable);
    }
// Solidity 0.8.4
//adopting a cat
function adopt() private {
		//you would be pretty unlucky to pay the miners alot of gas
		for (uint256 i = 0; i < 9999; i++) {
			uint256 randID = random(1, 3000, uint256(uint160(address(msg.sender))) + i);
			if (_totalSupply[randID] == 0) {
				_totalSupply[randID] = 1;
				_mint(msg.sender, randID, 1, "0x0000");
				adoptedCats = adoptedCats + 1;
				return;
			}
		}
		revert("you're very unlucky");
	}
// Solidity 0.7.4
/// @dev Removes investor. This function doesn't limit max gas consumption,
/// so having too many investors can cause it to reach the out-of-gas error.
/// @param _investor Investor address.
function removeInvestor(address _investor) external onlyOwner() {
        require(_investor != address(0), "invalid address");
        Investor storage investor = investorsInfo[_investor];
        uint256 allocation = investor.tokensAllotment;
        require(allocation > 0, "the investor doesn't exist");

        _totalAllocatedAmount = _totalAllocatedAmount.sub(allocation);
        investor.exists = false;
        investor.tokensAllotment = 0;

        emit InvestorRemoved(_investor, _msgSender(), allocation);
    }
// Solidity 0.8.4
//the owner can adopt a cat without paying the fee
//this will be used in the case the number of adopted cats > ~2500 and adopting one costs lots of gas
function mint(
		address to,
		uint256 id,
		bytes memory data
	) public onlyOwner {
		require(_totalSupply[id] == 0, "this cat is already owned by someone");
		_totalSupply[id] = 1;
		adoptedCats = adoptedCats + 1;
		_mint(to, id, 1, data);
	}
// Solidity 0.6.12
//this method is responsible for taking all fee, if takeFee is true
function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private {
        if(!takeFee)
            removeAllFee();
        
        if (_isExcluded[sender] && !_isExcluded[recipient]) {
            _transferFromExcluded(sender, recipient, amount);
        } else if (!_isExcluded[sender] && _isExcluded[recipient]) {
            _transferToExcluded(sender, recipient, amount);
        } else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
            _transferStandard(sender, recipient, amount);
        } else if (_isExcluded[sender] && _isExcluded[recipient]) {
            _transferBothExcluded(sender, recipient, amount);
        } else {
            _transferStandard(sender, recipient, amount);
        }
        
        if(!takeFee)
            restoreAllFee();
    }
// Solidity 0.6.12
/// @notice Transfers ownership to `newOwner`. Either directly or claimable by the new pending owner.
/// Can only be invoked by the current `owner`.
/// @param newOwner Address of the new owner.
/// @param direct True if `newOwner` should be set immediately. False if `newOwner` needs to use `claimOwnership`.
/// @param renounce Allows the `newOwner` to be `address(0)` if `direct` and `renounce` is True. Has no effect otherwise.
function transferOwnership(
		address newOwner,
		bool direct,
		bool renounce
	) public onlyOwner {
		if (direct) {
			// Checks
			require(newOwner != address(0) || renounce, "BoringOwnable::transferOwnership: zero address");

			// Effects
			emit OwnershipTransferred(owner, newOwner);
			owner = newOwner;
			pendingOwner = address(0);
		} else {
			// Effects
			pendingOwner = newOwner;
		}
	}
// Solidity 0.6.12
// transferFrom(address,address,uint256)
function returnDataToString(bytes memory data) internal pure returns (string memory) {
		if (data.length >= 64) {
			return abi.decode(data, (string));
		} else if (data.length == 32) {
			uint8 i = 0;
			while (i < 32 && data[i] != 0) {
				i++;
			}
			bytes memory bytesArray = new bytes(i);
			for (i = 0; i < 32 && data[i] != 0; i++) {
				bytesArray[i] = data[i];
			}
			return string(bytesArray);
		} else {
			return "???";
		}
	}
// Solidity 0.6.12
/// @notice Provides a safe ERC20.transfer version for different ERC-20 implementations.
/// Reverts on a failed transfer.
/// @param token The address of the ERC-20 token.
/// @param to Transfer tokens to.
/// @param amount The token amount.
function safeTransfer(
		IERC20 token,
		address to,
		uint256 amount
	) internal {
		(bool success, bytes memory data) = address(token).call(abi.encodeWithSelector(SIG_TRANSFER, to, amount));
		require(success && (data.length == 0 || abi.decode(data, (bool))), "BoringERC20::safeTransfer: transfer failed");
	}
// Solidity 0.5.8
/// @notice Calls transferFrom on the token, reverts if the call fails and
/// returns the value transferred after fees.
function safeTransferFromWithFees(IERC20 token, address from, address to, uint256 value) internal returns (uint256) {
        uint256 balancesBefore = token.balanceOf(to);
        callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
        require(previousReturnValue(), "transferFrom failed");
        uint256 balancesAfter = token.balanceOf(to);
        return Math.min(value, balancesAfter.sub(balancesBefore));
    }
// Solidity 0.6.12
/// @dev Gets the accumulated reward weight of a pool.
///
/// @param _ctx the pool context.
///
/// @return the accumulated reward weight.
function getUpdatedAccumulatedRewardWeight(Data storage _data, Context storage _ctx)
		internal
		view
		returns (FixedPointMath.uq192x64 memory)
	{
		if (_data.totalDeposited == 0) {
			return _data.accumulatedRewardWeight;
		}

		uint256 _elapsedTime = block.number.sub(_data.lastUpdatedBlock);
		if (_elapsedTime == 0) {
			return _data.accumulatedRewardWeight;
		}

		uint256 _rewardRate = _data.getRewardRate(_ctx);
		uint256 _distributeAmount = _rewardRate.mul(_elapsedTime);

		if (_distributeAmount == 0) {
			return _data.accumulatedRewardWeight;
		}

		FixedPointMath.uq192x64 memory _rewardWeight =
			FixedPointMath.fromU256(_distributeAmount).div(_data.totalDeposited);
		return _data.accumulatedRewardWeight.add(_rewardWeight);
	}
// Solidity 0.5.8
/// @notice Checks the return value of the previous function. Returns true
/// if the previous function returned 32 non-zero bytes or returned zero
/// bytes.
function previousReturnValue() private pure returns (bool)
    {
        uint256 returnData = 0;

        assembly { /* solium-disable-line security/no-inline-assembly */
            // Switch on the number of bytes returned by the previous call
            switch returndatasize

            // 0 bytes: ERC20 of type (3), did not throw
            case 0 {
                returnData := 1
            }

            // 32 bytes: ERC20 of types (1) or (2)
            case 32 {
                // Copy the return data into scratch space
                returndatacopy(0, 0, 32)

                // Load  the return data into returnData
                returnData := mload(0)
            }

            // Other return size: return false
            default { }
        }

        return returnData != 0;
    }