lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.8.4
// NOTE: The values should always be in the power of 1000. So if the required percentage if 6%, the value will be 60, etc...
function changeFeesForWhitelistedSell(uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _HuHdistributionFeeOnSell) external onlyOwner {
        require(_liquidityFeeOnSell < 1000, "Fee should be less than 100!");
        require(_marketingFeeOnSell < 1000, "Fee should be less than 100!");
        require(_HuHdistributionFeeOnSell < 1000, "Fee should be less than 100!");
        liquidityFeeOnWhiteListedSell = _liquidityFeeOnSell;
        marketingFeeOnWhiteListedSell = _marketingFeeOnSell;
        HuHdistributionFeeOnWhiteListedSell = _HuHdistributionFeeOnSell;
        emit ChangeFeesForWhitelistedSell(_liquidityFeeOnSell, _marketingFeeOnSell, _HuHdistributionFeeOnSell);
    }
// Solidity 0.6.5
/// @notice Purchase StarterPacks with SAND
/// @param buyer The destination address for the purchased Catalysts and Gems and the address that will pay for the purchase; if not metaTx then buyer must be equal to msg.sender
/// @param message A message containing information about the Catalysts and Gems to be purchased
/// @param signature A signed message specifying tx details
function purchaseWithSand(
        address buyer,
        Message calldata message,
        bytes calldata signature
    ) external {
        require(msg.sender == buyer || _metaTransactionContracts[msg.sender], "INVALID_SENDER");
        require(_sandEnabled, "SAND_IS_NOT_ENABLED");
        require(buyer != address(0), "DESTINATION_ZERO_ADDRESS");
        require(
            isPurchaseValid(buyer, message.catalystIds, message.catalystQuantities, message.gemIds, message.gemQuantities, message.nonce, signature),
            "INVALID_PURCHASE"
        );
        uint256 amountInSand = _calculateTotalPriceInSand(message.catalystIds, message.catalystQuantities);
        _handlePurchaseWithERC20(buyer, _wallet, address(_sand), amountInSand);
        _erc20GroupCatalyst.batchTransferFrom(address(this), buyer, message.catalystIds, message.catalystQuantities);
        _erc20GroupGem.batchTransferFrom(address(this), buyer, message.gemIds, message.gemQuantities);
        emit Purchase(buyer, message, amountInSand, address(_sand), amountInSand);
    }
// Solidity 0.6.5
/// @notice Enables admin to withdraw all remaining tokens
/// @param to The destination address for the purchased Catalysts and Gems
/// @param catalystIds The IDs of the catalysts to be transferred
/// @param gemIds The IDs of the gems to be transferred
function withdrawAll(
        address to,
        uint256[] calldata catalystIds,
        uint256[] calldata gemIds
    ) external {
        require(msg.sender == _admin, "NOT_AUTHORIZED");

        address[] memory catalystAddresses = new address[](catalystIds.length);
        for (uint256 i = 0; i < catalystIds.length; i++) {
            catalystAddresses[i] = address(this);
        }
        address[] memory gemAddresses = new address[](gemIds.length);
        for (uint256 i = 0; i < gemIds.length; i++) {
            gemAddresses[i] = address(this);
        }
        uint256[] memory unsoldCatalystQuantities = _erc20GroupCatalyst.balanceOfBatch(catalystAddresses, catalystIds);
        uint256[] memory unsoldGemQuantities = _erc20GroupGem.balanceOfBatch(gemAddresses, gemIds);

        _erc20GroupCatalyst.batchTransferFrom(address(this), to, catalystIds, unsoldCatalystQuantities);
        _erc20GroupGem.batchTransferFrom(address(this), to, gemIds, unsoldGemQuantities);
    }
// Solidity 0.6.5
/// @dev Function to calculate the total price in SAND of the StarterPacks to be purchased
/// @dev The price of each StarterPack relates to the catalystId
/// @param catalystIds Array of catalystIds to be purchase
/// @param catalystQuantities Array of quantities of those catalystIds to be purchased
/// @return Total price in SAND
function _calculateTotalPriceInSand(uint256[] memory catalystIds, uint256[] memory catalystQuantities) internal returns (uint256) {
        uint256[] memory prices = _priceSelector();
        uint256 totalPrice;
        for (uint256 i = 0; i < catalystIds.length; i++) {
            uint256 id = catalystIds[i];
            uint256 quantity = catalystQuantities[i];
            totalPrice += prices[id].mul(quantity);
        }
        return totalPrice;
    }
