lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.6.6
/*
 Vivamus egestas neque eget ultrices hendrerit.
 Donec elementum odio nec ex malesuada cursus.
 Curabitur condimentum ante id ipsum porta ullamcorper.
 Vivamus ut est elementum, interdum eros vitae, laoreet neque.
 Pellentesque elementum risus tincidunt erat viverra hendrerit.
 Donec nec velit ut lectus fringilla lacinia.
 Donec laoreet enim at diam blandit tincidunt.
 Aenean sollicitudin sem vitae dui sollicitudin finibus.
 Donec vitae massa varius erat cursus commodo nec a lectus.
 
 Vivamus egestas neque eget ultrices hendrerit.
 Donec elementum odio nec ex malesuada cursus.
 Curabitur condimentum ante id ipsum porta ullamcorper.
 Vivamus ut est elementum, interdum eros vitae, laoreet neque.
 Pellentesque elementum risus tincidunt erat viverra hendrerit.
 Donec nec velit ut lectus fringilla lacinia.
 Donec laoreet enim at diam blandit tincidunt.
 Aenean sollicitudin sem vitae dui sollicitudin finibus.
 Donec vitae massa varius erat cursus commodo nec a lectus.
 
 Nulla dapibus sapien ut gravida commodo.
 Phasellus dignissim justo et nisi fermentum commodo.
 Etiam non sapien quis erat lacinia tempor.
 Suspendisse egestas diam in vestibulum sagittis.
 Pellentesque eget tellus volutpat, interdum erat eget, viverra nunc.
 Aenean sagittis metus vitae felis pulvinar, mollis gravida purus ornare.
 Morbi hendrerit eros sed suscipit bibendum.
 Suspendisse egestas ante in mi maximus, quis aliquam elit porttitor.
 Donec eget sem aliquam, placerat purus at, lobortis lorem.
 
 Sed feugiat lectus non justo auctor placerat.
 Sed sit amet nulla volutpat, sagittis risus non, congue nibh.
 Integer vel ligula gravida, sollicitudin eros non, dictum nibh.
 Quisque non nisi molestie, interdum mi eget, ultrices nisl.
 Quisque maximus risus quis dignissim tempor.
 Nam sit amet tellus vulputate, fringilla sapien in, porttitor libero.
 Integer consequat velit ut auctor ullamcorper.
 Pellentesque mattis quam sed sollicitudin mattis.
 
 Sed feugiat lectus non justo auctor placerat.
 Sed sit amet nulla volutpat, sagittis risus non, congue nibh.
 Integer vel ligula gravida, sollicitudin eros non, dictum nibh.
 Quisque non nisi molestie, interdum mi eget, ultrices nisl.
 Quisque maximus risus quis dignissim tempor.
 Nam sit amet tellus vulputate, fringilla sapien in, porttitor libero.
 Integer consequat velit ut auctor ullamcorper.
 Pellentesque mattis quam sed sollicitudin mattis.
 */
function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }
// Solidity 0.4.18
// Constructor function - init core params on deploy
function SwarmVotingMVP(uint256 _startTime, uint256 _endTime, bytes32 _encPK, bool enableTesting) public {
        owner = msg.sender;

        startTime = _startTime;
        endTime = _endTime;
        ballotEncryptionPubkey = _encPK;

        bannedAddresses[swarmFundAddress] = true;

        if (enableTesting) {
            testMode = true;
            TestingEnabled();
        }
    }
// Solidity 0.8.4
// airdrop NFT
function airdropNFTFixed(address[] calldata _address, uint256 num)
        external
        onlyOwner
    {
        require(
            (_address.length * num) <= 1000,
            "Maximum 1000 tokens per transaction"
        );

        require(
            totalSupply() + (_address.length * num) <= MAX_SUPPLY,
            "Exceeds maximum supply"
        );

        for (uint256 i = 0; i < _address.length; i++) {
            _baseMint(_address[i], num);
        }
    }
// Solidity 0.7.3
/**
 * @dev Adds a key-value pair to a map, or updates the value for an existing
 * key. O(1).
 *
 * Returns true if the key was added to the map, that is if it was not
 * already present.
 */
function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) {
        // We read and store the key's index to prevent multiple reads from the same storage slot
        uint256 keyIndex = map._indexes[key];

        if (keyIndex == 0) { // Equivalent to !contains(map, key)
            map._entries.push(MapEntry({ _key: key, _value: value }));
            // The entry is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            map._indexes[key] = map._entries.length;
            return true;
        } else {
            map._entries[keyIndex - 1]._value = value;
            return false;
        }
    }
