lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.24
/**
 * @dev Get the holder's info of a token.
 * @param _tokenId id of interested token
 **/
function getTokenInfo(uint256 _tokenId)
        external view
        returns (string, string, string, string, string, string, string)
    {
        address tokenOwner = ownerOf(_tokenId);
        require(tokenOwner != address(0));

        IdentityInfo storage pInfo = IdentityInfoOfId[_tokenId];
        return (
            pInfo.hashID,
            pInfo.name,
            pInfo.country,
            pInfo.photoUrl,
            pInfo.institute,
            pInfo.occupation,
            pInfo.suggestions
        );
    }
// Solidity 0.4.24
/**
 * @dev Set holder's IdentityInfo of a token
 * @param _tokenId id of target token.
 * @param _name token holder customized field, the name of the holder
 * @param _country token holder customized field.
 * @param _photoUrl token holder customized field, link to holder's photo
 * @param _institute token holder customized field, institute the holder works for
 * @param _occupation token holder customized field, holder's occupation in the institute he/she works in
 * @param _suggestions token holder customized field, holder's suggestions for HashFuture
 **/
function setIdentityInfo(
        uint256 _tokenId,
        string _name,
        string _country,
        string _photoUrl,
        string _institute,
        string _occupation,
        string _suggestions
    )
        public
        onlyOwnerOf(_tokenId)
    {
        IdentityInfo storage pInfo = IdentityInfoOfId[_tokenId];

        pInfo.name = _name;
        pInfo.country = _country;
        pInfo.photoUrl = _photoUrl;
        pInfo.institute = _institute;
        pInfo.occupation = _occupation;
        pInfo.suggestions = _suggestions;
    }
// Solidity 0.5.12
//only admin and game is not run
function startArgs(uint dailyInvest, uint safePool, uint gloryPool, uint staticPool, uint[] memory locks) public onlyAdmin() {
        require(!isStart(), "Game Not Start Limit");
        _dailyInvest = dailyInvest;
        _safePool = safePool;
        _gloryPool = gloryPool;
        _staticPool = staticPool;
        for(uint i=0; i<locks.length; i++) {
            lockedRound.push(locks[i]);
        }
    }
// Solidity 0.5.17
/**
 * @dev ETH to Maco Cash
 */
function toMacoCash(uint160 sqrtPriceLimitX96) public payable {
        wrap(msg.value);
        WETH.approve(macoEthUniswapPoolAddress, msg.value);

        // → coinswap ETH/MACO 
        // docs: https://docs.uniswap.org/reference/core/interfaces/pool/IUniswapV3PoolActions
        /*
          swap( address recipient, bool zeroForOne, int256 amountSpecified, uint160 sqrtPriceLimitX96, bytes data) external returns (int256 amount0, int256 amount1)
         */
        macoEthUniswapPool.swap(address(this), !macoEthUniswapPoolToken0IsMaco, int256(msg.value), sqrtPriceLimitX96, swapDataToBytes(SwapData(2, msg.sender)));
    }
// Solidity 0.5.17
/**
 * @dev Maco Cash to Coin: Emits event to cash out deposited Maco Cash to Maco in user's wallet
 * @param _amount amount of maco cash to cash out
 */
function cashOut(uint256 _amount, bool _toEth) public payable {
        require(msg.value >= tx.gasprice * (_toEth ? gasToCashOutToEth : gasToCashOut), "min_gas_to_cashout");
        
        // pay owner the gas fee it needs to call settlecashout
        address payable payowner = address(uint160(owner()));
        require(payowner.send( msg.value ), "fees_to_owner");

        //→ emit event
        //emit SwapEvent(_toEth ? 7 : 1, msg.sender, msg.value, _amount);
        if(_toEth) { 
            dao.cashOutEth(msg.sender, msg.value, _amount);
        } else {
            dao.cashOutMaco(msg.sender, msg.value, _amount);
        }
    }
// Solidity 0.8.2
/**
 * @dev Called by IMX to mint each NFT
 *
 * @param to the address to mint to
 * @param amount not relavent for NFTs
 * @param mintingBlob all NFT details
 */
