lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.8.11
// public minting
function mint(uint256 _mintAmount) public payable nonReentrant{
	uint256 s = totalSupply();
	require(status, "Off" );
	require(_mintAmount > 0, "0" );
	require(_mintAmount <= maxMint, "Too many" );
	require(s + _mintAmount <= maxSupply, "Max" );
	require(msg.value >= cost * _mintAmount);
	for (uint256 i = 0; i < _mintAmount; ++i) {
	_safeMint(msg.sender, s + i, "");
	}
	delete s;
	}
// Solidity 0.8.11
// admin minting
function adminMint(address[] calldata recipient) external onlyOwner{
	uint256 s = totalSupply();
	require(s + recipient.length <= maxSupply, "Too many" );
	for(uint i = 0; i < recipient.length; ++i){
	_safeMint(recipient[i], s++, "" );
	}
	delete s;	
	}
// Solidity 0.4.13
// Allows the developer to set the crowdsale and token addresses.
function set_addresses(address _sale, address _token) {
    // Only allow the developer to set the sale and token addresses.
    require(msg.sender == developer);
    // Only allow setting the addresses once.
    // Set the crowdsale and token addresses.
    sale = _sale;
    token = ERC20(_token);
  }
// Solidity 0.8.9
/// @inheritdoc     IERC721BulkTransfer
function transfer(
        address collection,
        address recipient,
        uint256[] calldata tokenIds
    ) external {
        require(tokenIds.length > 0, "Invalid token ids amount");

        for (uint256 i = 0; i < tokenIds.length; i++) {
            uint256 tokenId = tokenIds[i];
            IERC721(collection).transferFrom(msg.sender, recipient, tokenId);
        }
    }
// Solidity 0.4.24
/**
 * @dev Executes a relayed transaction.
 * @param _wallet The target wallet.
 * @param _data The data for the relayed transaction
 * @param _nonce The nonce used to prevent replay attacks.
 * @param _signatures The signatures as a concatenated byte array.
 * @param _gasPrice The gas price to use for the gas refund.
 * @param _gasLimit The gas limit to use for the gas refund.
 */
function execute(
        BaseWallet _wallet,
        bytes _data, 
        uint256 _nonce, 
        bytes _signatures, 
        uint256 _gasPrice,
        uint256 _gasLimit
    )
        external
        returns (bool success)
    {
        uint startGas = gasleft();
        bytes32 signHash = getSignHash(address(this), _wallet, 0, _data, _nonce, _gasPrice, _gasLimit);
        require(checkAndUpdateUniqueness(_wallet, _nonce, signHash), "RM: Duplicate request");
        require(verifyData(address(_wallet), _data), "RM: the wallet authorized is different then the target of the relayed data");
        uint256 requiredSignatures = getRequiredSignatures(_wallet, _data);
        if((requiredSignatures * 65) == _signatures.length) {
            if(verifyRefund(_wallet, _gasLimit, _gasPrice, requiredSignatures)) {
                if(requiredSignatures == 0 || validateSignatures(_wallet, _data, signHash, _signatures)) {
                    // solium-disable-next-line security/no-call-value
                    success = address(this).call(_data);
                    refund(_wallet, startGas - gasleft(), _gasPrice, _gasLimit, requiredSignatures, msg.sender);
                }
            }
        }
        emit TransactionExecuted(_wallet, success, signHash); 
    }
// Solidity 0.4.24
/**
 * @dev Generates the signed hash of a relayed transaction according to ERC 1077.
 * @param _from The starting address for the relayed transaction (should be the module)
 * @param _to The destination address for the relayed transaction (should be the wallet)
 * @param _value The value for the relayed transaction
 * @param _data The data for the relayed transaction
 * @param _nonce The nonce used to prevent replay attacks.
 * @param _gasPrice The gas price to use for the gas refund.
 * @param _gasLimit The gas limit to use for the gas refund.
 */
function getSignHash(
        address _from,
        address _to, 
        uint256 _value, 
        bytes _data, 
        uint256 _nonce,
        uint256 _gasPrice,
        uint256 _gasLimit
    ) 
        internal 
        pure
        returns (bytes32) 
    {
        return keccak256(
            abi.encodePacked(
                "\x19Ethereum Signed Message:\n32",
                keccak256(abi.encodePacked(byte(0x19), byte(0), _from, _to, _value, _data, _nonce, _gasPrice, _gasLimit))
        ));
    }
// Solidity 0.4.24
/**
 * @dev Checks that a nonce has the correct format and is valid. 
 * It must be constructed as nonce = {block number}{timestamp} where each component is 16 bytes.
 * @param _wallet The target wallet.
 * @param _nonce The nonce
 */
