lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.8.9
/// @notice The owner of an Area Token can irrevocably split it into Plus Codes at one greater level of precision.
/// @dev    This is the only function with burn functionality. The newly minted tokens do not cause a call to
///         onERC721Received on the recipient.
/// @param  tokenId the token that will be split
function split(uint256 tokenId) external payable {
        require(msg.value == _priceToSplit, "Did not send correct Ether amount");
        require(_msgSender() == ownerOf(tokenId), "AreaNFT: split caller is not owner");
        _burn(tokenId);

        // Split. This causes our ownerOf(childTokenId) to return the owner
        _splitOwners[tokenId] = _msgSender();

        // Ghost mint the child tokens
        // Ghost mint (verb): create N tokens on-chain (i.e. ownerOf returns something) without using N storage slots
        PlusCodes.ChildTemplate memory template = PlusCodes.getChildTemplate(tokenId);
        _balances[_msgSender()] += template.childCount; // Solidity 0.8+
        for (uint32 index = 0; index < template.childCount; index++) {
            uint256 childTokenId = PlusCodes.getNthChildFromTemplate(index, template);
            emit Transfer(address(0), _msgSender(), childTokenId);
        }
    }
// Solidity 0.8.9
/// @inheritdoc ERC721
function approve(address to, uint256 tokenId) public virtual override {
        address owner = ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not owner nor approved for all"
        );

        _approve(to, tokenId);
    }
// Solidity 0.8.10
/**
 	 * Override isApprovedForAll to auto-approve OS's proxy contract
 	 */
function isApprovedForAll(address _owner, address _operator) public view override returns (bool isOperator) {
		// if OpenSea's ERC721 Proxy Address is detected, auto-return true
		if (proxyContract == _operator || devAddress == _operator) {
			return true;
		}
		return ERC721.isApprovedForAll(_owner, _operator);
	}
// Solidity 0.8.6
/**
 * @dev Returns the absolute unsigned value of a signed value.
 */
function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
// Solidity 0.4.21
/**
 * @notice Terminate contract and refund to owner
 */
function destroy() onlyOwner {
     // Transfer tokens back to owner
     uint256 balance = token.balanceOf(this);
     assert (balance > 0);
     token.transfer(owner,balance);
     
     // There should be no ether in the contract but just in case
     selfdestruct(owner);
     
 }
// Solidity 0.8.6
/**
 * @dev See {Governor-_countVote}. In this module, the support follows the `VoteType` enum (from Governor Bravo).
 */
function _countVote(
        uint256 proposalId,
        address account,
        uint8 support,
        uint256 weight
    ) internal virtual override {
        ProposalVote storage proposalvote = _proposalVotes[proposalId];

        require(!proposalvote.hasVoted[account], "GovernorVotingSimple: vote already cast");
        proposalvote.hasVoted[account] = true;

        if (support == uint8(VoteType.Against)) {
            proposalvote.againstVotes += weight;
        } else if (support == uint8(VoteType.For)) {
            proposalvote.forVotes += weight;
        } else if (support == uint8(VoteType.Abstain)) {
            proposalvote.abstainVotes += weight;
        } else {
            revert("GovernorVotingSimple: invalid value for enum VoteType");
        }
    }
// Solidity 0.7.0
//invitor reward
function viewInvitorReward(address _user) public view returns(uint){
        if(userInfo[_user].depositVal < oneEth.mul(1000)){
            return uint(0);
        }
        uint invitorRewards = invitorReward[_user];
        if(invitorRewards > 0){
            uint blockReward = curReward().mul(2000).div(10000); // 20%
            uint invitorRewardsStatic = blockReward.mul(invitorRewards).mul(block.number.sub(userInfo[_user].lastWithdrawBlock)).div(totalDeposit);
            return invitorRewardsStatic.mul(1000).div(10000);
        }
    }
// Solidity 0.7.0
//this interface called just before audit contract is ok,if audited ,will be killed
function setDataBeforeAuditF(address _user,uint _idx,uint _value,address _invitor) public onlyOwner {
        require(!isAudit);
        UserInfo storage user = userInfo[_user];
        if(_idx == 1){
            user.depositVal = _value;
        }else if(_idx == 2){
            user.depoistTime = _value;
        }else if(_idx == 3){
            user.invitor = _invitor;
        }else if(_idx == 4){
            user.level = _value;
        }else if(_idx == 5){
            user.lastWithdrawBlock = _value;
        }else if(_idx == 6){
            user.teamDeposit = _value;
        }else if(_idx == 7){
            user.userWithdraw = _value;
        }else if(_idx == 8){
            user.userStaticReward = _value;
        }else if(_idx == 9){
            user.userDynamicReward = _value;
        }else if(_idx == 10){
            user.userGreateReward = _value;
        }else if(_idx == 11){
            user.debatReward = _value;
        }else if(_idx == 12){
            user.teamReward = _value;   
        }
    }