function mintFor(
        address to,
        uint256 amount,
        bytes memory mintingBlob
    ) external override {
        (
            uint256 tokenId,
            uint16 proto,
            uint256 serialNumber,
            uint8 chroma,
            string memory tokenURI
        ) = Minting.deserializeMintingBlobWithChroma(mintingBlob);
        _mintCommon(to, tokenId, tokenURI, proto, serialNumber);
        chromas[tokenId] = chroma;
        emit MintFor(
            to,
            amount,
            tokenId,
            proto,
            serialNumber,
            chroma,
            tokenURI
        );
    }
// Solidity 0.5.17
/**
 * @dev Cashes out deposited Maco Cash to Maco in user's wallet
 * @param _to address of the future owner of the token
 * @param _amount how much Maco to cash out
 * @param _notMinted not minted cash to reflect on blockchain
 */
function settleCashOut(address payable _to, uint256 _amount, bool _toEth, uint160 sqrtPriceLimitX96, uint256 _notMinted) public onlyMinter {
        mintFromCash(_notMinted);
        
        // must be done in any case, so it can be taken from him for uniswap or left if not swapped
        transferFrom(address(this), _to, _amount);

        if(_toEth) {
            // owner wanted ETH in return to Cash
            //require(_amount <= balanceOf(_to), 'low_balance');
            _approve(_to, macoEthUniswapPoolAddress, _amount);

            macoEthUniswapPool.swap(
                address(this), 
                macoEthUniswapPoolToken0IsMaco, 
                int256(_amount), 
                sqrtPriceLimitX96, 
                swapDataToBytes(SwapData(3, _to))
            );
        }
    }
// Solidity 0.5.17
/**
 * @dev Mints token to one of the payout adddresses for bootstrap, infrastructure and dev team
 * @dev Approves the contract owner to transfer that minted tokens
 * @param _amount mints this amount of Maco to the contract itself
 * @param _to address on where to mint
 */
function mintOwnerFundsTo(uint256 _amount, address _to) internal onlyMinter {
        require(_amount > 0, "zero amount to mint");
        require(_to != address(0), "mint to is zero address");

        //_approve(address(this), msg.sender, _amount);
        //_transfer(address(this), _to, _amount);
        mint(_to, _amount);
        _approve(_to, owner(), _amount);
    }
// Solidity 0.5.17
/**
 * @dev Reflects the current maco cash state to maco coin by minting to the contract itself
 * @dev Approves the contract owner to transfer that minted cash later
 * @dev Additionally approves pre-minted funds for hardware payment and dev incentives
 * @param _amount mints this amount of Maco to the contract itself
 */
function mintFromCash(uint256 _amount) public onlyMinter {
        uint256 totalApprove = _amount;
        if(_amount > 0) {
            mint(address(this), _amount);
            // approve for later cashout
            _approve(address(this), owner(), totalApprove);

            // check if a 10% milestone is broken, and if so grant the dev team 10% of their fund
            if( (totalSupply() * 10 / cap()) < ((totalSupply() + _amount) * 10 / cap()) ) {
                uint256 devFunds = cap()/100*percentDevteam/10;
                mintOwnerFundsTo(devFunds, devTeamPayoutAdress);
                emit OwnerFundsApproval(2, devFunds);
            }
            
        }
        // check for next infrastructure cost settlement
        if ((now >= lastInfrastructureGrand + 4 * 1 weeks) 
            && ((usedForInfrstructure + currentInfrastructureCosts) <= (cap()/100 * percentInfrastructureFund))
        ) {
            usedForInfrstructure += currentInfrastructureCosts;
            lastInfrastructureGrand = now;
            mintOwnerFundsTo(currentInfrastructureCosts, infrastructurePayoutAdress);
            emit OwnerFundsApproval(1, currentInfrastructureCosts);     
        }
    }
// Solidity 0.8.6
/// @dev Deposit tokens to be locked until the end of the locking period
/// @param amount The amount of tokens to deposit
function deposit(uint256 amount) public {
    if (block.timestamp > depositDeadline) {
      revert DepositPeriodOver();
    }

    balanceOf[msg.sender] += amount;
    totalSupply += amount;

    if (!token.transferFrom(msg.sender, address(this), amount)) {
      revert TransferFailed();
    }

    emit Transfer(msg.sender, address(this), amount);
  }