function checkAndUpdateNonce(BaseWallet _wallet, uint256 _nonce) internal returns (bool) {
        if(_nonce <= relayer[_wallet].nonce) {
            return false;
        }   
        uint256 nonceBlock = (_nonce & 0xffffffffffffffffffffffffffffffff00000000000000000000000000000000) >> 128;
        if(nonceBlock > block.number + BLOCKBOUND) {
            return false;
        }
        relayer[_wallet].nonce = _nonce;
        return true;    
    }
// Solidity 0.4.24
/**
 * @dev Recovers the signer at a given position from a list of concatenated signatures.
 * @param _signedHash The signed hash
 * @param _signatures The concatenated signatures.
 * @param _index The index of the signature to recover.
 */
function recoverSigner(bytes32 _signedHash, bytes _signatures, uint _index) internal pure returns (address) {
        uint8 v;
        bytes32 r;
        bytes32 s;
        // we jump 32 (0x20) as the first slot of bytes contains the length
        // we jump 65 (0x41) per signature
        // for v we load 32 bytes ending with v (the first 31 come from s) then apply a mask
        // solium-disable-next-line security/no-inline-assembly
        assembly {
            r := mload(add(_signatures, add(0x20,mul(0x41,_index))))
            s := mload(add(_signatures, add(0x40,mul(0x41,_index))))
            v := and(mload(add(_signatures, add(0x41,mul(0x41,_index)))), 0xff)
        }
        require(v == 27 || v == 28); 
        return ecrecover(_signedHash, v, r, s);
    }
// Solidity 0.4.24
/**
 * @dev Refunds the gas used to the Relayer. 
 * For security reasons the default behavior is to not refund calls with 0 or 1 signatures. 
 * @param _wallet The target wallet.
 * @param _gasUsed The gas used.
 * @param _gasPrice The gas price for the refund.
 * @param _gasLimit The gas limit for the refund.
 * @param _signatures The number of signatures used in the call.
 * @param _relayer The address of the Relayer.
 */
function refund(BaseWallet _wallet, uint _gasUsed, uint _gasPrice, uint _gasLimit, uint _signatures, address _relayer) internal {
        uint256 amount = 29292 + _gasUsed; // 21000 (transaction) + 7620 (execution of refund) + 672 to log the event + _gasUsed
        // only refund if gas price not null, more than 1 signatures, gas less than gasLimit
        if(_gasPrice > 0 && _signatures > 1 && amount <= _gasLimit) {
            if(_gasPrice > tx.gasprice) {
                amount = amount * tx.gasprice;
            }
            else {
                amount = amount * _gasPrice;
            }
            _wallet.invoke(_relayer, amount, "");
        }
    }
// Solidity 0.4.24
/**
 * @dev Returns false if the refund is expected to fail.
 * @param _wallet The target wallet.
 * @param _gasUsed The expected gas used.
 * @param _gasPrice The expected gas price for the refund.
 */
function verifyRefund(BaseWallet _wallet, uint _gasUsed, uint _gasPrice, uint _signatures) internal view returns (bool) {
        if(_gasPrice > 0 
            && _signatures > 1 
            && (address(_wallet).balance < _gasUsed * _gasPrice || _wallet.authorised(this) == false)) {
            return false;
        }
        return true;
    }
// Solidity 0.4.24
/**
 * @dev Checks that the wallet address provided as the first parameter of the relayed data is the same
 * as the wallet passed as the input of the execute() method. 
 @return false if the addresses are different.
 */
function verifyData(address _wallet, bytes _data) private pure returns (bool) {
        require(_data.length >= 36, "RM: Invalid dataWallet");
        address dataWallet;
        // solium-disable-next-line security/no-inline-assembly
        assembly {
            //_data = {length:32}{sig:4}{_wallet:32}{...}
            dataWallet := mload(add(_data, 0x24))
        }
        return dataWallet == _wallet;
    }
// Solidity 0.4.24
/**
 * @dev Lets an authorised module revoke a guardian from a wallet.
 * @param _wallet The target wallet.
 * @param _guardian The guardian to revoke.
 */
function revokeGuardian(BaseWallet _wallet, address _guardian) external onlyModule(_wallet) {
        GuardianStorageConfig storage config = configs[_wallet];
        address lastGuardian = config.guardians[config.guardians.length - 1];
        if (_guardian != lastGuardian) {
            uint128 targetIndex = config.info[_guardian].index;
            config.guardians[targetIndex] = lastGuardian;
            config.info[lastGuardian].index = targetIndex;
        }
        config.guardians.length--;
        delete config.info[_guardian];
    }
