lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.8.7
// transfer
function _transfer(address from_, address to_, uint256 tokenId_) internal virtual {
        require(from_ == ownerOf[tokenId_], "ERC721I: _transfer() Transfer Not Owner of Token!");
        require(to_ != address(0x0), "ERC721I: _transfer() Transfer to Zero Address!");

        // ERC721I Starts Here
        // checks if there is an approved address clears it if there is
        if (getApproved[tokenId_] != address(0x0)) { 
            _approve(address(0x0), tokenId_); 
        } 

        ownerOf[tokenId_] = to_; 
        balanceOf[from_]--;
        balanceOf[to_]++;
        // ERC721I Ends Here

        emit Transfer(from_, to_, tokenId_);
    }
// Solidity 0.8.7
// // Internal View Functions
// Embedded Libraries
function _toString(uint256 value_) internal pure returns (string memory) {
        if (value_ == 0) { return "0"; }
        uint256 _iterate = value_; uint256 _digits;
        while (_iterate != 0) { _digits++; _iterate /= 10; } // get digits in value_
        bytes memory _buffer = new bytes(_digits);
        while (value_ != 0) { _digits--; _buffer[_digits] = bytes1(uint8(48 + uint256(value_ % 10 ))); value_ /= 10; } // create bytes of value_
        return string(_buffer); // return string converted bytes of value_
    }
// Solidity 0.8.7
// Functional Views
function _isApprovedOrOwner(address spender_, uint256 tokenId_) internal view virtual returns (bool) {
        require(ownerOf[tokenId_] != address(0x0), "ERC721I: _isApprovedOrOwner() Owner is Zero Address!");
        address _owner = ownerOf[tokenId_];
        return (spender_ == _owner || spender_ == getApproved[tokenId_] || isApprovedForAll[_owner][spender_]);
    }
// Solidity 0.8.7
// // public write functions
function approve(address to_, uint256 tokenId_) public virtual {
        address _owner = ownerOf[tokenId_];
        require(to_ != _owner, "ERC721I: approve() Cannot approve yourself!");
        require(msg.sender == _owner || isApprovedForAll[_owner][msg.sender], "ERC721I: Caller not owner or Approved!");
        _approve(to_, tokenId_);
    }
// Solidity 0.8.7
// // public view functions
// never use these for functions ever, they are expensive af and for view only (this will be an issue in the future for interfaces)
function walletOfOwner(address address_) public virtual view returns (uint256[] memory) {
        uint256 _balance = balanceOf[address_];
        uint256[] memory _tokens = new uint256[] (_balance);
        uint256 _index;
        uint256 _loopThrough = totalSupply;
        for (uint256 i = 0; i < _loopThrough; i++) {
            if (ownerOf[i] == address(0x0) && _tokens[_balance - 1] == 0) { _loopThrough++; }
            if (ownerOf[i] == address_) { _tokens[_index] = i; _index++; }
        }
        return _tokens;
    }
// Solidity 0.8.7
// Governance Functions
function setPayableGovernanceShareholders(address payable[] memory addresses_, uint256[] memory shares_) public onlyPayableGovernanceSetter {
        require(_payableGovernanceAddresses.length == 0 && _payableGovernanceShares.length == 0, "Payable Governance already set! To set again, reset first!");
        require(addresses_.length == shares_.length, "Address and Shares length mismatch!");
        uint256 _totalShares;
        for (uint256 i = 0; i < addresses_.length; i++) {
            _totalShares += shares_[i];
            _payableGovernanceAddresses.push(addresses_[i]);
            _payableGovernanceShares.push(shares_[i]);
        }
        require(_totalShares == 1000, "Total Shares is not 1000!");
    }
// Solidity 0.8.7
// Withdraw Functions
function withdrawEther() public onlyOwner {
        // require that there has been payable governance set.
        require(_payableGovernanceAddresses.length > 0 && _payableGovernanceShares.length > 0, "Payable governance not set yet!");
         // this should never happen
        require(_payableGovernanceAddresses.length == _payableGovernanceShares.length, "Payable governance length mismatch!");
        
        // now, we check that the governance shares equal to 1000.
        uint256 _totalPayableShares;
        for (uint256 i = 0; i < _payableGovernanceShares.length; i++) {
            _totalPayableShares += _payableGovernanceShares[i]; }
        require(_totalPayableShares == 1000, "Payable Governance Shares is not 1000!");
        
        // // now, we start the withdrawal process if all conditionals pass
        // store current balance in local memory
        uint256 _totalETH = address(this).balance; 

        // withdraw loop for payable governance
        for (uint256 i = 0; i < _payableGovernanceAddresses.length; i++) {
            uint256 _ethToWithdraw = ((_totalETH * _payableGovernanceShares[i]) / 1000);
            _withdraw(_payableGovernanceAddresses[i], _ethToWithdraw);
        }
    }