// Solidity 0.8.6
/// @dev Withdraw tokens after the end of the locking period or during the deposit period
/// @param amount The amount of tokens to withdraw
function withdraw(uint256 amount) public {
    if (
      block.timestamp > depositDeadline &&
      block.timestamp < depositDeadline + lockDuration
    ) {
      revert LockPeriodOngoing();
    }
    if (balanceOf[msg.sender] < amount) {
      revert ExceedsBalance();
    }

    balanceOf[msg.sender] -= amount;
    totalSupply -= amount;

    if (!token.transfer(msg.sender, amount)) {
      revert TransferFailed();
    }

    emit Transfer(address(this), msg.sender, amount);
  }
// Solidity 0.5.16
/**
 	 * @param _id bundle id
 	 * @return the bundle detail
 	 */
function getBundleDetailById(uint256 _id) public view returns (uint256 id, address beneficiary, uint256 amount, uint256[] memory phaseIdentifies, bool[] memory isPhaseWithdrawns) {
		LockupBundle storage bundle = _lockupBundles[_id];
		id = bundle.id;
		beneficiary = bundle.beneficiary;
		amount = bundle.amount;
		phaseIdentifies = new uint256[](_lockupPhases.length);
		isPhaseWithdrawns = new bool[](_lockupPhases.length);
		for (uint256 i = 0; i < _lockupPhases.length; i++) {
			phaseIdentifies[i] = _lockupPhases[i].id;
			isPhaseWithdrawns[i] = bundle.isPhaseWithdrawns[_lockupPhases[i].id];
		}
	}
// Solidity 0.6.12
/// @notice Executes calls on behalf of this contract.
/// @param calls The array of calls to be executed.
/// @return An array of the return values for each of the calls
function executeCalls(Call[] calldata calls) external returns (bytes[] memory) {
    bytes[] memory response = new bytes[](calls.length);
    for (uint256 i = 0; i < calls.length; i++) {
      response[i] = _executeCall(calls[i].to, calls[i].value, calls[i].data);
    }
    return response;
  }
// Solidity 0.6.12
/// @notice Transfers ERC721 tokens to an account
/// @param withdrawals An array of WithdrawERC721 structs that each include the ERC721 token to transfer and the corresponding token ids.
/// @param to The recipient of the transfers
function _withdrawERC721(WithdrawERC721[] memory withdrawals, address to) internal {
    for (uint256 i = 0; i < withdrawals.length; i++) {
      for (uint256 tokenIndex = 0; tokenIndex < withdrawals[i].tokenIds.length; tokenIndex++) {
        withdrawals[i].token.transferFrom(address(this), to, withdrawals[i].tokenIds[tokenIndex]);
      }

      emit WithdrewERC721(address(withdrawals[i].token), withdrawals[i].tokenIds);
    }
  }
// Solidity 0.6.12
/* Get all stakes a address holds
 *
 */
function getStakes() public view returns (uint[3][] memory) {
        uint[3][] memory tempStakeList = new uint[3][](_staking[msg.sender].length);
        for (uint i = 0; i < _staking[msg.sender].length; i++){
            tempStakeList[i][0] = getStakeAmount(i);
            tempStakeList[i][1] = getRemainingLockTime(i);
            tempStakeList[i][2] = getStakeReward(i);
        } 
        return tempStakeList;
    }
// Solidity 0.6.12
/* Calculates the current reward of a stake.
 * Get time staked
 * Add a buffer to circumvent float calculations
 * Gets amount of periods staked
 * Multiplies the periods staked with the reward percent amount
 * Multiplies the reward by the amount staked
 * Removed the buffer
 * Removes the percent buffer
 */
function getStakeReward(uint stake_) public view returns (uint) {
        uint stakingTime = now - _staking[msg.sender][stake_].startTime;
        uint buffededStakingTime = stakingTime * stakeBuffer;
        uint periods = buffededStakingTime / yearInMs;
        uint buffedRewardPeriodPercent = periods * _stakingOptions[_staking[msg.sender][stake_].stakeType].rewardPercent;
        uint buffedReward = _staking[msg.sender][stake_].amount * buffedRewardPeriodPercent;
        uint rewardPerc = buffedReward / stakeBuffer;
        uint reward = rewardPerc / 100;
        return reward;
    }
