lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.6.12
/*
 @dev amount of tokens accrued, not accounting for tokens paid
 @param _time the timestamp to perform the calculation
 @param _bgn  the start time of the contract
 @param _clf  the timestamp of the cliff
 @param _end  the end time of the contract
 @param _tot  the total amount of the contract
 @param _rxd  the number of gems received
 */
function unpaid(uint256 _time, uint48 _bgn, uint48 _clf, uint48 _fin, uint128 _tot, uint128 _rxd) internal pure returns (uint256 amt) {
        amt = _time < _clf ? 0 : sub(accrued(_time, _bgn, _fin, _tot), _rxd);
    }
// Solidity 0.6.12
/*
 @dev Allows governance or the manager to end pre-maturely a vesting contract
 @param _id  The id of the vesting contract
 @param _end A scheduled time to end the vest
 */
function _yank(uint256 _id, uint256 _end) internal lock {
        require(wards[msg.sender] == 1 || awards[_id].mgr == msg.sender, "DssVest/not-authorized");
        Award memory _award = awards[_id];
        require(_award.usr != address(0), "DssVest/invalid-award");
        if (_end < block.timestamp) {
            _end = block.timestamp;
        }
        if (_end < _award.fin) {
            uint48 end = toUint48(_end);
            awards[_id].fin = end;
            if (end < _award.bgn) {
                awards[_id].bgn = end;
                awards[_id].clf = end;
                awards[_id].tot = 0;
            } else if (end < _award.clf) {
                awards[_id].clf = end;
                awards[_id].tot = 0;
            } else {
                awards[_id].tot = toUint128(
                                    add(
                                        unpaid(_end, _award.bgn, _award.clf, _award.fin, _award.tot, _award.rxd),
                                        _award.rxd
                                    )
                                );
            }
        }

        emit Yank(_id, _end);
    }
// Solidity 0.7.5
/**
 * @notice Allows the owner to execute custom transactions
 * @param target address
 * @param value uint256
 * @param signature string
 * @param data bytes
 * @dev Only owner can call it
 */
function executeTransaction(
    address target,
    uint256 value,
    string memory signature,
    bytes memory data
  ) external payable onlyOwner returns (bytes memory) {
    bytes memory callData;
    if (bytes(signature).length == 0) {
      callData = data;
    } else {
      callData = abi.encodePacked(bytes4(keccak256(bytes(signature))), data);
    }

    require(
      target != address(0),
      "Orchestrator::executeTransaction: target can't be zero"
    );

    // solium-disable-next-line security/no-call-value
    (bool success, bytes memory returnData) =
      target.call{value: value}(callData);
    require(
      success,
      "Orchestrator::executeTransaction: Transaction execution reverted."
    );

    emit TransactionExecuted(target, value, signature, data);
    (target, value, signature, data);

    return returnData;
  }
// Solidity 0.8.4
/**
 * @dev Internal setter for the voting period.
 *
 * Emits a {VotingPeriodSet} event.
 */
function _setVotingPeriod(uint256 newVotingPeriod) internal virtual {
        // voting period must be at least one block long
        require(newVotingPeriod > 0, "GovernorSettings: voting period too low");
        emit VotingPeriodSet(_votingPeriod, newVotingPeriod);
        _votingPeriod = newVotingPeriod;
    }
// Solidity 0.4.24
/**
 * @dev transfer token for a specified address
 * @param _to The address to transfer to.
 * @param _value The amount to be transferred.
 * @return bool success
 */
function transfer(address _to, uint256 _value) whenNotPaused notBlacklisted(msg.sender) notBlacklisted(_to) public returns (bool) {
        require(_to != address(0));
        require(_value <= balances[msg.sender]);

        balances[msg.sender] = balances[msg.sender].sub(_value);
        balances[_to] = balances[_to].add(_value);
        emit Transfer(msg.sender, _to, _value);
        return true;
    }
// Solidity 0.8.4
/**
 * @dev Return total stake amount of `account`
 */
function getStakeAmount(
        address account
    )
        external
        view
        returns (uint256)
    {
        uint256[] memory stakeIds = stakerIds[account];
        uint256 totalStakeAmount;
        for (uint256 i = 0; i < stakeIds.length; i++) {
            totalStakeAmount += stakes[stakeIds[i]].amount;
        }
        return totalStakeAmount;
    }
// Solidity 0.8.4
/**
 * @dev Return total stake amount that have been in the pool from `fromDate`
 * Requirements:
 *
 * - `fromDate` must be past date
 */