// Solidity 0.6.5
/// @dev Function to determine whether to use old or new prices
/// @return Array of prices
function _priceSelector() internal returns (uint256[] memory) {
        uint256[] memory prices;
        // No price change:
        if (_priceChangeTimestamp == 0) {
            prices = _starterPackPrices;
        } else {
            // Price change delay has expired.
            if (now > _priceChangeTimestamp + 1 hours) {
                _priceChangeTimestamp = 0;
                prices = _starterPackPrices;
            } else {
                // Price change has occured:
                prices = _previousStarterPackPrices;
            }
        }
        return prices;
    }
// Solidity 0.4.20
/*
 This function allows users to purchase Video Game Item. 
 The price is automatically multiplied by 2 after each purchase.
 Users can purchase multiple video game Items.
 */
function purchaseVideoGameItem(uint _videoGameItemId) public payable {
        require(msg.value >= videoGameItems[_videoGameItemId].currentPrice);
        require(isPaused == false);

        CryptoVideoGames parentContract = CryptoVideoGames(cryptoVideoGames);
        uint256 currentPrice = videoGameItems[_videoGameItemId].currentPrice;
        uint256 excess = msg.value - currentPrice;
        // Calculate the 10% value
        uint256 devFee = (currentPrice / 10);
        uint256 parentOwnerFee = (currentPrice / 10);

        address parentOwner = parentContract.getVideoGameOwner(videoGameItems[_videoGameItemId].parentVideoGame);
        address newOwner = msg.sender;
        // Calculate the video game owner commission on this sale & transfer the commission to the owner.     
        uint256 commissionOwner = currentPrice - devFee - parentOwnerFee; // => 80%
        videoGameItems[_videoGameItemId].ownerAddress.transfer(commissionOwner);

        // Transfer the 10% commission to the developer
        devFeeAddress.transfer(devFee); // => 10% 
        parentOwner.transfer(parentOwnerFee); // => 10%   
        newOwner.transfer(excess);              

        // Update the video game owner and set the new price
        videoGameItems[_videoGameItemId].ownerAddress = newOwner;
        videoGameItems[_videoGameItemId].currentPrice = mul(videoGameItems[_videoGameItemId].currentPrice, 2);
    }
// Solidity 0.4.20
// This function will return all of the details of the Video Game Item
function getVideoGameItemDetails(uint _videoGameItemId) public view returns (
        string videoGameItemName,
        address ownerAddress,
        uint256 currentPrice,
        uint parentVideoGame
    ) {
        VideoGameItem memory _videoGameItem = videoGameItems[_videoGameItemId];

        videoGameItemName = _videoGameItem.videoGameItemName;
        ownerAddress = _videoGameItem.ownerAddress;
        currentPrice = _videoGameItem.currentPrice;
        parentVideoGame = _videoGameItem.parentVideoGame;
    }
// Solidity 0.4.20
/**
 @dev Multiplies two numbers, throws on overflow. => From the SafeMath library
 */
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;
    }
// Solidity 0.6.12
/// @dev Mints tokens to a recipient.
///
/// This function reverts if the caller does not have the minter role.
///
/// @param _recipient the account to mint tokens to.
/// @param _amount    the amount of tokens to mint.
function mint(address _recipient, uint256 _amount) external onlyWhitelisted {
    require(!blacklist[msg.sender], "NUSD: Formation is blacklisted.");
    uint256 _total = _amount.add(hasMinted[msg.sender]);
    require(_total <= ceiling[msg.sender],"NUSD: Formation's ceiling was breached.");
    require(!paused[msg.sender], "NUSD: user is currently paused.");
    hasMinted[msg.sender] = hasMinted[msg.sender].add(_amount);
    _mint(_recipient, _amount);
  }
// Solidity 0.8.13
// reserve MAX_RESERVE_SUPPLY for promotional purposes
function reserveNFTs(address to, uint256 quantity) external onlyOwner {
        require(quantity > 0, "Quantity cannot be zero");
        uint totalMinted = totalSupply();
        require(totalMinted.add(quantity) <= MAX_RESERVE_SUPPLY, "No more promo NFTs left");
        _safeMint(to, quantity);
        lockMetadata(quantity);
    }
// Solidity 0.4.24
// Transfers the taxes a user owes from their account to the taxCollector and resets lastPaidTaxes to now
function transferTaxes(address user, bool isInAuction) public returns (bool) {

    if (isInAuction) {
      return true;
    }

    uint256 taxesDue = _taxesDue(user);

    // Make sure the user has enough funds to pay the taxesDue
    if (userBalanceAtLastPaid[user] < taxesDue) {
        return false;
    }

    // Transfer taxes due from this contract to the tax collector
    _payoutTaxes(taxesDue);
    // Update the user's lastPaidTaxes
    lastPaidTaxes[user] = now;
    // subtract the taxes paid from the user's balance
    userBalanceAtLastPaid[user] = userBalanceAtLastPaid[user].sub(taxesDue);

    return true;
  }