// Solidity 0.4.24
/**
 * @dev Gets the list of guaridans for a wallet.
 * @param _wallet The target wallet.
 * @return the list of guardians.
 */
function getGuardians(BaseWallet _wallet) external view returns (address[]) {
        GuardianStorageConfig storage config = configs[_wallet];
        address[] memory guardians = new address[](config.guardians.length);
        for (uint256 i = 0; i < config.guardians.length; i++) {
            guardians[i] = config.guardians[i];
        }
        return guardians;
    }
// Solidity 0.4.24
/**
 * @dev Checks if an address is an account guardian or an account authorised to sign on behalf of a smart-contract guardian
 * given a list of guardians.
 * @param _guardians the list of guardians
 * @param _guardian the address to test
 * @return true and the list of guardians minus the found guardian upon success, false and the original list of guardians if not found.
 */
function isGuardian(address[] _guardians, address _guardian) internal view returns (bool, address[]) {
        if(_guardians.length == 0 || _guardian == address(0)) {
            return (false, _guardians);
        }
        bool isFound = false;
        address[] memory updatedGuardians = new address[](_guardians.length - 1);
        uint256 index = 0;
        for (uint256 i = 0; i < _guardians.length; i++) {
            if(!isFound) {
                // check if _guardian is an account guardian
                if(_guardian == _guardians[i]) {
                    isFound = true;
                    continue;
                }
                // check if _guardian is the owner of a smart contract guardian
                if(isContract(_guardians[i]) && isGuardianOwner(_guardians[i], _guardian)) {
                    isFound = true;
                    continue;
                }
            }
            if(index < updatedGuardians.length) {
                updatedGuardians[index] = _guardians[i];
                index++;
            }
        }
        return isFound ? (true, updatedGuardians) : (false, _guardians);
    }
// Solidity 0.4.24
/**
 * @dev Checks if an address is the owner of a guardian contract. 
 * The method does not revert if the call to the owner() method consumes more then 5000 gas. 
 * @param _guardian The guardian contract
 * @param _owner The owner to verify.
 */
function isGuardianOwner(address _guardian, address _owner) internal view returns (bool) {
        address owner = address(0);
        bytes4 sig = bytes4(keccak256("owner()"));
        // solium-disable-next-line security/no-inline-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr,sig)
            let result := staticcall(5000, _guardian, ptr, 0x20, ptr, 0x20)
            if eq(result, 1) {
                owner := mload(ptr)
            }
        }
        return owner == _owner;
    }
// Solidity 0.4.24
/**
 * @dev transfers tokens (ETH or ERC20) from a wallet.
 * @param _wallet The target wallet.
 * @param _token The address of the token to transfer.
 * @param _to The destination address
 * @param _amount The amoutnof token to transfer
 * @param _data  The data for the transaction (only for ETH transfers)
 */
function transferToken(
        BaseWallet _wallet, 
        address _token, 
        address _to, 
        uint256 _amount, 
        bytes _data
    ) 
        external 
        onlyExecute 
        onlyWhenUnlocked(_wallet) 
    {
        // eth transfer to whitelist
        if(_token == ETH_TOKEN) {
            _wallet.invoke(_to, _amount, _data);
            emit Transfer(_wallet, ETH_TOKEN, _amount, _to, _data);
        }
        // erc20 transfer to whitelist
        else {
            bytes memory methodData = abi.encodeWithSignature("transfer(address,uint256)", _to, _amount);
            _wallet.invoke(_token, 0, methodData);
            emit Transfer(_wallet, _token, _amount, _to, _data);
        }
    }
// Solidity 0.4.24
// *************** Implementation of RelayerModule methods ********************* //
function validateSignatures(BaseWallet _wallet, bytes _data, bytes32 _signHash, bytes _signatures) internal view returns (bool) {
        address lastSigner = address(0);
        address[] memory guardians = guardianStorage.getGuardians(_wallet);
        bool isGuardian = false;
        for (uint8 i = 0; i < _signatures.length / 65; i++) {
            address signer = recoverSigner(_signHash, _signatures, i);
            if(i == 0) {
                // AT: first signer must be owner
                if(!isOwner(_wallet, signer)) { 
                    return false;
                }
            }
            else {
                // "AT: signers must be different"
                if(signer <= lastSigner) { 
                    return false;
                }
                lastSigner = signer;
                (isGuardian, guardians) = GuardianUtils.isGuardian(guardians, signer);
                // "AT: signatures not valid"
                if(!isGuardian) { 
                    return false;
                }
            }
        }
        return true;
    }
