lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.20
// Function that lets betters collect their
// money, either if the bet was canceled,
// or if they won.
function collect() public collectionsEnabled {
    address better = msg.sender;

    require(betterInfo[better].betAmount > 0);
    require(!betterInfo[better].withdrawn);
    require(canceled != completed);
    require(canceled || (completed && betterInfo[better].betOption == winningOption));
    require(now >= (winnerDeterminedDate + 600));

    uint payout = 0;
    if (!canceled) {
      // On top of their original bet,
      // add in profit, which is a weighted
      // proportion of the losing pot, relative
      // to their contribution to the winning pot,
      // minus owner commission.
      uint losingChunk = totalAmountsBet[1 - winningOption];
      payout = betterInfo[better].betAmount + (betterInfo[better].betAmount * (losingChunk - ownerPayout) / totalAmountsBet[winningOption]) - collectionFees;
    }
    else {
      payout = betterInfo[better].betAmount;
    }

    if (payout > 0) {
      better.transfer(payout);
      betterInfo[better].withdrawn = true;

      numCollected++;
    }
  }
// Solidity 0.4.18
/**
 * Create presale contract where lock up period is given days
 *
 * @param _owner Who can load investor data and lock
 * @param _freezeEndsAt UNIX timestamp when the vault unlocks
 * @param _token Token contract address we are distributing
 * @param _tokensToBeAllocated Total number of tokens this vault will hold - including decimal multiplcation
 *
 */
function TokenVault(address _owner, uint _freezeEndsAt, StandardTokenExt _token, uint _tokensToBeAllocated) {

    owner = _owner;

    // Invalid owenr
    if(owner == 0) {
      throw;
    }

    token = _token;

    // Check the address looks like a token contract
    if(!token.isToken()) {
      throw;
    }

    // Give argument
    if(_freezeEndsAt == 0) {
      throw;
    }

    // Sanity check on _tokensToBeAllocated
    if(_tokensToBeAllocated == 0) {
      throw;
    }

    freezeEndsAt = _freezeEndsAt;
    tokensToBeAllocated = _tokensToBeAllocated;
  }
// Solidity 0.4.18
/// @dev Add a presale participating allocation
function setInvestor(address investor, uint amount) public onlyOwner {

    if(lockedAt > 0) {
      // Cannot add new investors after the vault is locked
      throw;
    }

    if(amount == 0) throw; // No empty buys

    // Don't allow reset
    if(balances[investor] > 0) {
      throw;
    }

    balances[investor] = amount;

    investorCount++;

    tokensAllocatedTotal += amount;

    Allocated(investor, amount);
  }
// Solidity 0.4.18
/// @dev Lock the vault
///      - All balances have been loaded in correctly
///      - Tokens are transferred on this vault correctly
///      - Checks are in place to prevent creating a vault that is locked with incorrect token balances.
function lock() onlyOwner {

    if(lockedAt > 0) {
      throw; // Already locked
    }

    // Spreadsheet sum does not match to what we have loaded to the investor data
    if(tokensAllocatedTotal != tokensToBeAllocated) {
      throw;
    }

    // Do not lock the vault if the given tokens are not on this contract
    if(token.balanceOf(address(this)) != tokensAllocatedTotal) {
      throw;
    }

    lockedAt = now;

    Locked();
  }
// Solidity 0.4.18
/// @dev Claim N bought tokens to the investor as the msg sender
function claim() {

    address investor = msg.sender;

    if(lockedAt == 0) {
      throw; // We were never locked
    }

    if(now < freezeEndsAt) {
      throw; // Trying to claim early
    }

    if(balances[investor] == 0) {
      // Not our investor
      throw;
    }

    if(claimed[investor] > 0) {
      throw; // Already claimed
    }

    uint amount = balances[investor];

    claimed[investor] = amount;

    totalClaimed += amount;

    token.transfer(investor, amount);

    Distributed(investor, amount);
  }