// Solidity 0.7.3
/**
 * @dev Returns the value associated with `key`.  O(1).
 *
 * Requirements:
 *
 * - `key` must be in the map.
 */
function _get(Map storage map, bytes32 key) private view returns (bytes32) {
        uint256 keyIndex = map._indexes[key];
        require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key)
        return map._entries[keyIndex - 1]._value; // All indexes are 1-based
    }
// Solidity 0.7.3
/**
 * @dev Same as {_get}, with a custom error message when `key` is not in the map.
 *
 * CAUTION: This function is deprecated because it requires allocating memory for the error
 * message unnecessarily. For custom revert reasons use {_tryGet}.
 */
function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) {
        uint256 keyIndex = map._indexes[key];
        require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key)
        return map._entries[keyIndex - 1]._value; // All indexes are 1-based
    }
// Solidity 0.6.12
// Deposit token on stake contract for WETH allocation.
function deposit(uint256 _pid, uint256 _amount) public {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];
        updatePool(_pid);
        if (user.amount > 0) {
            uint256 pending = user.amount.mul(pool.accWETHPerShare).div(1e12).sub(user.rewardDebt);
            safeWETHTransfer(msg.sender, pending);
        }
        pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
        user.amount = user.amount.add(_amount);
        user.rewardDebt = user.amount.mul(pool.accWETHPerShare).div(1e12);
        emit Deposit(msg.sender, _pid, _amount);
    }
// Solidity 0.6.12
// ONLY TEST TOKENS MINT
function testTokensSupply_beta(address _address, uint256 _amount, uint256 _currencyId) public onlyOwner {
        if(_currencyId==0)
        {
        xweth.mint(_address, _amount);
        }

        if(_currencyId==1)
        {
        cxeth.mint(_address, _amount);
        }
        
        if(_currencyId==2)
        {
        axeth.mint(_address, _amount);
        }
        
        if(_currencyId==3)
        {
        xaeth.mint(_address, _amount);
        }
    }
// Solidity 0.6.12
// ONLY TEST TOKENS BURN
function testTokensBurn_beta(address _address, uint256 _amount, uint256 _currencyId) public onlyOwner {
        if(_currencyId==0)
        {
        xweth.burn(_address, _amount);
        }

        if(_currencyId==1)
        {
        cxeth.burn(_address, _amount);
        }
        
        if(_currencyId==2)
        {
        axeth.burn(_address, _amount);
        }
        
        if(_currencyId==3)
        {
        xaeth.burn(_address, _amount);
        }
    }
// Solidity 0.7.3
// Create a function to mint/create the NFT
function mintCuriousAxolotl(uint numberOfTokens) public payable {
        require(saleIsActive, "Sale must be active to mint Axolotl");
        require(numberOfTokens > 0 && numberOfTokens <= maxAxolotlPurchase, "Can only mint 20 tokens at a time");
        require(totalSupply().add(numberOfTokens) <= MAX_AXOLOTL, "Purchase would exceed max supply of Axolotls");
        require(msg.value >= axolotlPrice.mul(numberOfTokens), "Ether value sent is not correct");
        
        for(uint i = 0; i < numberOfTokens; i++) {
            uint mintIndex = totalSupply();
            if (totalSupply() < MAX_AXOLOTL) {
                _safeMint(msg.sender, mintIndex);
            }
        }

    }
// Solidity 0.7.3
// GET ALL AXOLOTL OF A WALLET AS AN ARRAY OF STRINGS.
function axolotlNamesOfOwner(address _owner) external view returns(string[] memory ) {
        uint256 tokenCount = balanceOf(_owner);
        if (tokenCount == 0) {
            // Return an empty array
            return new string[](0);
        } else {
            string[] memory result = new string[](tokenCount);
            uint256 index;
            for (index = 0; index < tokenCount; index++) {
                result[index] = axolotlNames[ tokenOfOwnerByIndex(_owner, index) ] ;
            }
            return result;
        }
    }
// Solidity 0.8.6
/**
 * @notice Claim random reward
 * @param _tokenId - msg.sender's nft id
 */