// Solidity 0.4.23
/**
 * @dev Function to mint tokens, and lock some of them with a release time
 * @param _to The address that will receive the minted tokens.
 * @param _amount The amount of tokens to mint.
 * @param _lockedAmount The amount of tokens to be locked.
 * @param _releaseTime The timestamp about to release, which could be set just once.
 * @return A boolean that indicates if the operation was successful.
 */
function mintWithLock(address _to, uint256 _amount, uint256 _lockedAmount, uint256 _releaseTime) external returns (bool) {
        require(mintAgents[msg.sender] && totalSupply_.add(_amount) <= cap);
        require(_amount >= _lockedAmount);

        totalSupply_ = totalSupply_.add(_amount);
        balances[_to] = balances[_to].add(_amount);
        lockedBalanceMap[_to] = lockedBalanceMap[_to] > 0 ? lockedBalanceMap[_to].add(_lockedAmount) : _lockedAmount;
        releaseTimeMap[_to] = releaseTimeMap[_to] > 0 ? releaseTimeMap[_to] : _releaseTime;
        emit Mint(_to, _amount);
        emit Transfer(address(0), _to, _amount);
        emit BalanceLocked(_to, _lockedAmount);
        return true;
    }
// Solidity 0.6.12
// Update reward variables of the given pool to be up-to-date.
//function mint(uint256 amount) public onlyOwner{
//    bacon.mint(devaddr, amount);
//}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
        doHalvingCheck(false);
        PoolInfo storage pool = poolInfo[_pid];
        if (block.number <= pool.lastRewardBlock) {
            return;
        }
        uint256 lpSupply = pool.lpToken.balanceOf(address(this));
        if (lpSupply == 0) {
            pool.lastRewardBlock = block.number;
            return;
        }
        uint256 blockPassed = block.number.sub(pool.lastRewardBlock);
        uint256 baconReward = blockPassed
            .mul(baconPerBlock)
            .mul(pool.allocPoint)
            .div(totalAllocPoint);
        bacon.mint(devaddr, baconReward.div(20)); // 5%
        bacon.mint(address(this), baconReward);
        pool.accBaconPerShare = pool.accBaconPerShare.add(baconReward.mul(1e12).div(lpSupply));
        pool.lastRewardBlock = block.number;
    }
// Solidity 0.6.12
// Deposit LP tokens to MasterChef for BACON 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.accBaconPerShare).div(1e12).sub(user.rewardDebt);
            safeBaconTransfer(msg.sender, pending);
        }
        pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
        user.amount = user.amount.add(_amount);
        user.rewardDebt = user.amount.mul(pool.accBaconPerShare).div(1e12);
        emit Deposit(msg.sender, _pid, _amount);
    }
// Solidity 0.8.0
// swaps any combination of ERC-20/721/1155
// User needs to approve assets before invoking swap
function multiAssetSwap(
        ERC20Details memory inputERC20s,
        ERC721Details[] memory inputERC721s,
        ERC1155Details[] memory inputERC1155s,
        MarketRegistry.BuyDetails[] memory buyDetails,
        ExchangeRegistry.SwapDetails[] memory swapDetails,
        address[] memory addrs // [changeIn, exchange, recipient]
    ) payable external {
        address[] memory _erc20AddrsIn;
        uint256[] memory _erc20AmountsIn;
        
        // transfer all tokens
        (_erc20AddrsIn, _erc20AmountsIn) = _transferHelper(
            inputERC20s,
            inputERC721s,
            inputERC1155s
        );

        // execute all swaps
        _swap(
            swapDetails,
            buyDetails,
            _erc20AmountsIn,
            _erc20AddrsIn,
            addrs[0],
            addrs[1],
            addrs[2]
        );
    }
// Solidity 0.8.0
// Emergency function: In case any ERC1155 tokens get stuck in the contract unintentionally
// Only owner can retrieve the asset balance to a recipient address
function rescueERC1155(address asset, uint256[] calldata ids, uint256[] calldata amounts, address recipient) onlyOwner external {
        for (uint256 i = 0; i < ids.length; i++) {
            IERC1155(asset).safeTransferFrom(address(this), recipient, ids[i], amounts[i], "");
        }
    }
// Solidity 0.8.4
// user buy PASS from contract with specific erc20 tokens
function mint() public nonReentrant returns (uint256 tokenId) {
    require(address(erc20) != address(0), "FixPrice: erc20 address is null.");
    require((tokenIdTracker.current() <= maxSupply), "exceeds maximum supply");

    tokenId = tokenIdTracker.current(); // accumulate the token id

    IERC20Upgradeable(erc20).safeTransferFrom(
      _msgSender(),
      address(this),
      rate
    );

    if (platform != address(0)) {
      IERC20Upgradeable(erc20).safeTransfer(
        platform,
        (rate * platformRate) / 100
      );
    }

    _safeMint(_msgSender(), tokenId); // mint PASS to user address
    emit Mint(_msgSender(), tokenId);

    tokenIdTracker.increment(); // automate token id increment
  }