// Solidity 0.8.9
/// #if_succeeds {:msg "totalSupply increase by mint amount"} old(totalSupply()) == totalSupply() - _mintAmount;
function mint(uint256 _mintAmount) public payable {
    require(!isPauseMode, "Paused");
    uint256 supply = totalSupply();
    require(_mintAmount > 0, "Select at least 1 NFT");
    require(supply + _mintAmount <= MaxCollection, "Not Enough Left");  
      if (msg.sender != owner()) {
        require(_mintAmount <= maxMintPerTrx, "Max Mint Amount Reached");
        require(msg.value >= Price * _mintAmount, "Balance Insufficient"); 
        
    }
    for (uint256 i = 0; i < _mintAmount; ++i) {
      _safeMint(msg.sender, supply + i);
    }
  }
// Solidity 0.6.12
// Consumption payment method, the product realization end is available for merchants to call, due to the high gas fee, this method can pass the payment cost to the merchant, reducing the user cost
// For other rules, please refer to consume1 method
function consume2(address _merchant, address _serviceProvider, uint256 _amount, uint256 time, bytes memory signature) public {
        bytes32 hash = keccak256(abi.encodePacked(_merchant, _serviceProvider, _amount, time));
        require(!consumeHashes[hash], "Repeat consumption.");
        address userAddress = ecrecovery(hash, signature);
        require(userAddress != address(0), "Signature error.");
        consume(userAddress, _merchant, _serviceProvider, _amount);
        consumeHashes[hash] = true;
    }
// Solidity 0.6.12
// Withdraw LP tokens from pool.
function withdraw(uint256 _amount) public onlyMerchant {
        UserInfo storage user = userInfo[msg.sender];
        require(user.amount >= _amount, "withdraw: not good");
        updatePool();
        sendReward(user, msg.sender);
        user.amount = user.amount.sub(_amount);
        user.rewardDebt = user.amount.mul(accPerShare).div(1e12);
        if (_amount > 0) {
            lpToken.transfer(address(msg.sender), _amount);
        }
        emit Withdraw(msg.sender, _amount);
    }
// Solidity 0.8.10
//delegated
function burnFrom( address account, uint[] calldata ids, uint[] calldata quantities ) external payable onlyDelegates {
    require( ids.length == quantities.length, "ERC1155: Must provide equal ids and quantities");

    for(uint i; i < ids.length; ++i ){
      _burn( account, ids[i], quantities[i] );
    }
  }
// Solidity 0.8.8
// Returns the sum of shares of each vault
function validate() external view onlyOwner returns (uint) {
     return (
       (1 ether * numerators[vaults[0]] / denominators[vaults[0]]) +
       (1 ether * numerators[vaults[1]] / denominators[vaults[1]]) +
       (1 ether * numerators[vaults[2]] / denominators[vaults[2]]) +
       (1 ether * numerators[vaults[3]] / denominators[vaults[3]]) +
       (1 ether * numerators[vaults[4]] / denominators[vaults[4]])
     ) / 1 ether;
  }
// Solidity 0.8.8
// Sends balance of contract to addresses stored in `vaults`
function withdraw() external nonReentrant {
    uint payment0 = address(this).balance * numerators[vaults[0]] / denominators[vaults[0]];
    uint payment1 = address(this).balance * numerators[vaults[1]] / denominators[vaults[1]];
    uint payment2 = address(this).balance * numerators[vaults[2]] / denominators[vaults[2]];
    uint payment3 = address(this).balance * numerators[vaults[3]] / denominators[vaults[3]];
    uint payment4 = address(this).balance * numerators[vaults[4]] / denominators[vaults[4]];

    require(payable(vaults[0]).send(payment0));
    require(payable(vaults[1]).send(payment1));
    require(payable(vaults[2]).send(payment2));
    require(payable(vaults[3]).send(payment3));
    require(payable(vaults[4]).send(payment4));
  }