// Solidity 0.8.7
// Internal Mint
function _mintMany(address to_, uint256 amount_) internal {
        require(maxTokens >= totalSupply + amount_,
            "Not enough tokens remaining!");

        uint256 _startId = totalSupply + 1; // iterate from 1

        for (uint256 i = 0; i < amount_; i++) {
            _mint(to_, _startId + i);
        }
        totalSupply += amount_;
    }
// Solidity 0.8.7
// Whitelist Mint Functions
function whitelistMint(bytes32[] calldata proof_, uint256 amount_) external payable 
    onlySender whitelistMintEnabled {
        require(isWhitelisted(msg.sender, proof_), 
            "You are not Whitelisted!");
        require(maxMintsPerWl >= addressToWlMints[msg.sender] + amount_,
            "Over Max Mints per TX or Not enough whitelist mints remaining for you!");
        require(msg.value == mintPrice * amount_,   
            "Invalid value sent!");
        
        // Add address to WL minted
        addressToWlMints[msg.sender] += amount_;

        _mintMany(msg.sender, amount_);
    }
// Solidity 0.4.24
// Allows a token holder to burn tokens. Once burned, tokens are permanently
// removed from the total supply.
function burn(uint256 _amount) public returns (bool success) {
        require(_amount > 0, 'Token amount to burn must be larger than 0');

        address account = msg.sender;
        require(_amount <= balanceOf(account), 'You cannot burn token you dont have');

        balances[account] = balances[account].sub(_amount);
        totalSupply = totalSupply.sub(_amount);
        return true;
    }
// Solidity 0.5.17
// Batch mint tokens. Assign directly to _to[].
function mint(uint256 _id, address[] calldata _to, uint256[] calldata _quantities) external creatorOnly(_id) {

        for (uint256 i = 0; i < _to.length; ++i) {

            address to = _to[i];
            uint256 quantity = _quantities[i];

            // Grant the items to the caller
            balances[_id][to] = quantity.add(balances[_id][to]);

            // Emit the Transfer/Mint event.
            // the 0x0 source address implies a mint
            // It will also provide the circulating supply info.
            emit TransferSingle(msg.sender, address(0x0), to, _id, quantity);

            if (to.isContract()) {
                _doSafeTransferAcceptanceCheck(msg.sender, msg.sender, to, _id, quantity, '');
            }
        }
    }
// Solidity 0.4.18
// Change the date and time: the beginning of the round, the end of the bonus, the end of the round. Available to Manager
// Description in the Crowdsale constructor
function changePeriod(uint256 _startTime, uint256 _endDiscountTime, uint256 _endTime) public{

        require(wallets[uint8(Roles.manager)] == msg.sender);

        require(!isInitialized);

        // Date and time are correct
        require(now <= _startTime);
        require(_endDiscountTime > _startTime && _endDiscountTime <= _endTime);

        startTime = _startTime;
        endTime = _endTime;
        endDiscountTime = _endDiscountTime;

    }
// Solidity 0.4.18
// Returns the percentage of the bonus on the given date. Constant.
function getProfitPercentForData(uint256 timeNow) public constant returns (uint256){
        // if the discount is 0 or zero steps, or the round does not start, we return the minimum discount
        if (profit.max == 0 || profit.step == 0 || timeNow > endDiscountTime){
            return profit.min;
        }

        // if the round is over - the maximum
        if (timeNow<=startTime){
            return profit.max;
        }

        // bonus period
        uint256 range = endDiscountTime.sub(startTime);

        // delta bonus percentage
        uint256 profitRange = profit.max.sub(profit.min);

        // Time left
        uint256 timeRest = endDiscountTime.sub(timeNow);

        // Divide the delta of time into
        uint256 profitProcent = profitRange.div(profit.step).mul(timeRest.mul(profit.step.add(1)).div(range));
        return profitProcent.add(profit.min);
    }
