lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.13
/**
 * Make an investment.
 *
 * Crowdsale must be running for one to invest.
 * We must have not pressed the emergency brake.
 *
 * @param receiver The Ethereum address who receives the tokens
 * @param customerId (optional) UUID v4 to track the successful payments on the server side
 *
 */
function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
    // Determine if it's a good time to accept investment from this participant
    if (getState() == State.PreFunding) {
      // Are we whitelisted for early deposit
      require(earlyParticipantWhitelist[receiver]);
    }

    uint weiAmount = ceilingStrategy.weiAllowedToReceive(msg.value, weiRaised, investedAmountOf[receiver], weiFundingCap);
    uint tokenAmount = pricingStrategy.calculatePrice(weiAmount, weiRaised, tokensSold, msg.sender, token.decimals());
    
    // Dust transaction if no tokens can be given
    require(tokenAmount != 0);

    if (investedAmountOf[receiver] == 0) {
      // A new investor
      investorCount++;
    }
    updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);

    // Pocket the money
    multisigWallet.transfer(weiAmount);

    // Return excess of money
    uint weiToReturn = msg.value.sub(weiAmount);
    if (weiToReturn > 0) {
      msg.sender.transfer(weiToReturn);
    }
  }
// Solidity 0.4.13
/**
 * 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.
 *
 * 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 notFinished {
    require(receiver != address(0));
    uint tokenAmount = fullTokens.mul(10**uint(token.decimals()));
    require(tokenAmount != 0);
    uint weiAmount = weiPrice.mul(tokenAmount); // This can also be 0, in which case we give out tokens for free
    updateInvestorFunds(tokenAmount, weiAmount, receiver , 0);
  }
// Solidity 0.4.13
/**
 * Private function to update accounting in the crowdsale.
 */
function updateInvestorFunds(uint tokenAmount, uint weiAmount, address receiver, uint128 customerId) private {
    // Update investor
    investedAmountOf[receiver] = investedAmountOf[receiver].add(weiAmount);
    tokenAmountOf[receiver] = tokenAmountOf[receiver].add(tokenAmount);

    // Update totals
    weiRaised = weiRaised.add(weiAmount);
    tokensSold = tokensSold.add(tokenAmount);

    assignTokens(receiver, tokenAmount);
    // Tell us that the investment was completed successfully
    Invested(receiver, weiAmount, tokenAmount, customerId);
  }
// Solidity 0.4.13
/**
 * Crowdfund state machine management.
 *
 * This function has the timed transition builtin.
 * So there is no chance of the variable being stale.
 */
function getState() public constant returns (State) {
    if (finalized) return State.Finalized;
    else if (block.number < startsAt) return State.PreFunding;
    else if (block.number <= endsAt && !ceilingStrategy.isCrowdsaleFull(weiRaised, weiFundingCap)) return State.Funding;
    else if (isMinimumGoalReached()) return State.Success;
    else if (!isMinimumGoalReached() && weiRaised > 0 && loadedRefund >= weiRaised) return State.Refunding;
    else return State.Failure;
  }
// Solidity 0.4.13
/** Called once by crowdsale finalize() if the sale was a success. */
function finalizeCrowdsale(CrowdsaleToken token) {
    require(msg.sender == address(crowdsale));

    // How many % points of tokens the founders and others get
    uint tokensSold = crowdsale.tokensSold();
    uint saleBasePoints = basePointsDivisor.sub(bonusBasePoints);
    allocatedBonus = tokensSold.mul(bonusBasePoints).div(saleBasePoints);

    // Move tokens to the team multisig wallet
    token.mint(teamMultisig, allocatedBonus);

    // Make token transferable
    token.releaseTokenTransfer();
  }
// Solidity 0.5.1
/**
 * @dev allows a creator to destroy some of its own tokens
 * Validates that caller is a creator and that sender is not blacklisted
 * amount is less than or equal to the creator's account balance
 * @param _amount uint256 the amount of tokens to be destroyed
 */
function destroy(uint256 _amount) whenNotPaused onlyCreators notBlacklisted(msg.sender) public {
        uint256 balance = balances[msg.sender];
        require(_amount > 0);
        require(balance >= _amount);

        totalSupply = totalSupply.sub(_amount);
        balances[msg.sender] = balance.sub(_amount);
        emit Destroy(msg.sender, _amount);
        emit Transfer(msg.sender, address(0), _amount);
    }