function getEligibleStakeAmount(
        uint256 fromDate
    )
        public
        override
        view
        returns (uint256)
    {
        require(fromDate <= block.timestamp, "StakeToken#getEligibleStakeAmount: NO_PAST_DATE");
        uint256 totalSAmount;

        for (uint256 i = 1; i <= tokenIds; i++) {
            if (_exists(i)) {
                Stake memory stake = stakes[i];
                if (stake.depositedAt > fromDate) {
                    break;
                }
                totalSAmount += stake.amount * stake.multiplier / multiplierDenominator;
            }
        }

        return totalSAmount;
    }
// Solidity 0.8.4
/**
 * @dev Returns StakeToken multiplier.
 *
 * 0 < `tokenId` <300: 120.
 * 300 <= `tokenId` <4000: 110.
 * 4000 <= `tokenId`: 100.
 */
function _getMultiplier()
        private
        view
        returns (uint256)
    {
        if (tokenIds < 300) {
            return 120;
        } else if (300 <= tokenIds && tokenIds < 4000) {
            return 110;
        } else {
            return 100;
        }
    }
// Solidity 0.8.4
/**
 * @dev Mint a new StakeToken.
 * Requirements:
 *
 * - `account` must not be zero address, check ERC721 {_mint}
 * - `amount` must not be zero
 * @param account address of recipient.
 * @param amount mint amount.
 * @param depositedAt timestamp when stake was deposited.
 */
function _mint(
        address account,
        uint256 amount,
        uint256 depositedAt
    )
        internal
        virtual
        returns (uint256)
    {
        require(amount > 0, "StakeToken#_mint: INVALID_AMOUNT");
        tokenIds++;
        uint256 multiplier = _getMultiplier();
        super._mint(account, tokenIds);
        Stake storage newStake = stakes[tokenIds];
        newStake.amount = amount;
        newStake.multiplier = multiplier;
        newStake.depositedAt = depositedAt;
        stakerIds[account].push(tokenIds);

        return tokenIds;
    }
// Solidity 0.8.4
/**
 * @dev Burn stakeToken.
 * Requirements:
 *
 * - `stakeId` must exist in stake pool
 * @param stakeId id of buring token.
 */
function _burn(
        uint256 stakeId
    )
        internal
        override
    {
        require(_exists(stakeId), "StakeToken#_burn: STAKE_NOT_FOUND");
        address stakeOwner = ownerOf(stakeId);
        super._burn(stakeId);
        delete stakes[stakeId];
        uint256[] storage stakeIds = stakerIds[stakeOwner];
        for (uint256 i = 0; i < stakeIds.length; i++) {
            if (stakeIds[i] == stakeId) {
                if (i != stakeIds.length - 1) {
                    stakeIds[i] = stakeIds[stakeIds.length - 1];
                }
                stakeIds.pop();
                break;
            }
        }
    }
// Solidity 0.8.4
/**
 * @dev Decrease stake amount.
 * If stake amount leads to be zero, the stake is burned.
 * Requirements:
 *
 * - `stakeId` must exist in stake pool
 * @param stakeId id of buring token.
 * @param amount to withdraw.
 */
function _decreaseStakeAmount(
        uint256 stakeId,
        uint256 amount
    )
        internal
        virtual
    {
        require(_exists(stakeId), "StakeToken#_decreaseStakeAmount: STAKE_NOT_FOUND");
        require(amount <= stakes[stakeId].amount, "StakeToken#_decreaseStakeAmount: INSUFFICIENT_STAKE_AMOUNT");
        if (amount == stakes[stakeId].amount) {
            _burn(stakeId);
        } else {
            stakes[stakeId].amount = stakes[stakeId].amount.sub(amount);
            emit StakeAmountDecreased(stakeId, amount);
        }
    }
// Solidity 0.8.4
/**
 * @dev Sweep funds
 * Accessible by operators
 */
function sweep(
        address token_,
        address to,
        uint256 amount
    )
        public
        onlyOperator
    {
        IERC20 token = IERC20(token_);
        // balance check is being done in ERC20
        token.transfer(to, amount);
        emit Swept(msg.sender, token_, to, amount);
    }
// Solidity 0.4.23
/**
 * @dev Updates set of the globally enabled features (`features`),
 *      taking into account sender's permissions.=
 * @dev Requires transaction sender to have `ROLE_FEATURE_MANAGER` permission.
 * @param mask bitmask representing a set of features to enable/disable
 */
function updateFeatures(uint256 mask) public {
    // caller must have a permission to update global features
    require(isSenderInRole(ROLE_FEATURE_MANAGER));

    // evaluate new features set and assign them
    features = evaluateBy(msg.sender, features, mask);

    // fire an event
    emit FeaturesUpdated(msg.sender, mask, features);
  }