// Solidity 0.8.10
// function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
//     require(address(this).balance >= value, "Address: insufficient balance for call");
//     return _functionCallWithValue(target, data, value, errorMessage);
// }
function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }
// Solidity 0.4.18
// Checking whether the rights to address ignore the "Pause of exchange". If the
// wallet is included in this list, it can translate tokens, ignoring the pause. By default,
// only the following wallets are included:
//    - Accountant wallet (he should immediately transfer tokens, but not to non-ETH investors)
//    - Contract for freezing the tokens for the Team (but Team wallet not included)
// Inside. Constant.
function unpausedWallet(address _wallet) internal constant returns(bool) {
        bool _accountant = wallets[uint8(Roles.accountant)] == _wallet;
        bool _manager = wallets[uint8(Roles.manager)] == _wallet;
        bool _bounty = wallets[uint8(Roles.bounty)] == _wallet;
        bool _company = wallets[uint8(Roles.company)] == _wallet;
        return _accountant || _manager || _bounty || _company;
    }
// Solidity 0.8.7
// *********************************************************************************************
// Begin overrides to accomodate virtual owners information until owners are committed to state.
// *********************************************************************************************
function tokenURI(uint256 tokenId) public pure override(ERC721) returns (string memory) {
        // Since _owners starts empty but this contract represents 4012 NFTs, change the
        // exists check for tokenURI.
        require(0 < tokenId && tokenId < 4013, "Doesn't exist!");
        return string(abi.encodePacked("ipfs://QmSgeFjJWkUkGRMvGDZHGd52VTi1L8yjMMtQaBxXXaC9nV/", tokenId.toString(), ".json"));
    }
// Solidity 0.8.7
// Free OS Listings
function isApprovedForAll(
        address owner,
        address operator
    )
        public
        view
        override(ERC721)
        returns (bool)
    {
        // Whitelist OpenSea proxy contract for easy trading.
        ProxyRegistry proxyRegistry = ProxyRegistry(_openSea);
        if (address(proxyRegistry.proxies(owner)) == operator) {
            return true;
        }
        
        return ERC721.isApprovedForAll(owner, operator);
    }
// Solidity 0.8.7
// If _balances for owner is not set in this contract, return balances from mint pass
// contract.
function balanceOf(address owner) public view virtual override(ERC721) returns (uint256) {
        require(owner != address(0), "ERC721: balance query for the zero address");
        if (_balances[owner] == 0) {
            return _ffmp.balanceOf(owner);
        } else {
            return _balances[owner];
        }
    }
// Solidity 0.4.20
// smart contracts must implement the fallback function in order to deregister
function deregister()
    external
    {
        Account storage account = accounts[msg.sender];
        require(account.membership & VOTER != 0);
        require(account.lastAccess + 7 days <= now);
        account.membership ^= VOTER;
        account.lastAccess = 0;
        // the MANDATORY transfer keeps population() meaningful
        msg.sender.transfer(registrationDeposit);
        Deregistered(msg.sender);
    }
// Solidity 0.4.20
// under no condition should you let anyone control two BOARD accounts
function appoint(address _board, string _vouch)
    external {
        require(accounts[msg.sender].membership & BOARD != 0);
        Account storage candidate = accounts[_board];
        if (candidate.membership & BOARD != 0) {
            return;
        }
        address appt = candidate.appointer;
        if (accounts[appt].membership & BOARD == 0) {
            candidate.appointer = msg.sender;
            Nominated(_board, _vouch);
            return;
        }
        if (appt == msg.sender) {
            return;
        }
        Nominated(_board, _vouch);
        candidate.membership |= BOARD;
        Board(_board);
    }
// Solidity 0.4.20
// bans prevent accounts from voting through this proposal
// this should only be used to stop a proposal that is abusing the VOTE token
// the burn is to penalize bans, so that they cannot suppress ideas
function banProposal(ProposalInterface _proposal, string _reason)
    external payable
    {
        require(msg.value == proposalCensorshipFee);
        require(accounts[msg.sender].membership & BOARD != 0);
        Account storage account = accounts[_proposal];
        require(account.membership & PROPOSAL != 0);
        account.membership &= ~PROPOSAL;
        burn.transfer(proposalCensorshipFee);
        BannedProposal(_proposal, _reason);
    }