// Solidity 0.4.24
/**
 * @notice Multiplies two numbers, throws on overflow.
 * @param a Multiplier
 * @param b Multiplicand
 * @return {"result" : "Returns product"}
 */
function mul(uint256 a, uint256 b) internal pure returns (uint256 result) {
    if (a == 0) {
      return 0;
    }
    uint256 c = a * b;
    require(c / a == b, "Error: Unsafe multiplication operation!");
    return c;
  }
// Solidity 0.4.24
/**
 * @notice Integer division of two numbers, truncating the quotient.
 * @param a Dividend
 * @param b Divisor
 * @return {"result" : "Returns quotient"}
 */
function div(uint256 a, uint256 b) internal pure returns (uint256 result) {
    // @dev require(b > 0); // Solidity automatically throws when dividing by 0
    uint256 c = a / b;
    // @dev require(a == b * c + a % b); // There is no case in which this doesn't hold
    return c;
  }
// Solidity 0.4.24
/**
 * @notice Subtracts two numbers, throws on underflow.
 * @param a Subtrahend
 * @param b Minuend
 * @return {"result" : "Returns difference"}
 */
function sub(uint256 a, uint256 b) internal pure returns (uint256 result) {
    // @dev throws on overflow (i.e. if subtrahend is greater than minuend)
    require(b <= a, "Error: Unsafe subtraction operation!");
    return a - b;
  }
// Solidity 0.4.24
/**
 * @notice Set the token name for Token interfaces
 * @dev This method must be set by the token interface's setParams() method
 * @dev | This method has an `internal` view
 * @param self Internal storage proxying TokenIOStorage contract
 * @param tokenName Name of the token contract
 * @return {"success" : "Returns true when successfully called from another contract"}
 */
function setTokenName(Data storage self, string tokenName) internal returns (bool success) {
    bytes32 id = keccak256(abi.encodePacked('token.name', address(this)));
    require(
      self.Storage.setString(id, tokenName),
      "Error: Unable to set storage value. Please ensure contract interface is allowed by the storage contract."
    );
    return true;
  }
// Solidity 0.4.24
/**
 * @notice Set the token symbol for Token interfaces
 * @dev This method must be set by the token interface's setParams() method
 * @dev | This method has an `internal` view
 * @param self Internal storage proxying TokenIOStorage contract
 * @param tokenSymbol Symbol of the token contract
 * @return {"success" : "Returns true when successfully called from another contract"}
 */
function setTokenSymbol(Data storage self, string tokenSymbol) internal returns (bool success) {
    bytes32 id = keccak256(abi.encodePacked('token.symbol', address(this)));
    require(
      self.Storage.setString(id, tokenSymbol),
      "Error: Unable to set storage value. Please ensure contract interface is allowed by the storage contract."
    );
    return true;
  }
// Solidity 0.4.24
/**
 * @notice Set the token version for Token interfaces
 * @dev This method must be set by the token interface's setParams() method
 * @dev | This method has an `internal` view
 * @param self Internal storage proxying TokenIOStorage contract
 * @param tokenVersion Semantic (vMAJOR.MINOR.PATCH | e.g. v0.1.0) version of the token contract
 * @return {"success" : "Returns true when successfully called from another contract"}
 */
function setTokenVersion(Data storage self, string tokenVersion) internal returns (bool success) {
    bytes32 id = keccak256(abi.encodePacked('token.version', address(this)));
    require(
      self.Storage.setString(id, tokenVersion),
      "Error: Unable to set storage value. Please ensure contract interface is allowed by the storage contract."
    );
    return true;
  }
// Solidity 0.4.24
/**
 * @notice Set the token decimals for Token interfaces
 * @dev This method must be set by the token interface's setParams() method
 * @dev | This method has an `internal` view
 * @dev This method is not set to the address of the contract, rather is maped to currency
 * @dev To derive decimal value, divide amount by 10^decimal representation (e.g. 10132 / 10**2 == 101.32)
 * @param self Internal storage proxying TokenIOStorage contract
 * @param  currency Currency symbol of the token (e.g. USDx, JYPx, GBPx)
 * @param tokenDecimals Decimal representation of the token contract unit amount
 * @return {"success" : "Returns true when successfully called from another contract"}
 */