// Solidity 0.5.1
/**
 * @dev gets the payload to sign when a user wants to do a metaTransfer
 * @param _from uint256 address of the transferer
 * @param _to uint256 address of the recipient
 * @param value uint256 the amount of tokens to be transferred
 * @param fee uint256 the fee paid to the relayer in uCNY
 * @param nonce uint256 the metaNonce of the usere's metatransaction
 */
function getTransferPayload(
        address _from,
        address _to,
        uint256 value,
        uint256 fee,
        uint256 nonce
    ) public
    view
    returns (bytes32 payload)
  {
    return ECDSA.toEthSignedMessageHash(
      keccak256(abi.encodePacked(
        "transfer",     // function specfic text
        _from,          // transferer.
        _to,            // recipient
        address(this),  // Token address (replay protection).
        value,          // Number of tokens.
        fee,            // fee paid to metaTransfer relayer, in uCNY
        nonce           // Local sender specific nonce (replay protection).
      ))
    );
  }
// Solidity 0.5.1
/**
 * @dev metaTransfer function called by relayer which executes a token transfer
 * on behalf of the original sender who provided a vaild signature.
 * @param _from address of the original sender
 * @param _to address of the  recipient
 * @param value uint256 amount of uCNY being sent
 * @param fee uint256 uCNY fee rewarded to the relayer
 * @param metaNonce uint256 metaNonce of the original sender
 * @param signature bytes signature provided by original sender
 */
function metaTransfer(
        address _from,
        address _to,
        uint256 value,
        uint256 fee,
        uint256 metaNonce,
        bytes memory signature
  ) public returns (bool success) {


    // Verify and increment nonce.
    require(getMetaNonce(_from) == metaNonce);
    metaNonces[_from] = metaNonces[_from].add(1);
    // Verify signature.
    bytes32 payload = getTransferPayload(_from,_to, value, fee, metaNonce);
    require(isValidSignature(_from,payload,signature));

    require(_from != address(0));

    //_transfer(sender,receiver,value);
    _transfer(_from,_to,value);
    //send Fee to metaTx miner
    _transfer(_from,msg.sender,fee);

    emit MetaTransfer(msg.sender, _from,_to,value);
    return true;
  }
// Solidity 0.4.25
// Where should the raised ETH go?
// This is a constructor function 
// which means the following function name has to match the contract name declared above
function Coinware() {
        balances[msg.sender] = 40000000000000000000000000;               // Give the creator all initial tokens. This is set to 1000 for example. If you want your initial tokens to be X and your decimal is 5, set this value to X * 100000. (CHANGE THIS)
        totalSupply = 40000000000000000000000000;                        // Update total supply (1000 for example) (CHANGE THIS)
        name = "Coinware";                                   // Set the name for display purposes (CHANGE THIS)
        decimals = 18;                                               // Amount of decimals for display purposes (CHANGE THIS)
        symbol = "CWT";                                             // Set the symbol for display purposes (CHANGE THIS)
        unitsOneEthCanBuy = 50000;                                      // Set the price of your token for the ICO (CHANGE THIS)
        fundsWallet = msg.sender;                                  // The owner of the contract gets ETH
    }
// Solidity 0.6.11
/// @dev Returns true if and only if the function is running in the constructor
function isConstructor() private view returns (bool) {
    // extcodesize checks the size of the code stored in an address, and
    // address returns the current address. Since the code is still not
    // deployed when running a constructor, any checks on its code size will
    // yield zero, making it an effective way to detect if a contract is
    // under construction or not.
    address self = address(this);
    uint256 cs;
    assembly { cs := extcodesize(self) }
    return cs == 0;
  }
// Solidity 0.6.11
/**
 * @dev claim private tokens from the contract balance.
 * `amount` means how many tokens must be claimed.
 * Can be used only by an owner or by any whitelisted person
 */
function claimPrivateTokens(uint amount) public {
        require(privateWhitelist[msg.sender] > 0, "Sender is not whitelisted");
        require(privateWhitelist[msg.sender] >= amount, "Exceeded token amount");
        require(currentPrivatePool >= amount, "Exceeded private pool");
        
        currentPrivatePool = currentPrivatePool.sub(amount);
        
        privateWhitelist[msg.sender] = privateWhitelist[msg.sender].sub(amount);
        token.transfer(msg.sender, amount);
    }
// Solidity 0.4.18
/**
 * ICO constructor
 * Define ICO details and contribution period
 */