// Solidity 0.4.23
/**
 * @dev Updates set of permissions (role) for a given operator,
 *      taking into account sender's permissions.
 * @dev Setting role to zero is equivalent to removing an operator.
 * @dev Setting role to `FULL_PRIVILEGES_MASK` is equivalent to
 *      copying senders permissions (role) to an operator.
 * @dev Requires transaction sender to have `ROLE_ROLE_MANAGER` permission.
 * @param operator address of an operator to alter permissions for
 * @param role bitmask representing a set of permissions to
 *      enable/disable for an operator specified
 */
function updateRole(address operator, uint256 role) public {
    // caller must have a permission to update user roles
    require(isSenderInRole(ROLE_ROLE_MANAGER));

    // evaluate the role and reassign it
    userRoles[operator] = evaluateBy(msg.sender, userRoles[operator], role);

    // fire an event
    emit RoleUpdated(msg.sender, operator, role, userRoles[operator]);
  }
// Solidity 0.4.23
/**
 * @dev Based on the actual role provided (set of permissions), operator address,
 *      and role required (set of permissions), calculate the resulting
 *      set of permissions (role).
 * @dev If operator is super admin and has full permissions (FULL_PRIVILEGES_MASK),
 *      the function will always return `required` regardless of the `actual`.
 * @dev In contrast, if operator has no permissions at all (zero mask),
 *      the function will always return `actual` regardless of the `required`.
 * @param operator address of the contract operator to use permissions of
 * @param actual input set of permissions to modify
 * @param required desired set of permissions operator would like to have
 * @return resulting set of permissions this operator can set
 */
function evaluateBy(address operator, uint256 actual, uint256 required) public constant returns(uint256) {
    // read operator's permissions
    uint256 p = userRoles[operator];

    // taking into account operator's permissions,
    // 1) enable permissions requested on the `current`
    actual |= p & required;
    // 2) disable permissions requested on the `current`
    actual &= FULL_PRIVILEGES_MASK ^ (p & (FULL_PRIVILEGES_MASK ^ required));

    // return calculated result (actual is not modified)
    return actual;
  }
// Solidity 0.4.15
// Returns TUTs rate per 1 ETH depending on current time
function getRateByTime() public constant returns (uint256) {
        uint256 timeNow = now;
        if (timeNow > (startTime + 94 * unitTimeSecs)) {
            return 1500;
        } else if (timeNow > (startTime + 87 * unitTimeSecs)) {
            return 1575; // + 5%
        } else if (timeNow > (startTime + 80 * unitTimeSecs)) {
            return 1650; // + 10%
        } else if (timeNow > (startTime + 73 * unitTimeSecs)) {
            return 1800; // + 20%
        } else if (timeNow > (startTime + 56 * unitTimeSecs)) {
            return 2025; // + 35%
        } else if (timeNow > (startTime + 42 * unitTimeSecs)) {
            return 2100; // + 40%
        } else if (timeNow > (startTime + 28 * unitTimeSecs)) {
            return 2175; // + 45%
        } else {
            return 2250; // + 50%
        }
    }
// Solidity 0.4.23
/**
 * @dev Mints (creates) some tokens to address specified
 * @dev The value passed is treated as number of units (see `ONE_UNIT`)
 *      to achieve natural impression on token quantity
 * @dev Requires sender to have `ROLE_TOKEN_CREATOR` permission
 * @param _to an address to mint tokens to
 * @param _value an amount of tokens to mint (create)
 */
function mint(address _to, uint256 _value) public {
    // calculate native value, taking into account `decimals`
    uint256 value = _value * ONE_UNIT;

    // arithmetic overflow and non-zero value check
    require(value > _value);

    // delegate call to native `mintNative`
    mintNative(_to, value);
  }
// Solidity 0.4.23
/**
 * @dev Mints (creates) some tokens to address specified
 * @dev The value specified is treated as is without taking
 *      into account what `decimals` value is
 * @dev Requires sender to have `ROLE_TOKEN_CREATOR` permission
 * @param _to an address to mint tokens to
 * @param _value an amount of tokens to mint (create)
 */