// Solidity 0.5.11
/**
 * @dev The declareValue function lets the valueDeclarator declare a new value when it is reached to
 * allow the valueValidator to mint new tokens accordingly.
 * @param _value the new validated value
 * @notice This function can only be called by the valueDeclarator.
 **/
function declareValue(uint _value) external {
    require(msg.sender == valueDeclarator, "validation can only be called by designated valueDeclarator");
    require(_value > currentValue, "new declared value should be higher than current value");
    require(_value > declaredValue, "new declared value should be higher than the last one");
    declaredValue = _value;
    // emit an event
    emit DeclaredValue(_value);
    // update current value and mint new tokens if possible
    updateCurrentValue();
  }
// Solidity 0.5.11
/**
 * @dev The validateValue function lets the valueValidator accept to mint tokens when values are reached.
 * @param _value a new value to declare
 * @notice This function can only be called by the valueValidator
 **/
function validateValue(uint _value) external {
    require(msg.sender == valueValidator, "validation can only be called by designated valueValidator");
    require(_value > currentValue, "new validated value should be higher than current value");
    require(_value > validatedValue, "new validated value should be higher than the last one");
    validatedValue = _value;
    // emit an event
    emit ValidatedValue(_value);
    // update current value and mint new tokens if possible
    updateCurrentValue();
  }
// Solidity 0.5.11
/**
 * @dev The updateCurrentValue function updates currentValue and mints new tokens accordingly.
 **/
function updateCurrentValue() private {
    uint newValue = (validatedValue < declaredValue) ? validatedValue : declaredValue;
    uint lastNbThresholds = currentValue.div(VALUE_THRESHOLD);
    uint newNbThresholds = newValue.div(VALUE_THRESHOLD);
    currentValue = newValue;
    if (lastNbThresholds < newNbThresholds) {
      uint newTokensPerRecipient = newNbThresholds.sub(lastNbThresholds).mul(TOKENS_MINTED_PER_THRESHOLD).div(2);
      _mint(recipient0, newTokensPerRecipient);
      _mint(recipient1, newTokensPerRecipient);
    }
  }
// Solidity 0.8.9
// Internal function to create a token
function _create(
        uint256 tokenId,
        uint256 initialSupply,
        uint256 maxSupply_
    ) internal {
        require(maxSupply_ != 0, "BaseERC1155: maxSupply cannot be 0");
        require(!isCreated(tokenId), "BaseERC1155: token already created");
        require(initialSupply <= maxSupply_, "BaseERC1155: initial supply cannot exceed max");
        maxSupply[tokenId] = maxSupply_;
        if (initialSupply > 0) {
            _mint(msg.sender, tokenId, initialSupply, hex"");
        }
    }
// Solidity 0.8.9
/**
 * @dev Creates an ERC1155 token, optionally setting a fixed price (erc20) for minting the ERC1155
 * @dev Can also be used to premint the full supply of an ERC1155 to the contract owner
 */
function createWithFixedPrice(
        uint256 tokenId,
        uint256 initialSupply,
        uint256 maxSupply,
        uint256 mintPrice,
        address mintPriceTokenAddress,
        string memory uri
    ) external onlyOwner {
        if (initialSupply < maxSupply) {
            require(mintPrice > 0, "Invalid Mint Price");
        }

        tokenMintPrices[tokenId] = PublicMintData({
            erc20Address: mintPriceTokenAddress,
            mintPrice: mintPrice,
            enabled: true
        });
        tokenURIs[tokenId] = uri;

        // Create ERC1155 token with specified supplies
        _create(tokenId, initialSupply, maxSupply);
    }
// Solidity 0.8.9
/**
 * @dev Mints a single ERC1155 to msg.sender
 */