// Solidity 0.8.4
// withdraw erc20 tokens from contract
// anyone can withdraw reserve of erc20 tokens to receivingAddress
function withdraw() public nonReentrant {
    if (address(erc20) == address(0)) {
      emit Withdraw(receivingAddress, _getBalance());

      (bool success, ) = payable(receivingAddress).call{value: _getBalance()}(
        ""
      );
      require(success, "Failed to send Ether");
    } else {
      uint256 amount = IERC20Upgradeable(erc20).balanceOf(address(this)); // get the amount of erc20 tokens reserved in contract
      IERC20Upgradeable(erc20).safeTransfer(receivingAddress, amount); // transfer erc20 tokens to contract owner address

      emit Withdraw(receivingAddress, amount);
    }
  }
// Solidity 0.8.9
// -------------------------------------------------------- INTERNAL --------------------------------------------------------------------
function _requireValidPermit(
        address signer,
        address spender,
        uint256 id,
        uint256 deadline,
        uint256 nonce,
        bytes memory sig
    ) internal view {
        bytes32 digest = keccak256(
            abi.encodePacked(
                "\x19\x01",
                _DOMAIN_SEPARATOR(),
                keccak256(abi.encode(PERMIT_TYPEHASH, spender, id, nonce, deadline))
            )
        );
        require(SignatureChecker.isValidSignatureNow(signer, digest, sig), "INVALID_SIGNATURE");
    }
// Solidity 0.8.9
/// @dev Return the DOMAIN_SEPARATOR.
function _DOMAIN_SEPARATOR() internal view returns (bytes32) {
        uint256 chainId;
        //solhint-disable-next-line no-inline-assembly
        assembly {
            chainId := chainid()
        }

        // in case a fork happen, to support the chain that had to change its chainId,, we compute the domain operator
        return chainId == _deploymentChainId ? _deploymentDomainSeparator : _calculateDomainSeparator(chainId);
    }
// Solidity 0.4.18
/* Batch token transfer. Used by contract creator to distribute initial tokens to holders */
function batchTransfer(address[] _recipients, uint[] _values) onlyOwner returns (bool) {
        require( _recipients.length > 0 && _recipients.length == _values.length);

        uint total = 0;
        for(uint i = 0; i < _values.length; i++){
            total = total.add(_values[i]);
        }
        require(total <= balances[msg.sender]);

        uint64 _now = uint64(now);
        for(uint j = 0; j < _recipients.length; j++){
            balances[_recipients[j]] = balances[_recipients[j]].add(_values[j]);
            transferIns[_recipients[j]].push(transferInStruct(uint128(_values[j]),_now));
            Transfer(msg.sender, _recipients[j], _values[j]);
        }

        balances[msg.sender] = balances[msg.sender].sub(total);
        if(transferIns[msg.sender].length > 0) delete transferIns[msg.sender];
        if(balances[msg.sender] > 0) transferIns[msg.sender].push(transferInStruct(uint128(balances[msg.sender]),_now));

        return true;
    }
// Solidity 0.4.19
//*** Payable ***//
function() payable public {
        require(msg.value>0);
        require(msg.sender != 0x0);
        
        uint256 weiAmount;
        uint256 tokens;
        wallet=owner;
        
        if(isPreSale()){
            wallet=preSaleAddress;
            weiAmount=6000;
        }
        else if(isIco()){
            wallet=icoAddress;
            
            if((icoStart+(7*24*60*60)) >= now){
               weiAmount=4000;
            }
            else if((icoStart+(14*24*60*60)) >= now){
                 weiAmount=3750;
            }
            else if((icoStart+(21*24*60*60)) >= now){
                 weiAmount=3500;
            }
            else if((icoStart+(28*24*60*60)) >= now){
                 weiAmount=3250;
            }
            else if((icoStart+(35*24*60*60)) >= now){
                 weiAmount=3000;
            }
            else{
                weiAmount=2000;
            }
        }
        else{
            weiAmount=4000;
        }
        
        tokens=msg.value*weiAmount/1000000000000000000;
        Transfer(this, msg.sender, tokens);
        balanceOf[msg.sender]+=tokens;
        totalSupply=(totalSupply-tokens);
        wallet.transfer(msg.value);
        balanceOf[this]+=msg.value;
	}