function setTokenDecimals(Data storage self, string currency, uint tokenDecimals) internal returns (bool success) {
    bytes32 id = keccak256(abi.encodePacked('token.decimals', currency));
    require(
      self.Storage.setUint(id, tokenDecimals),
      "Error: Unable to set storage value. Please ensure contract interface is allowed by the storage contract."
    );
    return true;
  }
// Solidity 0.4.24
/**
 * @notice Set basis point fee for contract interface
 * @dev Transaction fees can be set by the TokenIOFeeContract
 * @dev Fees vary by contract interface specified `feeContract`
 * @dev | This method has an `internal` view
 * @param self Internal storage proxying TokenIOStorage contract
 * @param feeBPS Basis points fee for interface contract transactions
 * @return {"success" : "Returns true when successfully called from another contract"}
 */
function setFeeBPS(Data storage self, uint feeBPS) internal returns (bool success) {
    bytes32 id = keccak256(abi.encodePacked('fee.bps', address(this)));
    require(
      self.Storage.setUint(id, feeBPS),
      "Error: Unable to set storage value. Please ensure contract interface is allowed by the storage contract."
    );
    return true;
  }
// Solidity 0.4.24
/**
 * @notice Set fee message for contract interface
 * @dev Default fee messages can be set by the TokenIOFeeContract (e.g. "tx_fees")
 * @dev Fee messages vary by contract interface specified `feeContract`
 * @dev | This method has an `internal` view
 * @param self Internal storage proxying TokenIOStorage contract
 * @param feeMsg Fee message included in a transaction with fees
 * @return {"success" : "Returns true when successfully called from another contract"}
 */
function setFeeMsg(Data storage self, bytes feeMsg) internal returns (bool success) {
    bytes32 id = keccak256(abi.encodePacked('fee.msg', address(this)));
    require(
      self.Storage.setBytes(id, feeMsg),
      "Error: Unable to set storage value. Please ensure contract interface is allowed by the storage contract."
    );
    return true;
  }
// Solidity 0.4.24
/**
 * @notice Set contract interface associated with a given TokenIO currency symbol (e.g. USDx)
 * @dev | This should only be called once from a token interface contract;
 * @dev | This method has an `internal` view
 * @dev | This method is experimental and may be deprecated/refactored
 * @param self Internal storage proxying TokenIOStorage contract
 * @param  currency Currency symbol of the token (e.g. USDx, JYPx, GBPx)
 * @return {"success" : "Returns true when successfully called from another contract"}
 */
function setTokenNameSpace(Data storage self, string currency) internal returns (bool success) {
    bytes32 id = keccak256(abi.encodePacked('token.namespace', currency));
    require(
      self.Storage.setAddress(id, address(this)),
      "Error: Unable to set storage value. Please ensure contract interface is allowed by the storage contract."
    );
    return true;
  }
// Solidity 0.4.24
/**
 * @notice Set the KYC approval status (true/false) for a given account
 * @dev | This method has an `internal` view
 * @dev | Every account must be KYC'd to be able to use transfer() & transferFrom() methods
 * @dev | To gain approval for an account, register at https://tsm.token.io/sign-up
 * @param self Internal storage proxying TokenIOStorage contract
 * @param account Ethereum address of account holder
 * @param isApproved Boolean (true/false) KYC approval status for a given account
 * @param issuerFirm Firm name for issuing KYC approval
 * @return {"success" : "Returns true when successfully called from another contract"}
 */
function setKYCApproval(Data storage self, address account, bool isApproved, string issuerFirm) internal returns (bool success) {
      bytes32 id = keccak256(abi.encodePacked('account.kyc', getForwardedAccount(self, account)));
      require(
        self.Storage.setBool(id, isApproved),
        "Error: Unable to set storage value. Please ensure contract interface is allowed by the storage contract."
      );

      /// @dev NOTE: Issuer is logged for setting account KYC status
      emit KYCApproval(account, isApproved, issuerFirm);
      return true;
  }
// Solidity 0.4.24
/**
 * @notice Set a forwarded address for an account.
 * @dev | This method has an `internal` view
 * @dev | Forwarded accounts must be set by an authority in case of account recovery;
 * @dev | Additionally, the original owner can set a forwarded account (e.g. add a new device, spouse, dependent, etc)
 * @dev | All transactions will be logged under the same KYC information as the original account holder;
 * @param self Internal storage proxying TokenIOStorage contract
 * @param originalAccount Original registered Ethereum address of the account holder
 * @param forwardedAccount Forwarded Ethereum address of the account holder
 * @return {"success" : "Returns true when successfully called from another contract"}
 */
