lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.5.9
// the number of token can be claimed by the msg.sender at the moment
function claimableToken() public view returns (uint256) {
        BuyerInfo storage buyerInfo = _buyerInfos[msg.sender];

        if(buyerInfo.claimed < buyerInfo.total) {
            VestingContract storage vestingContract = _vestingContracts[buyerInfo.contractName];
            uint256 currentMonth = block.timestamp.sub(_deployTime).div(_month);
            
            if(currentMonth < vestingContract.startMonth) {
                return uint256(0);
            }

            if(currentMonth >= vestingContract.endMonth) { // vest the unclaimed token all at once so there's no remainder
                return buyerInfo.total.sub(buyerInfo.claimed);
            } else {
                uint256 claimableIndex = currentMonth.sub(vestingContract.startMonth);
                uint256 canClaim = 0;
                for(uint256 i = 0; i <= claimableIndex; ++i) {
                    canClaim = canClaim.add(vestingContract.basisPoints[i]);
                }
                return canClaim.mul(buyerInfo.total).div(10000).sub(buyerInfo.claimed);
            }
        }
        return uint256(0);
    }
// Solidity 0.8.0
/**
 * @dev Checks if amount is within allowed burn bounds and
 * destroys `amount` tokens from `account`, reducing the
 * total supply.
 * @param account account to burn tokens for
 * @param amount amount of tokens to burn
 *
 * Emits a {Burn} event
 */
function _burn(address account, uint256 amount) internal virtual override {
        require(amount >= burnMin, "BurnableTokenWithBounds: below min burn bound");
        require(amount <= burnMax, "BurnableTokenWithBounds: exceeds max burn bound");

        super._burn(account, amount);
        emit Burn(account, amount);
    }
// Solidity 0.8.7
/* 
 * @dev Verifies if message was signed by owner to give access to _add for this contract.
 *      Assumes Geth signature prefix.
 * @param _add Address of agent with access
 * @param _v ECDSA signature parameter v.
 * @param _r ECDSA signature parameters r.
 * @param _s ECDSA signature parameters s.
 * @return Validity of access message for a given address.
 */
function isInvalidAccessMessage(
        uint8 _v, 
        bytes32 _r, 
        bytes32 _s) 
        view public returns (bool)
    {
        bytes32 hash = keccak256(abi.encodePacked(this));
        address signAddress = ecrecover(
            keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)),
            _v,
            _r,
            _s
        );
        if (ownerAddy == signAddress){
          return true;
        }
        else{
          return false;
        }
    }
// Solidity 0.8.7
/* 
 * @dev Public Sale Mint
 * @param quantity Number of NFT's to be minted at 0.06 with a max of 10 per transaction. This is a gas efficient function.
 */
function mint(uint256 quantity) external payable {
    require(quantity <= 10, "Cant mint more than 10");
    require(totalSupply() + quantity <= 3183, "Sold out");
    require(msg.value >= pricePerPublic * quantity, "Not enough Eth");
    require(publicLive, "sale not live");
    _safeMint(msg.sender, quantity);
  }
// Solidity 0.8.7
/* 
 * @dev Verifies if message was signed by owner to give access to this contract.
 *      Assumes Geth signature prefix.
 * @param quantity Number of NFT's to be minted at 0.04 with a max of 3. This is a gas efficient function.
 * @param _v ECDSA signature parameter v.
 * @param _r ECDSA signature parameters r.
 * @param _s ECDSA signature parameters s.
 */
function mintWL(uint256 quantity, uint8 _v, bytes32 _r, bytes32 _s) external payable noInvalidAccess(_v, _r, _s){
    require(quantity <= 3, "Cant mint more than 3");
    require(totalSupply() + quantity <= 3183, "Sold out");
    require(msg.value >= pricePerWL * quantity, "Not enough Eth");
    require(presaleLive, "sale not live");
    require(WLminted[msg.sender] + quantity <= 3, "Cant mint more than 3");
    WLminted[msg.sender] += quantity;
    _safeMint(msg.sender, quantity);
  }
// Solidity 0.5.4
/**
 	 * @dev Stake `_value` ions on behalf of `_from`
 	 * @param _from The address of the target
 	 * @param _value The amount to stake
 	 * @return true on success
 	 */