function Ico(uint256 _icoStart, uint256 _icoEnd, address[] _team, uint256 _tokensPerEth) public {
    // require (_icoStart >= now);
    require (_icoEnd >= _icoStart);
    require (_tokensPerEth > 0);

    owner = msg.sender;

    icoStart = _icoStart;
    icoEnd = _icoEnd;
    tokensPerEth = _tokensPerEth;

    // initialize the team mapping with true when part of the team
    teamNum = _team.length;
    for (uint256 i = 0; i < teamNum; i++) {
      team[_team[i]] = true;
    }

    // as a safety measure tempory set the sale address to something else than 0x0
    currentSaleAddress = owner;
  }
// Solidity 0.4.18
/**
 *
 * Function allowing investors to participate in the ICO.
 * Specifying the beneficiary will change who will receive the tokens.
 * Fund tokens will be distributed based on amount of ETH sent by investor, and calculated
 * using tokensPerEth value.
 */
function participate(address beneficiary) public payable {
    require (beneficiary != address(0));
    require (now >= icoStart && now <= icoEnd);
    require (msg.value > 0);

    uint256 ethAmount = msg.value;
    uint256 numTokens = ethAmount.mul(tokensPerEth);

    require(totalSupply.add(numTokens) <= hardCap);

    balances[beneficiary] = balances[beneficiary].add(numTokens);
    totalSupply = totalSupply.add(numTokens);
    tokensFrozen = totalSupply * 2;
    aum = totalSupply;

    owner.transfer(ethAmount);
    // Our own custom event to monitor ICO participation
    Participate(beneficiary, numTokens);
    // Let ERC20 tools know of token hodlers
    Transfer(0x0, beneficiary, numTokens);
  }
// Solidity 0.4.18
/**
 * Internal burn function, only callable by team
 *
 * @param _amount is the amount of tokens to burn.
 */
function freeze(uint256 _amount) public onlySaleAddress returns (bool) {
    reconcileDividend(msg.sender);
    require(_amount <= balances[msg.sender]);

    // SafeMath.sub will throw if there is not enough balance.
    balances[msg.sender] = balances[msg.sender].sub(_amount);
    totalSupply = totalSupply.sub(_amount);
    tokensFrozen = tokensFrozen.add(_amount);

    aum = aum.sub(tokenValue.mul(_amount).div(tokenPrecision));

    Freeze(msg.sender, _amount);
    Transfer(msg.sender, 0x0, _amount);
    return true;
  }
// Solidity 0.4.18
/**
 * Calculate the divends for the current period given the AUM profit
 *
 * @param totalProfit is the amount of total profit in USD.
 */
function reportProfit(int256 totalProfit, address saleAddress) public onlyTeam returns (bool) {
    // first we new dividends if this period was profitable
    if (totalProfit > 0) {
      // We only care about 50% of this, as the rest is reinvested right away
      uint256 profit = uint256(totalProfit).mul(tokenPrecision).div(2);

      // this will throw if there are not enough tokens
      addNewDividends(profit);
    }

    // then we drip
    drip(saleAddress);

    // adjust AUM
    aum = aum.add(uint256(totalProfit).mul(tokenPrecision));

    // register the sale address
    currentSaleAddress = saleAddress;

    return true;
  }
// Solidity 0.4.18
/**
 * Calculate the divends for the current period given the dividend
 * amounts (USD * tokenPrecision).
 */
function addNewDividends(uint256 profit) internal {
    uint256 newAum = aum.add(profit); // 18 sig digits
    tokenValue = newAum.mul(tokenPrecision).div(totalSupply); // 18 sig digits
    uint256 totalDividends = profit.mul(tokenPrecision).div(tokenValue); // 18 sig digits
    uint256 managementDividends = totalDividends.div(managementFees); // 17 sig digits
    uint256 dividendsIssued = totalDividends.sub(managementDividends); // 18 sig digits

    // make sure we have enough in the frozen fund
    require(tokensFrozen >= totalDividends);

    dividendSnapshots.push(DividendSnapshot(totalSupply, dividendsIssued, managementDividends));

    // add the previous amount of given dividends to the totalSupply
    totalSupply = totalSupply.add(totalDividends);
    tokensFrozen = tokensFrozen.sub(totalDividends);
  }
// Solidity 0.4.18
// Reconcile all outstanding dividends for an address
// into its balance.
function reconcileDividend(address _owner) internal {
    var (owedDividend, dividends) = getOwedDividend(_owner);

    for (uint i = 0; i < dividends.length; i++) {
      if (dividends[i] > 0) {
        Reconcile(_owner, lastDividend[_owner] + i, dividends[i]);
        Transfer(0x0, _owner, dividends[i]);
      }
    }

    if(owedDividend > 0) {
      balances[_owner] = balances[_owner].add(owedDividend);
    }

    // register this user as being owed no further dividends
    lastDividend[_owner] = dividendSnapshots.length;
  }