function mintNative(address _to, uint256 _value) public {
    // check if caller has sufficient permissions to mint tokens
    require(isSenderInRole(ROLE_TOKEN_CREATOR));

    // non-zero recipient address check
    require(_to != address(0));

    // non-zero _value and arithmetic overflow check on the total supply
    // this check automatically secures arithmetic overflow on the individual balance
    require(tokensTotal + _value > tokensTotal);

    // increase `_to` address balance
    tokenBalances[_to] += _value;

    // increase total amount of tokens value
    tokensTotal += _value;

    // fire ERC20 compliant transfer event
    emit Transfer(address(0), _to, _value);

    // fire a mint event
    emit Minted(msg.sender, _to, _value);
  }
// Solidity 0.4.23
/**
 * @dev Burns (destroys) some tokens from the address specified
 * @dev The value specified is treated as is without taking
 *      into account what `decimals` value is
 * @dev Requires sender to have `ROLE_TOKEN_DESTROYER` permission
 * @param _from an address to burn some tokens from
 * @param _value an amount of tokens to burn (destroy)
 */
function burnNative(address _from, uint256 _value) public {
    // check if caller has sufficient permissions to burn tokens
    require(isSenderInRole(ROLE_TOKEN_DESTROYER));

    // non-zero burn value check
    require(_value != 0);

    // verify `_from` address has enough tokens to destroy
    // (basically this is a arithmetic overflow check)
    require(tokenBalances[_from] >= _value);

    // decrease `_from` address balance
    tokenBalances[_from] -= _value;

    // decrease total amount of tokens value
    tokensTotal -= _value;

    // fire ERC20 compliant transfer event
    emit Transfer(_from, address(0), _value);

    // fire a burn event
    emit Burnt(msg.sender, _from, _value);
  }
// Solidity 0.5.6
/* User can allow another smart contract to spend some shares in his behalf
 *  (this function should be called by user itself)
 *  @param _spender another contract's address
 *  @param _value number of tokens
 *  @param _extraData Data that can be sent from user to another contract to be processed
 *  bytes - dynamically-sized byte array,
 *  see http://solidity.readthedocs.io/en/v0.4.15/types.html#dynamically-sized-byte-array
 *  see possible attack information in comments to function 'approve'
 *  > this may be used to convert pre-ICO tokens to ICO tokens
 */
function approveAndCall(address _spender, uint256 _value, bytes memory _extraData) public returns (bool success) {

        approve(_spender, _value);

        // 'spender' is another contract that implements code as prescribed in 'allowanceRecipient' above
        allowanceRecipient spender = allowanceRecipient(_spender);

        // our contract calls 'receiveApproval' function of another contract ('allowanceRecipient') to send information about
        // allowance and data sent by user
        // 'this' is this (our) contract address
        if (spender.receiveApproval(msg.sender, _value, address(this), _extraData)) {
            emit DataSentToAnotherContract(msg.sender, _spender, _extraData);
            return true;
        }
        else return false;
    }
// Solidity 0.5.6
/* https://github.com/ethereum/EIPs/issues/677
 * transfer tokens with additional info to another smart contract, and calls its correspondent function
 * @param address _to - another smart contract address
 * @param uint256 _value - number of tokens
 * @param bytes _extraData - data to send to another contract
 * > this may be used to convert pre-ICO tokens to ICO tokens
 */
function transferAndCall(address _to, uint256 _value, bytes memory _extraData) public returns (bool success){

        transferFrom(msg.sender, _to, _value);

        tokenRecipient receiver = tokenRecipient(_to);

        if (receiver.tokenFallback(msg.sender, _value, _extraData)) {
            emit DataSentToAnotherContract(msg.sender, _to, _extraData);
            return true;
        }
        else return false;
    }
// Solidity 0.5.6
/* set time for start and time for end pre-ICO
 * time is integer representing block timestamp
 * in UNIX Time,
 * see: https://www.epochconverter.com
 * @param uint256 startTime - time to start
 * @param uint256 endTime - time to end
 * should be taken into account that
 * "block.timestamp" can be influenced by miners to a certain degree.
 * That means that a miner can "choose" the block.timestamp, to a certain degree,
 * to change the outcome of a transaction in the mined block.
 * see:
 * http://solidity.readthedocs.io/en/v0.4.15/frequently-asked-questions.html#are-timestamps-now-block-timestamp-reliable
 */
function startSale(uint256 _startUnixTime, uint256 _endUnixTime) public onlyBy(owner) returns (bool success){

        require(balanceOf[address(this)] > 0);
        require(salesCounter < maxSalesAllowed);

        // time for sale can be set only if:
        // this is first sale (saleStartUnixTime == 0 && saleEndUnixTime == 0) , or:
        // previous sale finished ( saleIsFinished() )
        require(
            (saleStartUnixTime == 0 && saleEndUnixTime == 0) || saleIsFinished()
        );
        // time can be set only for future
        require(_startUnixTime > now && _endUnixTime > now);
        // end time should be later than start time
        require(_endUnixTime - _startUnixTime > 0);

        saleStartUnixTime = _startUnixTime;
        saleEndUnixTime = _endUnixTime;
        salesCounter = salesCounter + 1;

        emit SaleStarted(_startUnixTime, _endUnixTime, salesCounter);

        return true;
    }