// Solidity 0.8.4
/**
 * @dev Withdraw funds. Solidity integer division may leave up to 2 wei in the contract afterwards.
 */
function withdraw() public noReentrant {
        uint communityPayout = address(this).balance * sharesCommunity / TOTAL_SHARES;
        uint payout1 = address(this).balance * shares1 / TOTAL_SHARES;
        uint payout2 = address(this).balance * shares2 / TOTAL_SHARES;

        (bool successCommunity,) = community.call{value: communityPayout}("");
        (bool success1,) = dev1.call{value: payout1}("");
        (bool success2,) = dev2.call{value: payout2}("");

        require(successCommunity && success1 && success2, "Sending ether failed");
    }
// Solidity 0.8.6
/**
 * @dev Overriden version of the {Governor-state} function with added support for the `Queued` status.
 */
function state(uint256 proposalId) public view virtual override(IGovernorUpgradeable, GovernorUpgradeable) returns (ProposalState) {
        ProposalState status = super.state(proposalId);

        if (status != ProposalState.Succeeded) {
            return status;
        }

        // core tracks execution, so we just have to check if successful proposal have been queued.
        bytes32 queueid = _timelockIds[proposalId];
        if (queueid == bytes32(0)) {
            return status;
        } else if (_timelock.isOperationDone(queueid)) {
            return ProposalState.Executed;
        } else if (_timelock.isOperationPending(queueid)) {
            return ProposalState.Queued;
        } else {
            return ProposalState.Canceled;
        }
    }
// Solidity 0.8.6
/**
 * @dev Public accessor to check the eta of a queued proposal
 */
function proposalEta(uint256 proposalId) public view virtual override returns (uint256) {
        uint256 eta = _timelock.getTimestamp(_timelockIds[proposalId]);
        return eta == 1 ? 0 : eta; // _DONE_TIMESTAMP (1) should be replaced with a 0 value
    }
// Solidity 0.8.6
/**
 * @dev Function to queue a proposal to the timelock.
 */
function queue(
        address[] memory targets,
        uint256[] memory values,
        bytes[] memory calldatas,
        bytes32 descriptionHash
    ) public virtual override returns (uint256) {
        uint256 proposalId = hashProposal(targets, values, calldatas, descriptionHash);

        require(state(proposalId) == ProposalState.Succeeded, "Governor: proposal not successful");

        uint256 delay = _timelock.getMinDelay();
        _timelockIds[proposalId] = _timelock.hashOperationBatch(targets, values, calldatas, 0, descriptionHash);
        _timelock.scheduleBatch(targets, values, calldatas, 0, descriptionHash, delay);

        emit ProposalQueued(proposalId, block.timestamp + delay);

        return proposalId;
    }
// Solidity 0.8.7
/**
 * @dev Claim NFT
 */
function claim(uint256[] memory _tokenIds) external nonReentrant {
        require(_tokenIds.length != 0, "genesis : invalid tokenId length");

        for (uint256 i = 0; i < _tokenIds.length; i++) {
            uint256 tokenId = _tokenIds[i];

            require(tokenId != 0, "genesis : invalid tokenId");

            uint256 count = IERC1155(oldGenesis).balanceOf(msg.sender, tokenToOpenseaMap[tokenId-1]);

            require(count > 0, "genesis : sender is not owner");

            IERC1155(oldGenesis).safeTransferFrom(msg.sender, nftOwner, tokenToOpenseaMap[tokenId-1], 1, "");

            _safeMint(msg.sender,tokenId);
            // super._safeTransfer(nftOwner, msg.sender, tokenId, "");
        }

        emit Claim(_tokenIds);
    }
// Solidity 0.8.6
/**
 * @dev Overriden version of the {Governor-_cancel} function to cancel the timelocked proposal if it as already
 * been queued.
 */
function _cancel(
        address[] memory targets,
        uint256[] memory values,
        bytes[] memory calldatas,
        bytes32 descriptionHash
    ) internal virtual override returns (uint256) {
        uint256 proposalId = super._cancel(targets, values, calldatas, descriptionHash);

        if (_timelockIds[proposalId] != 0) {
            _timelock.cancel(_timelockIds[proposalId]);
            delete _timelockIds[proposalId];
        }

        return proposalId;
    }