// Solidity 0.8.11
// free for gutter cats
function freeSale(uint256 catID) external nonReentrant {
        require(tx.origin == msg.sender, "no...");
        require(freeMintLive, "free mint not live");

        require(_currentIndex + 1 <= maxNormalSupplyID, "out of stock");
        require(!usedCatIDs[catID], "you can only mint once with this id");

        require(
            IERC1155(gutterCatNFTAddress).balanceOf(msg.sender, catID) > 0,
            "you have to own a cat with this id"
        );

        usedCatIDs[catID] = true;

        mintToken(msg.sender);
    }
// Solidity 0.8.11
//sets the gang addresses
function setGutterAddresses(
        address cats,
        address rats,
        address pigeons,
        address dogs
    ) external onlyOwner {
        gutterCatNFTAddress = cats; //0xEdB61f74B0d09B2558F1eeb79B247c1F363Ae452
        gutterRatNFTAddress = rats; //0xD7B397eDad16ca8111CA4A3B832d0a5E3ae2438C
        gutterPigeonNFTAddress = pigeons; //0x950b9476a4de757BB134483029AC4Ec17E739e3A
        gutterDogNFTAddress = dogs; //0x6e9da81ce622fb65abf6a8d8040e460ff2543add
    }
// Solidity 0.8.11
/**
 * Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-less listings.
 */
function isApprovedForAll(address owner, address operator)
        public
        view
        override
        returns (bool)
    {
        // Whitelist OpenSea proxy contract for easy trading.
        ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress);
        if (address(proxyRegistry.proxies(owner)) == operator) {
            return true;
        }
        return super.isApprovedForAll(owner, operator);
    }
// Solidity 0.8.4
/**
 * Withdraw processed allowance from a specific epoch
 */
function withdraw(uint256 epoch) external {
        require(epoch < currentEpoch(), "Can only withdraw from past epochs");

        User storage user = userData[msg.sender];

        uint256 amount = user.Exits[epoch];
        delete user.Exits[epoch];
        totalPerEpoch[epoch] -= amount; // TODO: WHen this goes to 0, is it the same as the data being removed?
        user.Amount -= amount;

        // Once all allocations on queue have been claimed, reset user state
        if (user.Amount == 0) {
            // NOTE: triggers ExitQueue.withdraw(uint256) (contracts/ExitQueue.sol #150-167) deletes ExitQueue.User (contracts/ExitQueue.sol#15-27) which contains a mapping
            //        This is okay as if Amount is 0, we'd expect user.Exits to be empty as well
            //        TODO: Confirm this via tests
            delete userData[msg.sender];
        }

        SafeERC20.safeTransfer(TEMPLE, msg.sender, amount);
        emit Withdrawal(msg.sender, amount);    
    }
// Solidity 0.8.4
// All the following overrides are optional, if you want to modify default behavior.
// How the protection gets disabled.
function protectionChecker() internal view override returns(bool) {
        return ProtectionSwitch_timestamp(1620086399); // Switch off protection on Monday, May 3, 2021 11:59:59 PM.
        // return ProtectionSwitch_block(13000000); // Switch off protection on block 13000000.
        //return ProtectionSwitch_manual(); // Switch off protection by calling disableProtection(); from owner. Default.
    }
// Solidity 0.8.4
/**
 * @dev Destroys `amount` tokens from `account`, deducting from the caller's
 * allowance.
 *
 * See {ERC20-_burn} and {ERC20-allowance}.
 *
 * Requirements:
 *
 * - the caller must have allowance for ``accounts``'s tokens of at least
 * `amount`.
 * - the caller must have the `BURNER_ROLE`.
 */
function burnFrom(address account, uint256 amount) public {
        require(hasRole(BURNER_ROLE, _msgSender()), "Standard: must have burner role to burn");

        uint256 currentAllowance = allowance(account, _msgSender());
        require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance");
        _approve(account, _msgSender(), currentAllowance - amount);
        _burn(account, amount);
    }
// Solidity 0.6.10
/**
 * When given allowance, transfers a token from the "_from" to the "_to" of quantity "_quantity".
 * Ensures that the recipient has received the correct quantity (ie no fees taken on transfer)
 *
 * @param _token           ERC20 token to approve
 * @param _from            The account to transfer tokens from
 * @param _to              The account to transfer tokens to
 * @param _quantity        The quantity to transfer
 */