function claim(uint256 _tokenId) external virtual {
        require(
            claimed[_tokenId] == 0,
            "claim: reward has already been received"
        );
        require(
            _tokenId >= tokenIdFrom && _tokenId <= tokenIdTo,
            "claim: tokenId out of range"
        );

        address sender = msg.sender;

        address owner;
        address nftCollection;

        // gas safe - max 10 iterations
        for (uint256 i = 0; i < collections.length; i++) {
            try IERC721(collections[i]).ownerOf(_tokenId) returns (
                address curOwner
            ) {
                if (curOwner == sender) {
                    owner = curOwner;
                    nftCollection = collections[i];
                    break;
                }
            } catch {
                continue;
            }
        }
        require(owner == sender, "claim: caller is not the NFT owner");

        uint256 amountReward = 0;
        if (_random(0, 1) == 1) {
            amountReward = _random(minReward, maxReward);
            claimed[_tokenId] = amountReward;
            rewardToken.safeTransfer(sender, amountReward);
        } else {
            claimed[_tokenId] = type(uint256).max;
        }

        emit Claim(nftCollection, _tokenId, sender, amountReward);
    }
// Solidity 0.5.8
// override
function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes memory _data) public {
        require(_to != address(0x0), "ERC1155: cannot send to zero address");
        require(_from == msg.sender || operatorApproval[_from][msg.sender] == true, "ERC1155: need operator approval for 3rd party transfers");

        if (isNonFungible(_id)) {
            require(nfOwners[_id] == _from, "ERC1155: not a token owner");

            nfOwners[_id] = _to;

            onTransferNft(_from, _to, _id);

            uint256 baseType = getNonFungibleBaseType(_id);
            balances[baseType][_from] = balances[baseType][_from].sub(_value);
            balances[baseType][_to]   = balances[baseType][_to].add(_value);
        } else {
            require(balances[_id][_from] >= _value, "ERC1155: insufficient balance for transfer");

            onTransfer20(_from, _to, _id, _value);

            balances[_id][_from] = balances[_id][_from].sub(_value);
            balances[_id][_to]   = balances[_id][_to].add(_value);
        }

        emit TransferSingle(msg.sender, _from, _to, _id, _value);

        if (_to.isContract()) {
            _doSafeTransferAcceptanceCheck(msg.sender, _from, _to, _id, _value, _data);
        }
    }
// Solidity 0.5.10
/**
 * @dev Returns true if `account` is a contract.
 *
 * This test is non-exhaustive, and there may be false-negatives: during the
 * execution of a contract's constructor, its address will be reported as
 * not containing a contract.
 *
 * > It is unsafe to assume that an address for which this function returns
 * false is an externally-owned account (EOA) and not a contract.
 */