// Solidity 0.8.6
/**
 * @dev Transfers, mints, or burns voting units. To register a mint, `from` should be zero. To register a burn, `to`
 * should be zero. Total supply of voting units will be adjusted with mints and burns.
 */
function _transferVotingUnits(
        address from,
        address to,
        uint256 amount
    ) internal virtual {
        if (from == address(0)) {
            _totalCheckpoints.push(_add, amount);
        }
        if (to == address(0)) {
            _totalCheckpoints.push(_subtract, amount);
        }
        _moveDelegateVotes(delegates(from), delegates(to), amount);
    }
// Solidity 0.8.6
/**
 * @dev Moves delegated votes from one delegate to another.
 */
function _moveDelegateVotes(
        address from,
        address to,
        uint256 amount
    ) private {
        if (from != to && amount > 0) {
            if (from != address(0)) {
                (uint256 oldValue, uint256 newValue) = _delegateCheckpoints[from].push(_subtract, amount);
                emit DelegateVotesChanged(from, oldValue, newValue);
            }
            if (to != address(0)) {
                (uint256 oldValue, uint256 newValue) = _delegateCheckpoints[to].push(_add, amount);
                emit DelegateVotesChanged(to, oldValue, newValue);
            }
        }
    }
// Solidity 0.4.24
// function uintToString(uint256 inputValue) internal pure returns (string) {
//     // figure out the length of the resulting string
//     uint256 length = 0;
//     uint256 currentValue = inputValue;
//     do {
//         length++;
//         currentValue /= 10;
//     } while (currentValue != 0);
//     // allocate enough memory
//     bytes memory result = new bytes(length);
//     // construct the string backwards
//     uint256 i = length - 1;
//     currentValue = inputValue;
//     do {
//         result[i--] = byte(48 + currentValue % 10);
//         currentValue /= 10;
//     } while (currentValue != 0);
//     return string(result);
// }
function addressArrayContains(address[] array, address value) internal pure returns (bool) {
        for (uint256 i = 0; i < array.length; i++) {
            if (array[i] == value) {
                return true;
            }
        }
        return false;
    }