function transferFrom(
        IERC20 _token,
        address _from,
        address _to,
        uint256 _quantity
    )
        internal
    {
        // Call specified ERC20 contract to transfer tokens (via proxy).
        if (_quantity > 0) {
            uint256 existingBalance = _token.balanceOf(_to);

            SafeERC20.safeTransferFrom(
                _token,
                _from,
                _to,
                _quantity
            );

            uint256 newBalance = _token.balanceOf(_to);

            // Verify transfer quantity is reflected in balance
            require(
                newBalance == existingBalance.add(_quantity),
                "Invalid post transfer balance"
            );
        }
    }
// Solidity 0.6.10
/**
 * @dev Divides value a by value b (result is rounded down - positive numbers toward 0 and negative away from 0).
 */
function divDown(int256 a, int256 b) internal pure returns (int256) {
        require(b != 0, "Cant divide by 0");
        require(a != MIN_INT_256 || b != -1, "Invalid input");

        int256 result = a.div(b);
        if (a ^ b < 0 && a % b != 0) {
            result = result.sub(1);
        }

        return result;
    }
// Solidity 0.4.24
// deletes proposal signature data after successfully executing a multiSig function
function deleteProposal(Data storage self, bytes32 _whatFunction)
        internal
    {
        //done for readability sake
        bytes32 _whatProposal = whatProposal(_whatFunction);
        address _whichAdmin;
        
        //delete the admins votes & log.   i know for loops are terrible.  but we have to do this 
        //for our data stored in mappings.  simply deleting the proposal itself wouldn't accomplish this.
        for (uint256 i=0; i < self.proposal_[_whatProposal].count; i++) {
            _whichAdmin = self.proposal_[_whatProposal].log[i];
            delete self.proposal_[_whatProposal].admin[_whichAdmin];
            delete self.proposal_[_whatProposal].log[i];
        }
        //delete the rest of the data in the record
        delete self.proposal_[_whatProposal];
    }
// Solidity 0.4.24
// returns address of an admin who signed for any given function
function checkSigner (Data storage self, bytes32 _whatFunction, uint256 _signer)
        internal
        view
        returns (address signer)
    {
        require(_signer > 0, "MSFun checkSigner failed - 0 not allowed");
        bytes32 _whatProposal = whatProposal(_whatFunction);
        return (self.proposal_[_whatProposal].log[_signer - 1]);
    }
// Solidity 0.4.13
/* Transfers tokens from your address to other */
function transfer(address _to, uint256 _value) lockAffected returns (bool success) {
    require(_to != 0x0 && _to != address(this));
    balances[msg.sender] = balances[msg.sender].sub(_value); // Deduct senders balance
    balances[_to] = balances[_to].add(_value);               // Add recivers blaance
    Transfer(msg.sender, _to, _value);                       // Raise Transfer event
    return true;
  }
// Solidity 0.4.19
/** Current market price per pixel for this region if it is the first sale of this region
 	  */
function calculateRegionInitialSalePixelPrice(address[16] _contracts, uint256 _regionId) view public returns (uint256) {
		require(BdpDataStorage(BdpContracts.getBdpDataStorage(_contracts)).getRegionUpdatedAt(_regionId) > 0); // region exists
		var purchasedPixels = countPurchasedPixels(_contracts);
		var (area,,) = calculateArea(_contracts, _regionId);
		return calculateAveragePixelPrice(_contracts, purchasedPixels, purchasedPixels + area);
	}
// Solidity 0.8.12
/**
 * @dev Tries to returns the value associated with `key`.  O(1).
 * Does not revert if `key` is not in the map.
 */
function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) {
        bytes32 value = map._values[key];
        if (value == bytes32(0)) {
            return (_contains(map, key), bytes32(0));
        } else {
            return (true, value);
        }
    }
// Solidity 0.4.19
/** Setup is allowed one whithin one day after purchase
 	  */
function calculateSetupAllowedUntil(address[16] _contracts, uint256 _regionId) view public returns (uint256) {
		var (updatedAt, purchasedAt) = BdpDataStorage(BdpContracts.getBdpDataStorage(_contracts)).getRegionUpdatedAtPurchasedAt(_regionId);
		if(updatedAt != purchasedAt) {
			return 0;
		} else {
			return purchasedAt + 1 days;
		}
	}