function stakeFrom(address _from, uint256 _value) public inWhitelist returns (bool) {
		require (balanceOf[_from] >= _value);						// Check if the targeted balance is enough
		balanceOf[_from] = balanceOf[_from].sub(_value);			// Subtract from the targeted balance
		stakedBalance[_from] = stakedBalance[_from].add(_value);	// Add to the targeted staked balance
		emit Stake(_from, _value);
		return true;
	}
// Solidity 0.7.5
/**
 * @dev See {IMerkleDrop-isClaimed}.
 */
function isClaimed(uint256 index) public view override returns (bool) {
        uint256 claimedWordIndex = index / 256;
        uint256 claimedBitIndex = index % 256;
        uint256 claimedWord = claimedBitMap[claimedWordIndex];
        uint256 mask = (1 << claimedBitIndex);
        return claimedWord & mask == mask;
    }
// Solidity 0.7.5
/**
 * @dev See {IMerkleDrop-claim}.
 */
function claim(uint256 index, address account, uint256 amount, bytes32[] calldata merkleProof) external override {
        require(!isClaimed(index), "MerkleDrop: drop already claimed");

        // Verify the merkle proof.
        bytes32 node = keccak256(abi.encodePacked(index, account, amount));
        require(MerkleProof.verify(merkleProof, merkleRoot, node), "MerkleDrop: invalid proof");

        // Mark it claimed and send the token.
        _setClaimed(index);
        token.safeTransfer(account, amount);
        emit Claimed(index, account, amount);
    }
// Solidity 0.7.5
/**
 * @dev See {IMerkleDrop-stop}.
 */
function stop(address beneficiary) external override onlyOwner {
        require(beneficiary != address(0), "MerkleDrop: beneficiary is the zero address");
        // solhint-disable-next-line not-rely-on-time
        require(block.timestamp >= expireTimestamp, "MerkleDrop: not expired");
        uint256 amount = token.balanceOf(address(this));
        token.safeTransfer(beneficiary, amount);
        emit Stopped(beneficiary, amount);
    }
// Solidity 0.5.4
/**
 	 * @dev Store `_value` from `_from` to `_to` in escrow
 	 * @param _from The address of the sender
 	 * @param _to The address of the recipient
 	 * @param _value The amount of network ions to put in escrow
 	 * @return true on success
 	 */
function escrowFrom(address _from, address _to, uint256 _value) public inWhitelist returns (bool) {
		require (balanceOf[_from] >= _value);						// Check if the targeted balance is enough
		balanceOf[_from] = balanceOf[_from].sub(_value);			// Subtract from the targeted balance
		escrowedBalance[_to] = escrowedBalance[_to].add(_value);	// Add to the targeted escrowed balance
		emit Escrow(_from, _to, _value);
		return true;
	}
// Solidity 0.5.4
/**
 	 * @dev Release escrowed `_value` from `_from`
 	 * @param _from The address of the sender
 	 * @param _value The amount of escrowed network ions to be released
 	 * @return true on success
 	 */
function unescrowFrom(address _from, uint256 _value) public inWhitelist returns (bool) {
		require (escrowedBalance[_from] >= _value);						// Check if the targeted escrowed balance is enough
		escrowedBalance[_from] = escrowedBalance[_from].sub(_value);	// Subtract from the targeted escrowed balance
		balanceOf[_from] = balanceOf[_from].add(_value);				// Add to the targeted balance
		emit Unescrow(_from, _value);
		return true;
	}
// Solidity 0.5.4
/**
 	 * Transfer ions between public key addresses in a Name
 	 * @param _nameId The ID of the Name
 	 * @param _from The address of the sender
 	 * @param _to The address of the recipient
 	 * @param _value the amount to send
 	 */
function transferBetweenPublicKeys(address _nameId, address _from, address _to, uint256 _value) public returns (bool success) {
		require (AOLibrary.isName(_nameId));
		require (_nameTAOPosition.senderIsAdvocate(msg.sender, _nameId));
		require (!_nameAccountRecovery.isCompromised(_nameId));
		// Make sure _from exist in the Name's Public Keys
		require (_namePublicKey.isKeyExist(_nameId, _from));
		// Make sure _to exist in the Name's Public Keys
		require (_namePublicKey.isKeyExist(_nameId, _to));
		_transfer(_from, _to, _value);
		return true;
	}
// Solidity 0.8.0
/**
 * @dev Check if neither account is blacklisted before performing transfer
 * If transfer recipient is a redemption address, burns tokens
 * @notice Transfer to redemption address will burn tokens with a 1 cent precision
 * @param sender address of sender
 * @param recipient address of recipient
 * @param amount amount of tokens to transfer
 */