// Solidity 0.5.6
/*  After sale contract owner
 *  (can be another contract or account)
 *  can withdraw all collected Ether
 */
function withdrawAllToOwner() public onlyBy(owner) returns (bool) {

        // only after sale is finished:
        require(saleIsFinished());
        uint256 sumInWei = address(this).balance;

        if (
        // makes withdrawal and returns true or false
            !msg.sender.send(address(this).balance)
        ) {
            return false;
        }
        else {
            // event
            emit Withdrawal(msg.sender, sumInWei);
            return true;
        }
    }
// Solidity 0.7.6
/**
 * @dev Transfers the tokens from a Taraxa owned wallet to the participant.
 *
 * Emits a {TokensSent} event.
 */
function multisendToken(
        address token,
        address[] calldata _recipients,
        uint256[] calldata _amounts
    ) public {
        require(_recipients.length <= 200, 'Multisend: max transfers per tx exceeded');
        require(
            _recipients.length == _amounts.length,
            'Multisend: contributors and balances have different sizes'
        );

        uint256 total = 0;
        IERC20 erc20token = IERC20(token);
        uint8 i = 0;
        for (i; i < _recipients.length; i++) {
            erc20token.transferFrom(msg.sender, _recipients[i], _amounts[i]);
            total += _amounts[i];
        }
        emit TokensSent(total, token);
    }
// Solidity 0.4.18
//200m coins total
//reward begins at 500 and is cut in half every reward era (as tokens are mined)
function getMiningReward() public constant returns (uint) {
        //once we get half way thru the coins, only get 250 per block

         //every reward era, the reward amount halves.

         return (500 * 10**uint(decimals) ).div( 2**rewardEra ) ;

    }
// Solidity 0.5.6
/**
 * @dev Getting Deex Token prize of _lastParticipant
 * @param _lastParticipant Address of _lastParticipant
 */
function calculateLastDeexPrize(address _lastParticipant) public view returns(uint) {

        uint payout = 0;
        uint totalSupply = (lastTotalDeexSupplyOfDragons.add(lastTotalDeexSupplyOfHamsters)).mul(80).div(100);

        if (depositDragons[currentRound - 1][_lastParticipant] > 0) {
            payout = totalSupply.mul(depositDragons[currentRound - 1][_lastParticipant]).div(lastTotalSupplyOfDragons);
        }

        if (depositHamsters[currentRound - 1][_lastParticipant] > 0) {
            payout = totalSupply.mul(depositHamsters[currentRound - 1][_lastParticipant]).div(lastTotalSupplyOfHamsters);
        }

        return payout;
    }
// Solidity 0.4.10
// To transfer tokens by proxy
function transferFrom(address _from, address _to, uint256 _amount)
        public
        canEnter
        isHolder(_to)
        returns (bool)
    {
        require(_amount <= holders[_from].allowances[msg.sender]);
        
        Holder from = holders[_from];
        Holder to = holders[_to];

        from.allowances[msg.sender] -= _amount;
        Transfer(_from, _to, _amount);
        return xfer(from, to, _amount);
    }
// Solidity 0.4.10
// Processes token transfers and subsequent change in voting power
function xfer(Holder storage _from, Holder storage _to, uint _amount)
        internal
        returns (bool)
    {
        // Ensure dividends are up to date at current balances
        updateDividendsFor(_from);
        updateDividendsFor(_to);

        // Remove existing votes
        revoke(_from);
        revoke(_to);

        // Transfer tokens
        _from.tokenBalance -= _amount;
        _to.tokenBalance += _amount;

        // Revote accoring to changed token balances
        revote(_from);
        revote(_to);

        // Force election
        election();
        return true;
    }
// Solidity 0.4.10
//
// Security Functions
//
// Cause the contract to Panic. This will block most state changing
// functions for a set delay.
function PANIC()
        public
        isHolder(msg.sender)
        returns (bool)
    {
        // A blocking holder requires at least 10% of tokens
        require(holders[msg.sender].tokenBalance >= totalSupply / 10);
        
        panicked = true;
        timeToCalm = uint40(now + PANICPERIOD);
        Panicked(msg.sender);
        return true;
    }