// Solidity 0.4.20
// this code lives here instead of in the token so that it can be upgraded with account registry migration
function faucet()
    external {
        Account storage account = accounts[msg.sender];
        require(account.membership & VOTER != 0);
        uint256 lastAccess = account.lastAccess;
        uint256 grant = (now - lastAccess) / 72 minutes;
        if (grant > 40) {
            grant = 40;
            account.lastAccess = now;
        } else {
            account.lastAccess = lastAccess + grant * 72 minutes;
        }
        token.grant(msg.sender, grant);
    }
// Solidity 0.7.6
/**
 * @notice register can only be called through transferAndCall on LINK contract
 * @param name string of the upkeep to be registered
 * @param encryptedEmail email address of upkeep contact
 * @param upkeepContract address to peform upkeep on
 * @param gasLimit amount of gas to provide the target contract when
 * performing upkeep
 * @param adminAddress address to cancel upkeep and withdraw remaining funds
 * @param checkData data passed to the contract when checking for upkeep
 * @param amount quantity of LINK upkeep is funded with (specified in Juels)
 * @param source application sending this request
 */
function register(
        string memory name,
        bytes calldata encryptedEmail,
        address upkeepContract,
        uint32 gasLimit,
        address adminAddress,
        bytes calldata checkData,
        uint96 amount,
        uint8 source
    )
      external
      onlyLINK()
    {
        bytes32 hash = keccak256(msg.data);

        emit RegistrationRequested(
            hash,
            name,
            encryptedEmail,
            upkeepContract,
            gasLimit,
            adminAddress,
            checkData,
            amount,
            source
        );

        AutoApprovedConfig memory config = s_config;
        if (config.enabled && _underApprovalLimit(config)) {
            _incrementApprovedCount(config);

            _approve(
                name,
                upkeepContract,
                gasLimit,
                adminAddress,
                checkData,
                amount,
                hash
            );
        }
    }
// Solidity 0.7.6
/**
 * @dev register upkeep on KeeperRegistry contract and emit RegistrationApproved event
 */
function approve(
        string memory name,
        address upkeepContract,
        uint32 gasLimit,
        address adminAddress,
        bytes calldata checkData,
        uint96 amount,
        bytes32 hash
    )
      external
      onlyOwner()
    {
        _approve(
            name,
            upkeepContract,
            gasLimit,
            adminAddress,
            checkData,
            amount,
            hash
        );
    }
// Solidity 0.7.6
/**
 * @notice owner calls this function to set if registration requests should be sent directly to the Keeper Registry
 * @param enabled setting for autoapprove registrations
 * @param windowSizeInBlocks window size defined in number of blocks
 * @param allowedPerWindow number of registrations that can be auto approved in above window
 * @param keeperRegistry new keeper registry address
 */
function setRegistrationConfig(
        bool enabled,
        uint32 windowSizeInBlocks,
        uint16 allowedPerWindow,
        address keeperRegistry,
        uint256 minLINKJuels
    )
      external
      onlyOwner()
    {
        s_config = AutoApprovedConfig({
            enabled: enabled,
            allowedPerWindow: allowedPerWindow,
            windowSizeInBlocks: windowSizeInBlocks,
            windowStart: 0,
            approvedInCurrentWindow: 0
        });
        s_minLINKJuels = minLINKJuels;
        s_keeperRegistry = KeeperRegistryBaseInterface(keeperRegistry);

        emit ConfigChanged(
          enabled,
          windowSizeInBlocks,
          allowedPerWindow,
          keeperRegistry,
          minLINKJuels
        );
    }
// Solidity 0.7.6
/**
 * @notice read the current registration configuration
 */
function getRegistrationConfig()
        external
        view
        returns (
            bool enabled,
            uint32 windowSizeInBlocks,
            uint16 allowedPerWindow,
            address keeperRegistry,
            uint256 minLINKJuels,
            uint64 windowStart,
            uint16 approvedInCurrentWindow
        )
    {
        AutoApprovedConfig memory config = s_config;
        return (
            config.enabled,
            config.windowSizeInBlocks,
            config.allowedPerWindow,
            address(s_keeperRegistry),
            s_minLINKJuels,
            config.windowStart,
            config.approvedInCurrentWindow
        );
    }
// Solidity 0.7.6
/**
 * @notice Called when LINK is sent to the contract via `transferAndCall`
 * @param amount Amount of LINK sent (specified in Juels)
 * @param data Payload of the transaction
 */