function _transfer(
        address sender,
        address recipient,
        uint256 amount
    ) internal virtual override {
        require(!isBlacklisted[sender], "FavorCurrency: sender is blacklisted");
        require(!isBlacklisted[recipient], "FavorCurrency: recipient is blacklisted");

        if (isRedemptionAddress(recipient)) {
            super._transfer(sender, recipient, amount.sub(amount.mod(CENT)));
            _burn(recipient, amount.sub(amount.mod(CENT)));
        } else {
            super._transfer(sender, recipient, amount);
        }
    }
// Solidity 0.8.0
/**
 * @dev Requere neither accounts to be blacklisted before approval
 * @param owner address of owner giving approval
 * @param spender address of spender to approve for
 * @param amount amount of tokens to approve
 */
function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal override {
        require(!isBlacklisted[owner], "FavorCurrency: tokens owner is blacklisted");
        require(!isBlacklisted[spender] || amount == 0, "FavorCurrency: tokens spender is blacklisted");

        super._approve(owner, spender, amount);
    }
// Solidity 0.8.9
/// @dev withdraw native tokens divided by splits
function withdraw(Payout storage _payout) external onlyWhenInitialized(_payout.initialized) {
        uint256 _amount = address(this).balance;
        if (_amount > 0) {
            for (uint256 i = 0; i < _payout.recipients.length; i++) {
                // we don't want to fail here or it can lock the contract withdrawals
                uint256 _share = (_amount * _payout.splits[i]) / _payout.BASE;
                (bool _success, ) = payable(_payout.recipients[i]).call{value: _share}('');
                if (_success) {
                    emit SplitWithdrawal(address(0), _payout.recipients[i], _share);
                }
            }
        }
    }
// Solidity 0.8.9
/// @dev withdraw ERC20 tokens divided by splits
function withdrawTokens(Payout storage _payout, address _tokenContract)
        external
        onlyWhenInitialized(_payout.initialized)
    {
        IERC20 tokenContract = IERC20(_tokenContract);

        // transfer the token from address of this contract
        uint256 _amount = tokenContract.balanceOf(address(this));
        /* istanbul ignore else */
        if (_amount > 0) {
            for (uint256 i = 0; i < _payout.recipients.length; i++) {
                uint256 _share = i != _payout.recipients.length - 1
                    ? (_amount * _payout.splits[i]) / _payout.BASE
                    : tokenContract.balanceOf(address(this));
                tokenContract.transfer(_payout.recipients[i], _share);
                emit SplitWithdrawal(_tokenContract, _payout.recipients[i], _share);
            }
        }
    }
// Solidity 0.8.9
/// @dev withdraw ERC721 tokens to the first recipient
function withdrawNFT(
        Payout storage _payout,
        address _tokenContract,
        uint256[] memory _id
    ) external onlyWhenInitialized(_payout.initialized) {
        IERC721 tokenContract = IERC721(_tokenContract);
        for (uint256 i = 0; i < _id.length; i++) {
            address _recipient = getNftRecipient(_payout);
            tokenContract.safeTransferFrom(address(this), _recipient, _id[i]);
        }
    }
// Solidity 0.8.9
/// @dev Allow a recipient to update to a new address
function updateRecipient(Payout storage _payout, address _recipient)
        external
        onlyWhenInitialized(_payout.initialized)
    {
        require(_recipient != address(0), 'Cannot use the zero address.');
        require(_recipient != address(this), 'Cannot use the address of this contract.');

        // loop over all the recipients and update the address
        bool _found = false;
        for (uint256 i = 0; i < _payout.recipients.length; i++) {
            // if the sender matches one of the recipients, update the address
            if (_payout.recipients[i] == msg.sender) {
                _payout.recipients[i] = _recipient;
                _found = true;
                break;
            }
        }
        require(_found, 'The sender is not a recipient.');
    }
// Solidity 0.4.13
// Transfer token with data and signature
function transferAndData(address _to, uint _value, string _data) returns (bool) {
        //Default assumes totalSupply can't be over max (2^256 - 1).
        if (balances[msg.sender] >= _value && balances[_to] + _value >= balances[_to]) {
            balances[msg.sender] -= _value;
            balances[_to] += _value;
            Transfer(msg.sender, _to, _value);
            
            return true;
        } else { return false; }
    }