// Solidity 0.6.12
/* Unstake previous stake, mints back the original tokens,
 * sends mint function call to reward contract to mint the
 * reward to the sender address.
 */
function unstake(uint stake_) public {
        require(isStakeLocked(stake_) != true, "Stake still locked!");
        _mint(msg.sender, _staking[msg.sender][stake_].amount);
        stakedSupply -= _staking[msg.sender][stake_].amount;
        uint _amount = getStakeReward(stake_);
        (bool success, bytes memory returnData) = address(_tokenContract).call(abi.encodeWithSignature("mint(address,uint256)",msg.sender, _amount));
        require(success);
        _removeIndexInArray(_staking[msg.sender], stake_);
        emit unstaked(msg.sender, _amount);
    }
// Solidity 0.5.16
/**
 	 * @param _id phase id
 	 * @return the phase detail
 	 */
function getLockupPhaseDetail(uint256 _id) public view returns (uint256 id, uint256 percentage, uint256 extraTime, bool hasWithdrawal, bool canWithdrawal) {
		if (_phaseIndexs[_id] > 0) {
			LockupPhase memory phase = _lockupPhases[_phaseIndexs[_id].sub(1)];
			id = phase.id;
			percentage = phase.percentage;
			extraTime = phase.extraTime;
			hasWithdrawal = phase.hasWithdrawal;
			canWithdrawal = checkPhaseCanWithdrawal(_id);
		}
	}
// Solidity 0.5.16
/**
 	 * Lockup Phases Start
 	 * ===============================================================================
 	 */
function setLockupPhases(uint256[] memory _ids, uint256[] memory _percentages, uint256[] memory _extraTimes) public whenNotPaused whenNotFinalized {
		require(isOwner() || isOperator(msg.sender), "TimeLockFactory: caller is not the owner or operator");
		require(_ids.length == _percentages.length && _ids.length == _extraTimes.length, "TimeLockFactory:: Cannot match inputs");
		_preValidateLockupPhases(_percentages);
		for (uint256 i = 0; i < _ids.length; i++) {
			if (!checkPhaseHasWithdrawal(_ids[i])) {
				_setLockupPhase(_ids[i], _percentages[i], _extraTimes[i]);
			}
		}
	}
// Solidity 0.8.7
// 0xInuarashi
function withdrawEther() public onlyOwner {
        uint _totalETH = address(this).balance; // balance of contract

        uint _Shareholder_1_ETH = ((_totalETH * Shareholder_1_Share) / 100); 
        uint _Shareholder_2_ETH = ((_totalETH * Shareholder_2_Share) / 100); 

        payable(Shareholder_1).transfer(_Shareholder_1_ETH);
        payable(Shareholder_2).transfer(_Shareholder_2_ETH);
    }
// Solidity 0.5.11
/**
 * @dev Get item id by option id
 * @param _collectionAddress - collectionn address
 * @param _optionId - collection option id
 * @return string of the item id
 */
function itemByOptionId(address _collectionAddress, uint256 _optionId) public view returns (string memory) {
       /* solium-disable-next-line */
        (bool success, bytes memory data) = address(_collectionAddress).staticcall(
            abi.encodeWithSelector(
                IERC721Collection(_collectionAddress).wearables.selector,
                _optionId
            )
        );

        require(success, "Invalid wearable");

        return abi.decode(data, (string));
    }
// Solidity 0.5.11
/**
 * @dev Sets the beneficiary address where the sales amount
 *  will be transferred on each sale for a collection
 * @param _collectionAddress - collectionn address
 * @param _collectionOptionIds - collection option ids
 * @param _collectionAvailableQtys - collection available qtys for sale
 * @param _collectionPrices - collectionn prices
 */