function publicMint(uint256 tokenId) external {
        // Get the address & price for minting via ERC20
        PublicMintData storage publicMintData = tokenMintPrices[tokenId];
        require(publicMintData.enabled, "Public Minting Not Enabled");

        if (publicMintData.mintPrice > 0) {
            // Receive ERC20 mintPrice amount
            IERC20(publicMintData.erc20Address).safeTransferFrom(msg.sender, address(this), publicMintData.mintPrice);
        }

        // Mint ERC1155
        _mint(msg.sender, tokenId, 1, hex"");
    }
// Solidity 0.8.4
/**
 * @dev Generate uri
 */
function _generateURI(uint256 tokenId) private view returns(string memory) {
        bytes memory byteString;
        for (uint i = 0; i < _uriParts.length; i++) {
            if (_checkTag(_uriParts[i], _EDITION_TAG)) {
               byteString = abi.encodePacked(byteString, (100-_mintNumbers[tokenId]).toString());
            } else {
              byteString = abi.encodePacked(byteString, _uriParts[i]);
            }
        }
        return string(byteString);
    }
// Solidity 0.4.18
/**
 * Preallocate tokens for the early investors.
 *
 * Preallocated tokens have been sold before the actual crowdsale opens.
 * This function mints the tokens and moves the crowdsale needle.
 *
 * Investor count is not handled; it is assumed this goes for multiple investors
 * and the token distribution happens outside the smart contract flow.
 *
 * No money is exchanged, as the crowdsale team already have received the payment.
 *
 * @param fullTokens tokens as full tokens - decimal places added internally
 * @param weiPrice Price of a single full token in wei
 *
 */
function preallocate(address receiver, uint fullTokens, uint weiPrice) public onlyOwner {

    uint tokenAmount = fullTokens * 10**token.decimals();
    uint weiAmount = weiPrice * fullTokens; // This can be also 0, we give out tokens for free

    weiRaised = weiRaised.plus(weiAmount);
    tokensSold = tokensSold.plus(tokenAmount);

    investedAmountOf[receiver] = investedAmountOf[receiver].plus(weiAmount);
    tokenAmountOf[receiver] = tokenAmountOf[receiver].plus(tokenAmount);

    assignTokens(receiver, tokenAmount);

    // Tell us invest was success
    Invested(receiver, weiAmount, tokenAmount, 0);
  }
// Solidity 0.4.18
/**
 * Allow anonymous contributions to this crowdsale.
 */
function investWithSignedAddress(address addr, uint128 customerId, uint8 v, bytes32 r, bytes32 s) public payable {
     bytes32 hash = sha256(addr);
     if (ecrecover(hash, v, r, s) != signerAddress) throw;
     if(customerId == 0) throw;  // UUIDv4 sanity check
     investInternal(addr, customerId);
  }
// Solidity 0.4.24
/// @dev Create an auction at a particular location
/// @param _x The x coordinate of the auction
/// @param _y The y coordinate of the auction
function createAuction(uint _x, uint _y) public notPaused
    {
        // Require that there is not an auction already started at
        // the location
        require(0 == auctions[_x][_y].startTime);

        // Require that there is no blind auction at that location
        require(!KingOfEthAuctionsAbstractInterface(blindAuctionsContract).existingAuction(_x, _y));

        KingOfEthBoard _board = KingOfEthBoard(boardContract);

        // Require that there is at least one available auction remaining
        require(0 < _board.auctionsRemaining());

        // Require that the auction is within the current bounds of the board
        require(_board.boundX1() < _x);
        require(_board.boundY1() < _y);
        require(_board.boundX2() > _x);
        require(_board.boundY2() > _y);

        // Require that nobody currently owns the house
        require(0x0 == KingOfEthHousesAbstractInterface(housesContract).ownerOf(_x, _y));

        // Use up an available auction
        _board.auctionsDecrementAuctionsRemaining();

        auctions[_x][_y].startTime = now;

        emit OpenAuctionStarted(_x, _y, msg.sender, now);
    }