function onTokenTransfer(
        address, /* sender */
        uint256 amount,
        bytes calldata data
    )
      external
      onlyLINK()
      permittedFunctionsForLINK(data)
      isActualAmount(amount, data)
    {
        require(amount >= s_minLINKJuels, "Insufficient payment");
        (bool success, ) = address(this).delegatecall(data); // calls register
        require(success, "Unable to create request");
    }
// Solidity 0.8.0
/**
 * @notice initializes the contract, with all parameters set at once
 * @param _token the only token contract that is accepted in this vesting instance
 * @param _owner the owner that can call decreaseVesting, set address(0) to have no owner
 * @param _cliffInTenThousands amount of tokens to be released ahead of startTime: 10000 => 100%
 * @param _cliffDelayInDays the cliff can be retrieved this many days before StartTime of the schedule
 * @param _exp this sets the pace of the schedule. 0 is instant, 1 is linear over time, 2 is quadratic over time etc.
 */
function initialize
   (
    address _token,
    address _owner,
    uint256 _startInDays,
    uint256 _durationInDays,
    uint256 _cliffInTenThousands,
    uint256 _cliffDelayInDays,
    uint256 _exp
   )
    external initializer
   {
    __Ownable_init();
    token = IERC20(_token);
    startTime = block.timestamp + _startInDays * 86400;
    duration = _durationInDays * 86400;
    cliff = _cliffInTenThousands;
    cliffDelay = _cliffDelayInDays * 86400;
    exp = _exp;
    if (_owner == address(0)) {
      renounceOwnership();
    }else {
      transferOwnership(_owner);
    }
  }
// Solidity 0.7.6
// Commission CryptoTulip for abstract deconstructed art.
// You: I'd like a painting please. Use my painting for the foundation
//      and use that other painting accross the street as inspiration.
// Artist: That'll be 1 finney. Come back one block later.
function commissionArt(uint256 _foundation, uint256 _inspiration)
      external payable returns (uint)
    {
        require((totalSupply() < COMMISSION_ARTWORK_LIMIT) || (msg.value >= 1000 * ARTIST_FEES));
        require(msg.sender == ownerOf(_foundation));
        require(msg.value >= ARTIST_FEES);
        uint256 _id = _createTulip(bytes32(0), _foundation, _inspiration, tulips[_foundation].generation + 1, msg.sender);
        return _creativeProcess(_id);
    }
// Solidity 0.4.16
// Allows the developer to set the crowdsale addresses.
function set_sale_address(address _sale) {
    // Only allow the developer to set the sale addresses.
    require(msg.sender == developer);
    // Only allow setting the addresses once.
    require(sale == 0x0);
    // Set the crowdsale and token addresses.
    sale = _sale;
  }
// Solidity 0.4.16
// DEPRECATED -- Users must execute withdraw and specify the token address explicitly
// This contract was formerly exploitable by a malicious dev zeroing out former
// user balances with a junk token
// Allows the developer to set the token address !
// Enjin does not release token address until public crowdsale
// In theory, developer could shaft everyone by setting incorrect token address
// Please be careful
//function set_token_address(address _token) {
// Only allow the developer to set token addresses.
//  require(msg.sender == developer);
// Set the token addresses.
//  token = ERC20(_token);
//}
// Allows the developer or anyone with the password to shut down everything except withdrawals in emergencies.
function activate_kill_switch(string password) {
    // Only activate the kill switch if the sender is the developer or the password is correct.
    require(msg.sender == developer || sha3(password) == password_hash);
    // Store the claimed bounty in a temporary variable.
    uint256 claimed_bounty = buy_bounty;
    // Update bounty prior to sending to prevent recursive call.
    buy_bounty = 0;
    // Irreversibly activate the kill switch.
    kill_switch = true;
    // Send the caller their bounty for activating the kill switch.
    msg.sender.transfer(claimed_bounty);
  }
// Solidity 0.4.16
// Default function.  Called when a user sends ETH to the contract.
function () payable {
    // Disallow deposits if kill switch is active.
    require(!kill_switch);
    // Only allow deposits if the contract hasn't already purchased the tokens.
    require(!bought_tokens);
    // Only allow deposits that won't exceed the contract's ETH cap.
    require(this.balance < eth_cap);
    // Update records of deposited ETH to include the received amount.
    balances[msg.sender] += msg.value;
  }