function _setCollectionData(
        address _collectionAddress,
        uint256[] memory _collectionOptionIds,
        uint256[] memory _collectionAvailableQtys,
        uint256[] memory _collectionPrices
    ) internal {
        // emit ChangedCollectionBeneficiary(_collectionAddress, collectionBeneficiaries[_collectionAddress], _beneficiary);
        CollectionData storage collection = collectionsData[_collectionAddress];

        for (uint256 i = 0; i < _collectionOptionIds.length; i++) {
            collection.availableQtyPerOptionId[_collectionOptionIds[i]] = _collectionAvailableQtys[i];
            collection.pricePerOptionId[_collectionOptionIds[i]] = _collectionPrices[i];
        }

        emit SetCollectionData(_collectionAddress, _collectionOptionIds, _collectionAvailableQtys, _collectionPrices);
    }
// Solidity 0.5.11
/**
 * @dev Validate if a user has balance and the contract has enough allowance
 * to use user's accepted token on his belhalf
 * @param _user - address of the user
 */
function _requireBalance(address _user, uint256 _price) internal view {
        require(
            acceptedToken.balanceOf(_user) >= _price,
            "Insufficient funds"
        );
        require(
            acceptedToken.allowance(_user, address(this)) >= _price,
            "The contract is not authorized to use the accepted token on sender behalf"
        );
    }
// Solidity 0.4.25
/*     
 function getSlice(uint256 begin, uint256 end, string text) public pure returns (string) {
 bytes memory a = new bytes(end-begin+1);
 for(uint i = 0; i <= end - begin; i++){
 a[i] = bytes(text)[i + begin - 1];
 }
 return string(a);    
 }
 */
function validUsername(string _username)
        public
        pure
        returns(bool)
    {
        uint256 len = bytes(_username).length;
        // Im Raum [4, 18]
        if ((len < 4) || (len > 18)) return false;
        // Letzte Char != ' '
        if (bytes(_username)[len-1] == 32) return false;
        // Erste Char != '0'
        return uint256(bytes(_username)[0]) != 48;
    }
// Solidity 0.6.12
/**
 	 * @notice Converts a given token amount to another token, as long as it
 	 *         meets the minimum taken amount. Amounts are debited from and
 	 *         and credited to the caller contract. It may fail if the
 	 *         minimum output amount cannot be met.
 	 * @param _from The contract address of the ERC-20 token to convert from.
 	 * @param _to The contract address of the ERC-20 token to convert to.
 	 * @param _inputAmount The amount of the _from token to be provided (may be 0).
 	 * @param _minOutputAmount The minimum amount of the _to token to be received (may be 0).
 	 * @return _outputAmount The amount of the _to token received (may be 0).
 	 */
function convertFunds(address _from, address _to, uint256 _inputAmount, uint256 _minOutputAmount) public override returns (uint256 _outputAmount)
	{
		address _sender = msg.sender;
		G.pullFunds(_from, _sender, _inputAmount);
		_outputAmount = SushiswapExchangeAbstraction._convertFunds(_from, _to, _inputAmount, _minOutputAmount);
		G.pushFunds(_to, _sender, _outputAmount);
		return _outputAmount;
	}
// Solidity 0.4.25
// Lottery Helper
// Seconds added per LT = SAT - ((Current no. of LT + 1) / SDIVIDER)^6
function getAddedTime(uint256 _rTicketSum, uint256 _tAmount)
        public
        pure
        returns (uint256)
    {
        //Luppe = 10000 = 10^4
        uint256 base = (_rTicketSum + 1).mul(10000) / SDIVIDER;
        uint256 expo = base;
        expo = expo.mul(expo).mul(expo); // ^3
        expo = expo.mul(expo); // ^6
        // div 10000^6
        expo = expo / (10**24);

        if (expo > SAT) return 0;
        return (SAT - expo).mul(_tAmount);
    }
// Solidity 0.4.25
// Lotto-Multiplier = 1 + LBase * (Current No. of Tickets / PDivider)^6
function getTMul(uint256 _ticketSum) // Unit Wei
        public
        pure
        returns(uint256)
    {
        uint256 base = _ticketSum * ZOOM / PDIVIDER;
        uint256 expo = base.mul(base).mul(base);
        expo = expo.mul(expo); // ^6
        return 1 + expo.mul(LBase) / (10**18);
    }