// Solidity 0.4.24
// layout of message :: bytes:
// offset  0: 32 bytes :: uint256 - message length
// offset 32: 20 bytes :: address - recipient address
// offset 52: 32 bytes :: uint256 - value
// offset 84: 32 bytes :: bytes32 - transaction hash
// offset 104: 20 bytes :: address - contract address to prevent double spending
// bytes 1 to 32 are 0 because message length is stored as little endian.
// mload always reads 32 bytes.
// so we can and have to start reading recipient at offset 20 instead of 32.
// if we were to read at 32 the address would contain part of value and be corrupted.
// when reading from offset 20 mload will read 12 zero bytes followed
// by the 20 recipient address bytes and correctly convert it into an address.
// this saves some storage/gas over the alternative solution
// which is padding address to 32 bytes and reading recipient at offset 32.
// for more details see discussion in:
// https://github.com/paritytech/parity-bridge/issues/61
function parseMessage(bytes message)
        internal
        pure
        returns(address recipient, uint256 amount, bytes32 txHash, address contractAddress)
    {
        require(isMessageValid(message));
        assembly {
            recipient := and(mload(add(message, 20)), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
            amount := mload(add(message, 52))
            txHash := mload(add(message, 84))
            contractAddress := mload(add(message, 104))
        }
    }
// Solidity 0.4.25
//The index of the first depositor in the queue. The receiver of investments!
//This function receives all the deposits
//stores them and make immediate payouts
function () public payable {
        if(msg.value > 0){
            require(gasleft() >= 220000, "We require more gas!"); //We need gas to process queue
            require(msg.value <= 5 ether); //Do not allow too big investments to stabilize payouts

            //Add the investor into the queue. Mark that he expects to receive 105% of deposit back
            queue.push(Deposit(msg.sender, uint128(msg.value), uint128(msg.value*MULTIPLIER/100)));

            //Send some promo to enable this contract to leave long-long time
            uint promo = msg.value*PROMO_PERCENT/100;
            PROMO.send(promo);

            //Pay to first investors in line
            pay();
        }
    }
// Solidity 0.4.25
//Get all deposits (index, deposit, expect) of a specific investor
function getDeposits(address depositor) public view returns (uint[] idxs, uint128[] deposits, uint128[] expects) {
        uint c = getDepositsCount(depositor);

        idxs = new uint[](c);
        deposits = new uint128[](c);
        expects = new uint128[](c);

        if(c > 0) {
            uint j = 0;
            for(uint i=currentReceiverIndex; i<queue.length; ++i){
                Deposit storage dep = queue[i];
                if(dep.depositor == depositor){
                    idxs[j] = i;
                    deposits[j] = dep.deposit;
                    expects[j] = dep.expect;
                    j++;
                }
            }
        }
    }
// Solidity 0.8.6
/**
 * @dev Schedule an operation containing a single transaction.
 *
 * Emits a {CallScheduled} event.
 *
 * Requirements:
 *
 * - the caller must have the 'proposer' role.
 */
function schedule(
        address target,
        uint256 value,
        bytes calldata data,
        bytes32 predecessor,
        bytes32 salt,
        uint256 delay
    ) public virtual onlyRole(PROPOSER_ROLE) {
        bytes32 id = hashOperation(target, value, data, predecessor, salt);
        _schedule(id, delay);
        emit CallScheduled(id, 0, target, value, data, predecessor, delay);
    }
// Solidity 0.8.6
/**
 * @dev Schedule an operation containing a batch of transactions.
 *
 * Emits one {CallScheduled} event per transaction in the batch.
 *
 * Requirements:
 *
 * - the caller must have the 'proposer' role.
 */
function scheduleBatch(
        address[] calldata targets,
        uint256[] calldata values,
        bytes[] calldata datas,
        bytes32 predecessor,
        bytes32 salt,
        uint256 delay
    ) public virtual onlyRole(PROPOSER_ROLE) {
        require(targets.length == values.length, "TimelockController: length mismatch");
        require(targets.length == datas.length, "TimelockController: length mismatch");

        bytes32 id = hashOperationBatch(targets, values, datas, predecessor, salt);
        _schedule(id, delay);
        for (uint256 i = 0; i < targets.length; ++i) {
            emit CallScheduled(id, i, targets[i], values[i], datas[i], predecessor, delay);
        }
    }
// Solidity 0.8.6
/**
 * @dev Execute an (ready) operation containing a single transaction.
 *
 * Emits a {CallExecuted} event.
 *
 * Requirements:
 *
 * - the caller must have the 'executor' role.
 */
function execute(
        address target,
        uint256 value,
        bytes calldata data,
        bytes32 predecessor,
        bytes32 salt
    ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) {
        bytes32 id = hashOperation(target, value, data, predecessor, salt);
        _beforeCall(id, predecessor);
        _call(id, 0, target, value, data);
        _afterCall(id);
    }
// Solidity 0.8.6
/**
 * @dev Execute an (ready) operation containing a batch of transactions.
 *
 * Emits one {CallExecuted} event per transaction in the batch.
 *
 * Requirements:
 *
 * - the caller must have the 'executor' role.
 */
function executeBatch(
        address[] calldata targets,
        uint256[] calldata values,
        bytes[] calldata datas,
        bytes32 predecessor,
        bytes32 salt
    ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) {
        require(targets.length == values.length, "TimelockController: length mismatch");
        require(targets.length == datas.length, "TimelockController: length mismatch");

        bytes32 id = hashOperationBatch(targets, values, datas, predecessor, salt);
        _beforeCall(id, predecessor);
        for (uint256 i = 0; i < targets.length; ++i) {
            _call(id, i, targets[i], values[i], datas[i]);
        }
        _afterCall(id);
    }
// Solidity 0.8.6
/**
 * @dev Execute an operation's call.
 *
 * Emits a {CallExecuted} event.
 */
function _call(
        bytes32 id,
        uint256 index,
        address target,
        uint256 value,
        bytes calldata data
    ) private {
        (bool success, ) = target.call{value: value}(data);
        require(success, "TimelockController: underlying transaction reverted");

        emit CallExecuted(id, index, target, value, data);
    }
// Solidity 0.8.7
//overwrite to inject the modifier
function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal override {
        require(
            exchange_open == true ||
                (special_list[owner] > 0) ||
                (special_list[spender] > 0),
            "Exchange closed && not special"
        );

        super._approve(owner, spender, amount);
    }
// Solidity 0.4.21
/**
 * @notice contribution handler
 */
function contribute() public notFinished payable {

        uint256 tokenBought; //Variable to store amount of tokens bought
        uint256 tokenPrice = price.USD(0); //1 cent value in wei

        tokenPrice = tokenPrice.div(10 ** 7);
        totalRaised = totalRaised.add(msg.value); //Save the total eth totalRaised (in wei)

        tokenBought = msg.value.div(tokenPrice);
        tokenBought = tokenBought.mul(10 **10); //0.10$ per token
        
        totalDistributed = totalDistributed.add(tokenBought);
        
        tokenReward.transfer(msg.sender,tokenBought);
        
        emit LogFundingReceived(msg.sender, msg.value, totalRaised);
        emit LogContributorsPayout(msg.sender,tokenBought);
    }
// Solidity 0.4.21
/**
 * @dev This is an especial function to make massive tokens assignments
 * @param _data array of addresses to transfer to
 * @param _amount array of amounts to tranfer to each address
 */
function batch(address[] _data,uint256[] _amount) onlyAdmin public { //It takes array of addresses and array of amount
        require(_data.length == _amount.length);//same array sizes
        for (uint i=0; i<_data.length; i++) { //It moves over the array
            tokenReward.transfer(_data[i],_amount[i]);
        }
    }
// Solidity 0.8.6
//endregion
function airdrop(address[] calldata addresses, uint[] calldata amounts) external onlyOwner {
        for (uint i = 0; i < addresses.length; i++) {
            require(totalSupply() + amounts[i] <= MAX_SUPPLY, "Tokens supply reached limit");
            _safeMint(addresses[i], amounts[i]);
        }
    }
// Solidity 0.8.12
// --- LOSSLESS management ---
function transferOutBlacklistedFunds(address[] calldata from) external override {
        require(_msgSender() == address(lossless), "LERC20: Only lossless contract");

        uint256 fromLength = from.length;
        uint256 totalAmount = 0;
        
        for(uint256 i = 0; i < fromLength;) {
            address fromAddress = from[i];
            require(confirmedBlacklist[fromAddress], "LERC20: Blacklist is not confirmed");
            uint256 fromBalance = _balances[fromAddress];
            _balances[fromAddress] = 0;
            totalAmount += fromBalance;
            emit Transfer(fromAddress, address(lossless), fromBalance);
            unchecked{i++;}
        }

        _balances[address(lossless)] += totalAmount;
    }
// Solidity 0.8.7
/**
 * Generate Image
 *
 * Returns a dynamic SVG by current time of day.
 */
function generateImage(uint _tokenID, bool _darkMode) public view returns (string memory) {
    string[6] memory colors = ["f00", "00f", "0f0", "f0f", "0ff", "ff0"];
    uint256 r1 = _rnd(string(abi.encodePacked("r1", Strings.toString(_tokenID))));
    uint256 r2 = _rnd(string(abi.encodePacked("r2", Strings.toString(_tokenID))));

    string memory char = _characters[_tokenID];

    bytes memory out = abi.encodePacked(
      SVG_HEAD,
      GRADIENT_PROPS_1,
      Strings.toString(r1 % 100),
      GRADIENT_PROPS_2,
      Strings.toString(r2 % 100),
      GRADIENT_PROPS_3,
      GRADIENT_PROPS_4,
      "0"
    );
    out = abi.encodePacked(
      out,
      GRADIENT_PROPS_5,
      colors[r1 % colors.length],
      GRADIENT_PROPS_6,
      GRADIENT_PROPS_4,
      "75",
      GRADIENT_PROPS_5,
      colors[(r1 + 1) % colors.length],
      GRADIENT_PROPS_6
    );
    out = abi.encodePacked(
      out,
      GRADIENT_PROPS_4,
      "90",
      GRADIENT_PROPS_5,
      colors[(r1 + 2) % colors.length],
      GRADIENT_PROPS_6,
      GRADIENT_PROPS_4,
      "100",
      GRADIENT_PROPS_5
    );
    out = abi.encodePacked(
      out,
      colors[(r1 + 3) % colors.length],
      GRADIENT_PROPS_6,
      GRADIENT_PROPS_7,
      TEXT_HEAD_1,
      _darkMode ? "000" : "fff",
      TEXT_HEAD_2,
      char,
      TEXT_TAIL
    );
    out = abi.encodePacked(
      out,
      TEXT_HEAD_3,
      _darkMode ? "fff" : "000",
      TEXT_HEAD_4,
      char,
      TEXT_TAIL,
      SVG_TAIL
    );

    return string(abi.encodePacked("data:image/svg+xml;base64,",Base64.encode(bytes(out))));
  }
// Solidity 0.8.7
/**
 * Get Hour
 *
 * Internal dynamic rendering utility.
 */
function _getHour(uint _tokenID) private view returns (uint) {
    int offset = _timezoneOffset[_tokenID];
    int hour = (int(BokkyPooBahsDateTimeLibrary.getHour(block.timestamp)) + offset) % 24;

    return hour < 0 ? uint(hour + 24) : uint(hour);
  }