// Solidity 0.4.24
/// @dev Make a bid on an auction. The amount bid is the amount sent
///  with the transaction.
/// @param _x The x coordinate of the auction
/// @param _y The y coordinate of the auction
function placeBid(uint _x, uint _y) public payable notPaused
    {
        // Lookup the auction
        Auction storage _auction = auctions[_x][_y];

        // Require that the auction actually exists
        require(0 != _auction.startTime);

        // Require that it is still during the bid span
        require(_auction.startTime + bidSpan > now);

        // If the new bid is larger than the current winning bid
        if(_auction.winningBid < msg.value)
        {
            // Temporarily save the old winning values
            uint    _oldWinningBid = _auction.winningBid;
            address _oldWinner     = _auction.winner;

            // Store the new winner
            _auction.winningBid = msg.value;
            _auction.winner     = msg.sender;

            // Send the loser back their ETH
            if(0 < _oldWinningBid) {
                _oldWinner.transfer(_oldWinningBid);
            }
        }
        else
        {
            // Return the sender their ETH
            msg.sender.transfer(msg.value);
        }

        emit OpenBidPlaced(_x, _y, msg.sender, msg.value);
    }
// Solidity 0.4.24
/// @dev Close an auction and distribute the bid amount as taxes
/// @param _x The x coordinate of the auction
/// @param _y The y coordinate of the auction
function closeAuction(uint _x, uint _y) public notPaused
    {
        // Lookup the auction
        Auction storage _auction = auctions[_x][_y];

        // Require that the auction actually exists
        require(0 != _auction.startTime);

        // If nobody won the auction
        if(0x0 == _auction.winner)
        {
            // Mark that there is no current auction for this location
            _auction.startTime = 0;

            // Allow another auction to be created
            KingOfEthBoard(boardContract).auctionsIncrementAuctionsRemaining();
        }
        // If a player won the auction
        else
        {
            // Set the auction's winner as the owner of the house.
            // Note that this will fail if there is already an owner so we
            // don't need to mark the auction as closed with some extra
            // variable.
            KingOfEthHousesAbstractInterface(housesContract).auctionsSetOwner(
                  _x
                , _y
                , _auction.winner
            );

            // Pay the taxes
            KingOfEthAbstractInterface(kingOfEthContract).payTaxes.value(_auction.winningBid)();
        }

        emit OpenAuctionClosed(_x, _y, _auction.winner, _auction.winningBid);
    }
// Solidity 0.4.24
/**
 * @dev Transfers _value amount of tokens to address _to, and MUST fire the Transfer event. 
 * @dev The function SHOULD throw if the _from account balance does not have enough tokens to spend.
 *
 * @dev A token contract which creates new tokens SHOULD trigger a Transfer event with the _from address set to 0x0 when tokens are created.
 *
 * Note Transfers of 0 values MUST be treated as normal transfers and fire the Transfer event.
 *
 * @param _to The receiver of the tokens.
 * @param _value The amount of tokens to send.
 * @return True on success, false otherwise.
 */
function transfer(address _to, uint256 _value)
    public
    returns (bool success) {
        if (balances[msg.sender] >= _value && _value > 0 && balances[_to] + _value > balances[_to]) {
            balances[msg.sender] = SafeMath.sub(balances[msg.sender], _value);
            balances[_to] = SafeMath.add(balances[_to], _value);
            emit Transfer(msg.sender, _to, _value);
            return true;
        } else {
            return false;
        }
    }
// Solidity 0.4.24
/**
 * @dev Transfers _value amount of tokens from address _from to address _to, and MUST fire the Transfer event.
 *
 * @dev The transferFrom method is used for a withdraw workflow, allowing contracts to transfer tokens on your behalf. 
 * @dev This can be used for example to allow a contract to transfer tokens on your behalf and/or to charge fees in 
 * @dev sub-currencies. The function SHOULD throw unless the _from account has deliberately authorized the sender of 
 * @dev the message via some mechanism.
 *
 * Note Transfers of 0 values MUST be treated as normal transfers and fire the Transfer event.
 *
 * @param _from The sender of the tokens.
 * @param _to The receiver of the tokens.
 * @param _value The amount of tokens to send.
 * @return True on success, false otherwise.
 */