function setForwardedAccount(Data storage self, address originalAccount, address forwardedAccount) internal returns (bool success) {
    bytes32 id = keccak256(abi.encodePacked('master.account', forwardedAccount));
    require(
      self.Storage.setAddress(id, originalAccount),
      "Error: Unable to set storage value. Please ensure contract interface is allowed by the storage contract."
    );
    return true;
  }
// Solidity 0.4.24
/**
 * @notice Get the original address for a forwarded account
 * @dev | This method has an `internal` view
 * @dev | Will return the registered account for the given forwarded account
 * @param self Internal storage proxying TokenIOStorage contract
 * @param account Ethereum address of account holder
 * @return { "registeredAccount" : "Will return the original account of a forwarded account or the account itself if no account found"}
 */
function getForwardedAccount(Data storage self, address account) internal view returns (address registeredAccount) {
    bytes32 id = keccak256(abi.encodePacked('master.account', account));
    address originalAccount = self.Storage.getAddress(id);
    if (originalAccount != 0x0) {
      return originalAccount;
    } else {
      return account;
    }
  }
// Solidity 0.4.24
/**
 * @notice Set the master fee contract used as the default fee contract when none is provided
 * @dev | This method has an `internal` view
 * @dev | This value is set in the TokenIOAuthority contract
 * @param self Internal storage proxying TokenIOStorage contract
 * @param contractAddress Contract address of the queryable interface
 * @return { "success" : "Returns true when successfully called from another contract"}
 */
function setMasterFeeContract(Data storage self, address contractAddress) internal returns (bool success) {
    bytes32 id = keccak256(abi.encodePacked('fee.contract.master'));
    require(
      self.Storage.setAddress(id, contractAddress),
      "Error: Unable to set storage value. Please ensure contract interface is allowed by the storage contract."
    );
    return true;
  }
// Solidity 0.4.24
/**
 * @notice Get the fee contract set for a contract interface
 * @dev | This method has an `internal` view
 * @dev | Custom fee pricing can be set by assigning a fee contract to transactional contract interfaces
 * @dev | If a fee contract has not been set by an interface contract, then the master fee contract will be returned
 * @param self Internal storage proxying TokenIOStorage contract
 * @param contractAddress Contract address of the queryable interface
 * @return { "feeContract" : "Returns the fee contract associated with a contract interface"}
 */
function getFeeContract(Data storage self, address contractAddress) internal view returns (address feeContract) {
    bytes32 id = keccak256(abi.encodePacked('fee.account', contractAddress));

    address feeAccount = self.Storage.getAddress(id);
    if (feeAccount == 0x0) {
      return getMasterFeeContract(self);
    } else {
      return feeAccount;
    }
  }
// Solidity 0.4.24
/**
 * @notice Set the frozen token balance for a given account
 * @dev | This method has an `internal` view
 * @param self Internal storage proxying TokenIOStorage contract
 * @param  currency Currency symbol of the token (e.g. USDx, JYPx, GBPx)
 * @param account Ethereum address of account holder
 * @param amount Amount of tokens to freeze for account
 * @return { "success" : "Return true if successfully called from another contract"}
 */
function setTokenFrozenBalance(Data storage self, string currency, address account, uint amount) internal returns (bool success) {
    bytes32 id = keccak256(abi.encodePacked('token.frozen', currency, getForwardedAccount(self, account)));
    require(
      self.Storage.setUint(id, amount),
      "Error: Unable to set storage value. Please ensure contract interface is allowed by the storage contract."
    );
    return true;
  }
// Solidity 0.4.24
/**
 * @notice Set the frozen token balance for a given account
 * @dev | This method has an `internal` view
 * @param self Internal storage proxying TokenIOStorage contract
 * @param contractAddress Contract address of the fee contract
 * @param amount Transaction value
 * @return { "calculatedFees" : "Return the calculated transaction fees for a given amount and fee contract" }
 */
function calculateFees(Data storage self, address contractAddress, uint amount) internal view returns (uint calculatedFees) {

    uint maxFee = self.Storage.getUint(keccak256(abi.encodePacked('fee.max', contractAddress)));
    uint minFee = self.Storage.getUint(keccak256(abi.encodePacked('fee.min', contractAddress)));
    uint bpsFee = self.Storage.getUint(keccak256(abi.encodePacked('fee.bps', contractAddress)));
    uint flatFee = self.Storage.getUint(keccak256(abi.encodePacked('fee.flat', contractAddress)));
    uint fees = ((amount.mul(bpsFee)).div(10000)).add(flatFee);

    if (fees > maxFee) {
      return maxFee;
    } else if (fees < minFee) {
      return minFee;
    } else {
      return fees;
    }
  }