// Solidity 0.4.16
/**
 @dev updates one of the token reserves
 can only be called by the owner
 
 @param _reserveToken           address of the reserve token
 @param _ratio                  constant reserve ratio, represented in ppm, 1-1000000
 @param _enableVirtualBalance   true to enable virtual balance for the reserve, false to disable it
 @param _virtualBalance         new reserve's virtual balance
 */
function updateReserve(IERC20Token _reserveToken, uint32 _ratio, bool _enableVirtualBalance, uint256 _virtualBalance)
        public
        ownerOnly
        validReserve(_reserveToken)
        validReserveRatio(_ratio)
    {
        Reserve storage reserve = reserves[_reserveToken];
        require(totalReserveRatio - reserve.ratio + _ratio <= MAX_CRR); // validate input

        totalReserveRatio = totalReserveRatio - reserve.ratio + _ratio;
        reserve.ratio = _ratio;
        reserve.isVirtualBalanceEnabled = _enableVirtualBalance;
        reserve.virtualBalance = _virtualBalance;
    }
// Solidity 0.6.0
// ------------------------------------------------------------------------
// Withdraw accumulated rewards
// ------------------------------------------------------------------------
function ClaimReward() external {
        require(PendingReward(msg.sender) > 0, "No pending rewards");
    
        uint256 _pendingReward = PendingReward(msg.sender);
        
        // Global stats update
        totalRewards = totalRewards.add(_pendingReward);
        
        // update the record
        users[msg.sender].totalGained = users[msg.sender].totalGained.add(_pendingReward);
        users[msg.sender].lastClaimedDate = now;
        users[msg.sender].pendingGains = 0;
        
        // mint more tokens inside token contract equivalent to _pendingReward
        require(IERC20(OXS).transfer(msg.sender, _pendingReward));
        
        emit RewardsCollected(_pendingReward);
    }
// Solidity 0.6.0
// ------------------------------------------------------------------------
// This will stop the existing staking
// ------------------------------------------------------------------------
function StopStaking() external {
        require(users[msg.sender].activeDeposit >= 0, "No active stake");
        uint256 _activeDeposit = users[msg.sender].activeDeposit;
        
        // update staking stats
            // check if we have any pending rewards, add it to previousGains var
            users[msg.sender].pendingGains = PendingReward(msg.sender);
            // update amount 
            users[msg.sender].activeDeposit = 0;
            // reset last claimed figure as well
            users[msg.sender].lastClaimedDate = now;
        
        // withdraw the tokens and move from contract to the caller
        require(IERC20(OXS).transfer(msg.sender, _activeDeposit));
        
        emit StakingStopped(_activeDeposit);
    }
// Solidity 0.6.0
//#########################################################################################################################################################//
//##########################################################FARMING QUERIES################################################################################//
//#########################################################################################################################################################//
// ------------------------------------------------------------------------
// Query to get the pending reward
// @param _caller address of the staker
// ------------------------------------------------------------------------
function PendingReward(address _caller) public view returns(uint256 _pendingRewardWeis){
        uint256 _totalStakingTime = now.sub(users[_caller].lastClaimedDate);
        
        uint256 _reward_token_second = ((stakingRate).mul(10 ** 21)).div(365 days); // added extra 10^21
        
        uint256 reward = ((users[_caller].activeDeposit).mul(_totalStakingTime.mul(_reward_token_second))).div(10 ** 23); // remove extra 10^21 // 10^2 are for 100 (%)
        
        return reward.add(users[_caller].pendingGains);
    }
// Solidity 0.6.0
//#########################################################################################################################################################//
//################################################################COMMON UTILITIES#########################################################################//
//#########################################################################################################################################################//    
// ------------------------------------------------------------------------
// Internal function to add new deposit
// ------------------------------------------------------------------------        
function _newDeposit(uint256 _amount) internal{
        require(users[msg.sender].activeDeposit ==  0, "Already running, use funtion add to stake");
        
        // add that token into the contract balance
        // check if we have any pending reward, add it to pendingGains variable
        users[msg.sender].pendingGains = PendingReward(msg.sender);
            
        users[msg.sender].activeDeposit = _amount;
        users[msg.sender].totalDeposits = users[msg.sender].totalDeposits.add(_amount);
        users[msg.sender].startTime = now;
        users[msg.sender].lastClaimedDate = now;
        
        // update global stats
        totalStakes = totalStakes.add(_amount);
    }