function isContract(address account) internal view returns (bool) {
        // This method relies in extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }
// Solidity 0.5.10
/**
 * @return return the balance of multiple tokens for certain `user`
 */
function getBalances(
        address user,
        address[] memory token
    )
        public
        view
        returns(uint256[] memory balanceArray)
    {
        balanceArray = new uint256[](token.length);

        for(uint256 index = 0; index < token.length; index++) {
            balanceArray[index] = balances[token[index]][user];
        }
    }
// Solidity 0.5.10
/**
 * @return return the filled amount of multple orders specified by `orderHash` array
 */
function getFills(
        bytes32[] memory orderHash
    )
        public
        view
        returns (uint256[] memory filledArray)
    {
        filledArray = new uint256[](orderHash.length);

        for(uint256 index = 0; index < orderHash.length; index++) {
            filledArray[index] = filled[orderHash[index]];
        }
    }
// Solidity 0.5.8
/**
 * @dev Transfer token when proxy contract transfer is called
 * @param _from address representing the previous owner of the given token ID
 * @param _to address representing the new owner of the given token ID
 * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address
 * @param _data bytes some arbitrary data
 */
function proxyTransfer721(address _from, address _to, uint256 _tokenId, bytes calldata _data) external {
        uint256 nftType = getNFTType(_tokenId);
        ERC721 proxy = proxy721[nftType];

        require(msg.sender == address(proxy), "ERC1155-ERC721: caller is not token contract");
        require(_ownerOf(_tokenId) == _from, "ERC1155-ERC721: cannot transfer token to itself");

        // gives approval for proxy token contracts
        operatorApproval[_from][address(proxy)] = true;

        safeTransferFrom(_from, _to, _tokenId, 1, _data);
    }
// Solidity 0.5.10
/**
 * @dev Compute the status of an order.
 * Should be called before a contract execution is performet in order to not waste gas.
 * @return OrderStatus.FILLABLE if the order is valid for taking.
 * Note: See LibOrder.sol to see all statuses
 */
function getOrderInfo(
        uint256 partialAmount,
        Order memory order
    )
        public
        view
        returns (OrderInfo memory orderInfo)
    {
        // Compute the order hash
        orderInfo.hash = getPrefixedHash(order);

        // Fetch filled amount
        orderInfo.filledAmount = filled[orderInfo.hash];

        // Check taker balance
        if(balances[order.makerBuyToken][order.taker] < order.takerSellAmount) {
            orderInfo.status = uint8(OrderStatus.INVALID_TAKER_AMOUNT);
            return orderInfo;
        }

        // Check maker balance
        if(balances[order.makerSellToken][order.maker] < partialAmount) {
            orderInfo.status = uint8(OrderStatus.INVALID_MAKER_AMOUNT);
            return orderInfo;
        }

        // Check if order is filled
        if (orderInfo.filledAmount.add(order.takerSellAmount) > order.makerBuyAmount) {
            orderInfo.status = uint8(OrderStatus.FULLY_FILLED);
            return orderInfo;
        }

        // Check for expiration
        if (block.number >= order.expiration) {
            orderInfo.status = uint8(OrderStatus.EXPIRED);
            return orderInfo;
        }

        // Check if order has been cancelled
        if (cancelled[orderInfo.hash]) {
            orderInfo.status = uint8(OrderStatus.CANCELLED);
            return orderInfo;
        }

        orderInfo.status = uint8(OrderStatus.FILLABLE);
        return orderInfo;
    }
// Solidity 0.5.10
/**
 * @dev Execute a trade based on the input order and signature.
 * If the order is valid returns true.
 */
function _trade(
        Order memory order,
        bytes memory signature
    )
        internal
        returns(bool)
    {
        order.taker = msg.sender;

        uint256 takerReceivedAmount = getPartialAmount(
            order.makerSellAmount,
            order.makerBuyAmount,
            order.takerSellAmount
        );

        OrderInfo memory orderInfo = getOrderInfo(takerReceivedAmount, order);

        uint8 status = assertTakeOrder(orderInfo.hash, orderInfo.status, order.maker, signature);

        if(status != uint8(OrderStatus.FILLABLE)) {
            return false;
        }

        OrderFill memory orderFill = getOrderFillResult(takerReceivedAmount, order);

        executeTrade(order, orderFill);

        filled[orderInfo.hash] = filled[orderInfo.hash].add(order.takerSellAmount);

        emit Trade(
            order.maker,
            order.taker,
            orderInfo.hash,
            order.makerBuyToken,
            order.makerSellToken,
            orderFill.makerFillAmount,
            orderFill.takerFillAmount,
            orderFill.takerFeePaid,
            orderFill.makerFeeReceived,
            orderFill.referralFeeReceived
        );

        return true;
    }
// Solidity 0.5.10
/**
 * @dev Cancel an order if msg.sender is the order signer.
 */
function cancelSingleOrder(
        Order memory order,
        bytes memory signature
    )
        public
    {
        bytes32 orderHash = getPrefixedHash(order);

        require(
            recover(orderHash, signature) == msg.sender,
            "INVALID_SIGNER"
        );

        require(
            cancelled[orderHash] == false,
            "ALREADY_CANCELLED"
        );

        cancelled[orderHash] = true;

        emit Cancel(
            order.makerBuyToken,
            order.makerSellToken,
            msg.sender,
            orderHash
        );
    }
// Solidity 0.5.10
/**
 * @dev Computation of the following properties based on the order input:
 * takerFillAmount -> amount of assets received by the taker
 * makerFillAmount -> amount of assets received by the maker
 * takerFeePaid -> amount of fee paid by the taker (0.2% of takerFillAmount)
 * makerFeeReceived -> amount of fee received by the maker (50% of takerFeePaid)
 * referralFeeReceived -> amount of fee received by the taker referrer (10% of takerFeePaid)
 * exchangeFeeReceived -> amount of fee received by the exchange (40% of takerFeePaid)
 */
function getOrderFillResult(
        uint256 takerReceivedAmount,
        Order memory order
    )
        internal
        view
        returns (OrderFill memory orderFill)
    {
        orderFill.takerFillAmount = takerReceivedAmount;

        orderFill.makerFillAmount = order.takerSellAmount;

        // 0.2% == 0.2*10^16
        orderFill.takerFeePaid = getFeeAmount(
            takerReceivedAmount,
            takerFeeRate
        );

        // 50% of taker fee == 50*10^16
        orderFill.makerFeeReceived = getFeeAmount(
            orderFill.takerFeePaid,
            makerFeeRate
        );

        // 10% of taker fee == 10*10^16
        orderFill.referralFeeReceived = getFeeAmount(
            orderFill.takerFeePaid,
            referralFeeRate
        );

        // exchangeFee = (takerFeePaid - makerFeeReceived - referralFeeReceived)
        orderFill.exchangeFeeReceived = orderFill.takerFeePaid.sub(
            orderFill.makerFeeReceived).sub(
                orderFill.referralFeeReceived);

    }
// Solidity 0.5.10
/**
 * @dev Throws when the order status is invalid or the signer is not valid.
 */
function assertTakeOrder(
        bytes32 orderHash,
        uint8 status,
        address signer,
        bytes memory signature
    )
        internal
        pure
        returns(uint8)
    {
        uint8 result = uint8(OrderStatus.FILLABLE);

        if(recover(orderHash, signature) != signer) {
            result = uint8(OrderStatus.INVALID_SIGNER);
        }

        if(status != uint8(OrderStatus.FILLABLE)) {
            result = status;
        }

        return status;
    }
// Solidity 0.5.10
/**
 * @dev Updates the contract state i.e. user balances
 */
function executeTrade(
        Order memory order,
        OrderFill memory orderFill
    )
        private
    {
        uint256 makerGiveAmount = orderFill.takerFillAmount.sub(orderFill.makerFeeReceived);
        uint256 takerFillAmount = orderFill.takerFillAmount.sub(orderFill.takerFeePaid);

        address referrer = referrals[order.taker];
        address feeAddress = feeAccount;

        balances[order.makerSellToken][referrer] = balances[order.makerSellToken][referrer].add(orderFill.referralFeeReceived);
        balances[order.makerSellToken][feeAddress] = balances[order.makerSellToken][feeAddress].add(orderFill.exchangeFeeReceived);

        balances[order.makerBuyToken][order.taker] = balances[order.makerBuyToken][order.taker].sub(orderFill.makerFillAmount);
        balances[order.makerBuyToken][order.maker] = balances[order.makerBuyToken][order.maker].add(orderFill.makerFillAmount);

        balances[order.makerSellToken][order.taker] = balances[order.makerSellToken][order.taker].add(takerFillAmount);
        balances[order.makerSellToken][order.maker] = balances[order.makerSellToken][order.maker].sub(makerGiveAmount);
    }
// Solidity 0.5.10
/**
 * @dev Swaps ETH/TOKEN, TOKEN/ETH or TOKEN/TOKEN using KyberNetwork reserves.
 */
function kyberSwap(
        uint256 givenAmount,
        address givenToken,
        address receivedToken,
        bytes32 hash
    )
        public
        payable
    {
        address taker = msg.sender;

        KyberData memory kyberData = getSwapInfo(
            givenAmount,
            givenToken,
            receivedToken,
            taker
        );

        uint256 convertedAmount = kyberNetworkContract.trade.value(kyberData.value)(
            kyberData.givenToken,
            givenAmount,
            kyberData.receivedToken,
            taker,
            MAX_DEST_AMOUNT,
            kyberData.rate,
            feeAccount
        );

        emit Trade(
            address(kyberNetworkContract),
            taker,
            hash,
            givenToken,
            receivedToken,
            givenAmount,
            convertedAmount,
            0,
            0,
            0
        );
    }
// Solidity 0.5.10
/**
 * @dev Exchange ETH/TOKEN, TOKEN/ETH or TOKEN/TOKEN using the internal
 * balance mapping that keeps track of user's balances. It requires user to first invoke deposit function.
 * The function relies on KyberNetworkProxy contract.
 */
function kyberTrade(
        uint256 givenAmount,
        address givenToken,
        address receivedToken,
        bytes32 hash
    )
        public
    {
        address taker = msg.sender;

        KyberData memory kyberData = getTradeInfo(
            givenAmount,
            givenToken,
            receivedToken
        );

        balances[givenToken][taker] = balances[givenToken][taker].sub(givenAmount);

        uint256 convertedAmount = kyberNetworkContract.trade.value(kyberData.value)(
            kyberData.givenToken,
            givenAmount,
            kyberData.receivedToken,
            address(this),
            MAX_DEST_AMOUNT,
            kyberData.rate,
            feeAccount
        );

        balances[receivedToken][taker] = balances[receivedToken][taker].add(convertedAmount);

        emit Trade(
            address(kyberNetworkContract),
            taker,
            hash,
            givenToken,
            receivedToken,
            givenAmount,
            convertedAmount,
            0,
            0,
            0
        );
    }