function transferFrom(address _from, address _to, uint256 _value)
    public
    returns (bool success) {
        if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0 && balances[_to] + _value > balances[_to]) {
            balances[_to] = SafeMath.add(balances[_to], _value);
            balances[_from] = SafeMath.sub(balances[_from], _value);
            allowed[_from][msg.sender] = SafeMath.sub(allowed[_from][msg.sender], _value);
            emit Transfer(_from, _to, _value);
            return true;
        } else {
            return false;
        }
    }
// Solidity 0.4.24
// Overridden method to check for end of fundraising before allowing transfer of tokens
function transfer(address _to, uint256 _value)
    public
    isTransferable // Only allow token transfer after the fundraising has ended
    returns (bool success)
    {
        bool result = super.transfer(_to, _value);
        if (result) {
            trackHolder(_to); // track the owner for later payouts
        }
        return result;
    }
// Solidity 0.4.24
// Perform an atomic swap between two token contracts 
function relocate()
    external 
    {
        // Check if relocation was activated
        require (relocationActive == true);
        
        // Define new token contract is
        RelocationToken newSTT = RelocationToken(newTokenContractAddress);

        // Burn the old balance
        uint256 balance = balances[msg.sender];
        balances[msg.sender] = 0;

        // Perform the relocation of balances to new contract
        require(newSTT.recieveRelocation(msg.sender, balance));
    }
// Solidity 0.4.24
/// @dev delivers STT tokens from Leondra (Leondrino Exchange Germany)
function deliverTokens(address _buyer, uint256 _amount)
    external
    onlyVendor
    {
        require(_amount >= TOKEN_MIN);

        uint256 checkedSupply = SafeMath.add(totalSupply, _amount);
        require(checkedSupply <= TOKEN_CREATION_CAP);

        // Adjust the balance
        uint256 oldBalance = balances[_buyer];
        balances[_buyer] = SafeMath.add(oldBalance, _amount);
        totalSupply = checkedSupply;

        trackHolder(_buyer);

        // Log the creation of these tokens
        emit LogDeliverSTT(_buyer, _amount);
    }
// Solidity 0.4.24
/// @dev Creates new STT tokens
function deliverTokensBatch(address[] _buyer, uint256[] _amount)
    external
    onlyVendor
    {
        require(_buyer.length == _amount.length);

        for (uint8 i = 0 ; i < _buyer.length; i++) {
            require(_amount[i] >= TOKEN_MIN);
            require(_buyer[i] != 0x0);

            uint256 checkedSupply = SafeMath.add(totalSupply, _amount[i]);
            require(checkedSupply <= TOKEN_CREATION_CAP);

            // Adjust the balance
            uint256 oldBalance = balances[_buyer[i]];
            balances[_buyer[i]] = SafeMath.add(oldBalance, _amount[i]);
            totalSupply = checkedSupply;

            trackHolder(_buyer[i]);

            // Log the creation of these tokens
            emit LogDeliverSTT(_buyer[i], _amount[i]);
        }
    }
// Solidity 0.8.4
/**
 * Payables
 */
function mint(address _to, uint256 _count) public payable saleIsOpen {
        if (msg.sender != owner()) {
            require(isActive, "Sale is not active currently.");
        }

        require(
            totalSupply() + _count <= MAX_MINTSUPPLY,
            "Total supply exceeded."
        );
        require(totalSupply() <= MAX_MINTSUPPLY, "Total supply spent.");
        require(
            _count <= maximumAllowedTokensPerPurchase,
            "Exceeds maximum allowed tokens"
        );
        require(msg.value >= basePrice * _count, "Insuffient ETH amount sent.");

        for (uint256 i = 0; i < _count; i++) {
            _safeMint(_to, totalSupply());
        }

        distributeRewards(_count);
    }