// Solidity 0.6.0
// ------------------------------------------------------------------------
// Internal function to add to existing deposit
// ------------------------------------------------------------------------        
function _addToExisting(uint256 _amount) internal{
        
        require(users[msg.sender].activeDeposit > 0, "no running farming/stake");
        
        // update staking stats
            // check if we have any pending reward, add it to pendingGains variable
            users[msg.sender].pendingGains = PendingReward(msg.sender);
            
            // update current deposited amount 
            users[msg.sender].activeDeposit = users[msg.sender].activeDeposit.add(_amount);
            // update total deposits till today
            users[msg.sender].totalDeposits = users[msg.sender].totalDeposits.add(_amount);
            // update new deposit start time -- new stake will begin from this time onwards
            users[msg.sender].startTime = now;
            // reset last claimed figure as well -- new stake will begin from this time onwards
            users[msg.sender].lastClaimedDate = now;
            
        // update global stats
        totalStakes = totalStakes.add(_amount);
    }
// Solidity 0.4.16
/**
 @dev returns the expected return for buying the token for a reserve token
 
 @param _reserveToken   reserve token contract address
 @param _depositAmount  amount to deposit (in the reserve token)
 
 @return expected purchase return amount
 */
function getPurchaseReturn(IERC20Token _reserveToken, uint256 _depositAmount)
        public
        constant
        active
        validReserve(_reserveToken)
        returns (uint256)
    {
        Reserve storage reserve = reserves[_reserveToken];
        require(reserve.isPurchaseEnabled); // validate input

        uint256 tokenSupply = token.totalSupply();
        uint256 reserveBalance = getReserveBalance(_reserveToken);
        uint256 amount = extensions.formula().calculatePurchaseReturn(tokenSupply, reserveBalance, reserve.ratio, _depositAmount);

        // deduct the fee from the return amount
        uint256 feeAmount = getConversionFeeAmount(amount);
        return safeSub(amount, feeAmount);
    }
// Solidity 0.4.16
/**
 @dev converts a specific amount of _fromToken to _toToken
 
 @param _fromToken  ERC20 token to convert from
 @param _toToken    ERC20 token to convert to
 @param _amount     amount to convert, in fromToken
 @param _minReturn  if the conversion results in an amount smaller than the minimum return - it is cancelled, must be nonzero
 
 @return conversion return amount
 */
function convert(IERC20Token _fromToken, IERC20Token _toToken, uint256 _amount, uint256 _minReturn) public returns (uint256) {
        require(_fromToken != _toToken); // validate input

        // conversion between the token and one of its reserves
        if (_toToken == token)
            return buy(_fromToken, _amount, _minReturn);
        else if (_fromToken == token)
            return sell(_toToken, _amount, _minReturn);

        // conversion between 2 reserves
        uint256 purchaseAmount = buy(_fromToken, _amount, 1);
        return sell(_toToken, purchaseAmount, _minReturn);
    }
// Solidity 0.4.16
/**
 @dev utility, returns the expected return for selling the token for one of its reserve tokens, given a total supply override
 
 @param _reserveToken   reserve token contract address
 @param _sellAmount     amount to sell (in the standard token)
 @param _totalSupply    total token supply, overrides the actual token total supply when calculating the return
 
 @return sale return amount
 */
function getSaleReturn(IERC20Token _reserveToken, uint256 _sellAmount, uint256 _totalSupply)
        private
        constant
        active
        validReserve(_reserveToken)
        greaterThanZero(_totalSupply)
        returns (uint256)
    {
        Reserve storage reserve = reserves[_reserveToken];
        uint256 reserveBalance = getReserveBalance(_reserveToken);
        uint256 amount = extensions.formula().calculateSaleReturn(_totalSupply, reserveBalance, reserve.ratio, _sellAmount);

        // deduct the fee from the return amount
        uint256 feeAmount = getConversionFeeAmount(amount);
        return safeSub(amount, feeAmount);
    }
// Solidity 0.4.21
// get normal cardlist;
function getNormalCardList(address _owner) external view returns(uint256[],uint256[]){
    uint256 len = getNormalCard(_owner);
    uint256[] memory itemId = new uint256[](len);
    uint256[] memory itemNumber = new uint256[](len);
    uint256 startId;
    uint256 endId;
    (startId,endId) = schema.productionCardIdRange(); 
    uint256 i;
    while (startId <= endId) {
      if (cards.getOwnedCount(_owner,startId)>=1) {
        itemId[i] = startId;
        itemNumber[i] = cards.getOwnedCount(_owner,startId);
        i++;
      }
      startId++;
      }   
    return (itemId, itemNumber);
  }