// Solidity 0.4.25
// get ticket price, based on current round ticketSum
//unit in ETH, no need / zoom^6
function getTPrice(uint256 _ticketSum)
        public
        pure
        returns(uint256)
    {
        uint256 base = (_ticketSum + 1).mul(ZOOM) / PDIVIDER;
        uint256 expo = base;
        expo = expo.mul(expo).mul(expo); // ^3
        expo = expo.mul(expo); // ^6
        uint256 tPrice = SLP + expo / PN;
        return tPrice;
    }
// Solidity 0.4.25
// used to draw grandpot results
// weightRange = roundWeight * grandpot / (grandpot - initGrandPot)
// grandPot = initGrandPot + round investedSum(for grandPot)
function getWeightRange(uint256 grandPot, uint256 initGrandPot, uint256 curRWeight)
        public
        pure
        returns(uint256)
    {
        //calculate round grandPot-investedSum
        uint256 grandPotInvest = grandPot - initGrandPot;
        if (grandPotInvest == 0) return 8;
        uint256 zoomMul = grandPot * ZOOM / grandPotInvest;
        uint256 weightRange = zoomMul * curRWeight / ZOOM;
        if (weightRange < curRWeight) weightRange = curRWeight;
        return weightRange;
    }
// Solidity 0.7.6
/*
 * Get the tokens owned by _owner
 */
function tokensOfOwner(address _owner) external view returns(uint256[] memory ) {
    uint256 tokenCount = balanceOf(_owner);
    if (tokenCount == 0) {
      // Return an empty array
      return new uint256[](0);
    } else {
      uint256[] memory result = new uint256[](tokenCount);
      uint256 index;
      for (index = 0; index < tokenCount; index++) {
        result[index] = tokenOfOwnerByIndex(_owner, index);
      }
      return result;
    }
  }
// Solidity 0.7.6
/*
 * Buy the token reserved for your shard
 *
 * Prerequisites:
 *  - not at max supply
 *  - sale has started
 *  - your wallet owns the shard ID in question
 *
 * Example input: To mint for FNTN // 137, you would not input
 * 137, but the tokenId in its shared contract. If you don't know this
 * ID, your best bet is the website. But it will also be after the final '/'
 * in the URL of your shard on OpenSea, eg https://opensea.io/0xetcetcetc/shardId
 */
function mintWithShard(uint tokenId) external payable nonReentrant {
    require(hasSaleStarted, "Sale hasn't started");
    require(msg.value == SHARD_PRICE, "Ether value required is 0.069");
    // Duplicate this here to potentially save people gas
    require(tokenId >= 1229 && tokenId <= 1420, "Enter a sharId from 1229 to 1420");

    // Ensure sender owns shard in question
    require(fntnContract.ownerOf(tokenId) == msg.sender, "Not the owner of this shard");

    // Convert to the shard ID (the number in "FNTN // __")
    uint shardId = tokenIdToShardId(tokenId);

    // Mint if token doesn't exist
    require(!_exists(shardId), "This token has already been minted");
    _safeMint(msg.sender, shardId);
  }
// Solidity 0.4.25
//Sources: Token contract, DApps
function pushRefIncome(address _sender)
        public
        payable
    {
        uint256 curRoundId = lotteryContract.getCurRoundId();
        uint256 _amount = msg.value;
        address sender = _sender;
        address ref = getRef(sender);
        // logs
        citizen[sender].totalSale += _amount;
        totalRefAllround += _amount;
        totalRefByRound[curRoundId] += _amount;
        // push to root
        // lower level cost less gas
        while (sender != devTeam) {
            _amount = _amount / 2;
            citizen[ref].refWallet = _amount.add(citizen[ref].refWallet);
            citizen[ref].roundRefIncome[curRoundId] += _amount;
            citizen[ref].allRoundRefIncome += _amount;
            sender = ref;
            ref = getRef(sender);
        }
        citizen[sender].refWallet = _amount.add(citizen[ref].refWallet);
        // devTeam Logs
        citizen[sender].roundRefIncome[curRoundId] += _amount;
        citizen[sender].allRoundRefIncome += _amount;
    }