lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.5.4
/**
 * @dev apply BDR exchange Abc
 * @param _value uint256 amount of BDR to exchange
 * @return uint256 the sequence of exchange request
 */
function applyExchangeToken(uint256 _value) public whenNotPaused returns (uint256) {
        uint256 trxSeq = applyCounts;
        require(exchangeTrx[trxSeq].from == address(0),"trxSeq already exist");
        require(balances[msg.sender] >= _value);
        exchangeTrx[trxSeq].executed = false;
        exchangeTrx[trxSeq].from = msg.sender;
        exchangeTrx[trxSeq].value = _value;
        applyCounts = applyCounts.add(1);
        balances[address(this)] = balances[address(this)].add(_value);
        balances[exchangeTrx[trxSeq].from] = balances[exchangeTrx[trxSeq].from].sub(_value);
        exchangeLock[exchangeTrx[trxSeq].from] = exchangeLock[exchangeTrx[trxSeq].from].add(_value);
        emit ApplyExchangeToken(exchangeTrx[trxSeq].from,exchangeTrx[trxSeq].value,trxSeq);
        emit Transfer(msg.sender,address(this),_value);
        return trxSeq;
    }
// Solidity 0.5.4
/**
 * @dev signer confirms one exchange request
 * @param _trxSeq uint256 the Sequence of exchange request
 */
function confirmExchangeTrx(uint256 _trxSeq) public onlySigner {
        require(exchangeTrx[_trxSeq].from != address(0),"_trxSeq not exist");
        require(exchangeTrx[_trxSeq].signers.length < requestSigners,"trx already has enough signers");
        require(exchangeTrx[_trxSeq].executed == false,"trx already executed");
        require(isConfirmer(_trxSeq, msg.sender) == false,"signer already confirmed");
        exchangeTrx[_trxSeq].signers.push(msg.sender);
        emit ConfirmTrx(msg.sender, _trxSeq);
    }
// Solidity 0.5.4
/**
 * @dev signer cancel confirmed exchange request
 * @param _trxSeq uint256 the Sequence of exchange request
 */
function cancelConfirm(uint256 _trxSeq) public onlySigner {
        require(exchangeTrx[_trxSeq].from != address(0),"_trxSeq not exist");
        require(isConfirmer(_trxSeq, msg.sender),"Signer didn't confirm");
        require(exchangeTrx[_trxSeq].executed == false,"trx already executed");
        uint256 len = exchangeTrx[_trxSeq].signers.length;
        for(uint256 i = 0;i < len;i++){
            if(exchangeTrx[_trxSeq].signers[i] == msg.sender){
                exchangeTrx[_trxSeq].signers[i] = exchangeTrx[_trxSeq].signers[len.sub(1)] ;
                exchangeTrx[_trxSeq].signers.length --;
                break;
            }
        }
        emit CancleConfirmTrx(msg.sender,_trxSeq);
    }
// Solidity 0.5.4
/**
 * @dev execute exchange request which confirmed by enough signers
 * @param _trxSeq uint256 the Sequence of exchange request
 */
function executeExchangeTrx(uint256 _trxSeq) public whenNotPaused{
        address from = exchangeTrx[_trxSeq].from;
        uint256 value = exchangeTrx[_trxSeq].value;
        require(from != address(0),"trxSeq not exist");
        require(exchangeTrx[_trxSeq].executed == false,"trxSeq has executed");
        require(exchangeTrx[_trxSeq].signers.length >= requestSigners);
        require(from == msg.sender|| isSigner[msg.sender]);
        require(value <= balances[address(this)]);
        _burn(address(this), value);
        exchangeLock[from] = exchangeLock[from].sub(value);
        exchangeTrx[_trxSeq].executed = true;
        AbcInterface(AbcInstance).tokenFallback(from,value,bytes(""));
        emit TokenExchange(exchangeTrx[_trxSeq].from,exchangeTrx[_trxSeq].value,false);
    }
// Solidity 0.4.18
/**
 *  @dev Contract initialization
 *  @param _ownerAddress address Token owner address
 *  @param _startTime uint256 Crowdsale end time
 *
 */
function SmartCityToken(address _ownerAddress, uint256 _startTime) public {
        owner = _ownerAddress; // token Owner
        startTime = _startTime; // token Start Time
        unlockOwnerDate = startTime + 2 years;
        balances[owner] = totalSupply; // all tokens are initially allocated to token owner
    }
// Solidity 0.4.18
/**
 *  @dev Workaround for vulnerability described here: https://docs.google.com/document/d/1YLPtQxZu1UAvO9cZ1O2RPXBbT0mooh4DYKjA_jp-RLM
 */
function _approve(address _spender, uint256 _value) internal returns(bool success) {
        require((_value == 0) || (allowances[msg.sender][_spender] == 0));

        allowances[msg.sender][_spender] = _value; // Set spender allowance

        Approval(msg.sender, _spender, _value); // Trigger Approval event
        return true;
    }
// Solidity 0.4.18
/**
 *  @dev Burns all the tokens which has not been sold during ICO
 */
function burn() public {
        if (!burned && now > startTime) {
            uint256 diff = balances[owner].sub(amountReserved); // Get the amount of unsold tokens

            balances[owner] = amountReserved;
            totalSupply = totalSupply.sub(diff); // Reduce total provision number

            burned = true;
            Burned(diff); // Trigger Burned event
        }
    }
// Solidity 0.5.12
/**
 * @notice Deploys token
 * @param _symbol Token symbol
 * @param _name Token name
 * @param _decimals Token decimals
 * @param _totalSupply Token total supply
 * @param _tokenOwner Owner of the deployed token
 * @param _tokenRegistry Token Registry
 */
function deployToken(
        string calldata _symbol,
        string calldata _name,
        uint8 _decimals,
        uint256 _totalSupply,
        address _tokenOwner,
        address _tokenRegistry,
        bool _saveHoldersHistory,
        address _allowable,
        address _getter
    )
        onlyOwner //owner - TokenRegistry
        external
        returns (address)
    {
        address tokenAddress = address(new InveniamToken(
            _symbol,
            _name,
            _decimals,
            _totalSupply * uint256(10)**_decimals,
            _tokenOwner,
            _tokenRegistry,
            _saveHoldersHistory,
            _allowable,
            _getter
        ));
        Allowable(tokenAddress).transferOwnership(_tokenOwner);
        return tokenAddress;
    }
// Solidity 0.6.12
// Stake SYRUP tokens to StakingPool
function deposit(uint256 _amount) public {
        PoolInfo storage pool = poolInfo[0];
        UserInfo storage user = userInfo[msg.sender];

        // require (_amount.add(user.amount) <= maxStaking, 'exceed max stake');

        updatePool(0);
        if (user.amount > 0) {
            uint256 pending = user.amount.mul(pool.accCakePerShare).div(1e12).sub(user.rewardDebt);
            if(pending > 0) {
                rewardToken.safeTransfer(address(msg.sender), pending);
            }
        }
        if(_amount > 0) {
            pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
            user.amount = user.amount.add(_amount);
            totalStaked = totalStaked.add(_amount);
        }
        user.rewardDebt = user.amount.mul(pool.accCakePerShare).div(1e12);

        emit Deposit(msg.sender, _amount);
    }
// Solidity 0.8.6
/// @notice Reserved for owner to mint
function ownerMint(address to, uint amount) public onlyOwner {

    uint mintsRemaining = ownerMintsRemaining;

    /// @notice Owner mints cannot be minted after the maximum has been reached
    require(mintsRemaining > 0, "Groupies: Max owner mint limit reached");

    if (amount > mintsRemaining){
      amount = mintsRemaining;
    }

    uint currentTotalSupply = totalSupply;

    _mintAmountTo(to, amount, currentTotalSupply);

    ownerMintsRemaining = mintsRemaining - amount;

    totalSupply = currentTotalSupply + amount;
  }
// Solidity 0.5.12
/**
 * @notice Adds given role to the user
 * @param _user Address of user wallet
 * @param _role Role name
 * param _withApproval Flag whether we need an approval
 */
function addRole(
        address _user,
        bytes32 _role,
        bool _withApproval,
        bool _withSameRole,
        bytes32[] storage roleNames,
        mapping(bytes32 => mapping(address => AddressList.Data)) storage roleUserData,
        mapping(bytes32 => address[]) storage roleUsers,
        mapping(address => mapping(bytes32 => address)) storage addRoleInitiators
    )
        public
    {
        if (_withApproval) {
            _checkRoleLevel(_role, _withSameRole, roleUserData);
            _checkInitiator(addRoleInitiators[_user][_role]);
        }
        require(isExists(_role, roleNames), ERROR_ROLE_NOT_FOUND);
        _user.addTo(roleUserData[_role], roleUsers[_role]);
        emit RoleAdded(_user, _role);
        if (_withApproval) {
            delete addRoleInitiators[_user][_role];
        }
    }
// Solidity 0.5.12
/**
 * @notice Requests to add given role to the user
 * @param _user Address of user wallet
 * @param _role Role name
 */
function addRoleRequest(
        address _user,
        bytes32 _role,
        bool _withSameRole,
        mapping(bytes32 => mapping(address => AddressList.Data)) storage roleUserData,
        mapping(address => mapping(bytes32 => address)) storage addRoleInitiators
    )
        public
    {
        _checkRoleLevel(_role, _withSameRole, roleUserData);
        addRoleInitiators[_user][_role] = msg.sender;
        emit RoleAddingRequested(_user, _role);
    }
// Solidity 0.5.12
/**
 * @notice Removes given role from the user
 * @param _user Address of user wallet
 * @param _role Role name
 */
function removeRole(
        address _user,
        bytes32 _role,
        bool _withApproval,
        bool _withSameRole,
        bytes32[] storage roleNames,
        mapping(bytes32 => mapping(address => AddressList.Data)) storage roleUserData,
        mapping(bytes32 => address[]) storage roleUsers,
        mapping(address => mapping(bytes32 => address)) storage removeRoleInitiators
    )
        public
    {
        if (_withApproval) {
            _checkRoleLevel(_role, _withSameRole, roleUserData);
            _checkInitiator(removeRoleInitiators[_user][_role]);
        }
        require(isExists(_role, roleNames), ERROR_ROLE_NOT_FOUND);
        _user.removeFrom(roleUserData[_role], roleUsers[_role]);
        emit RoleRemoved(_user, _role);
        if (_withApproval) {
            delete removeRoleInitiators[_user][_role];
        }
    }
// Solidity 0.5.12
/**
 * @notice Requests to remove given role to the user
 * @param _user Address of user wallet
 * @param _role Role name
 */
function removeRoleRequest(
        address _user,
        bytes32 _role,
        bool _withSameRole,
        mapping(bytes32 => mapping(address => AddressList.Data)) storage roleUserData,
        mapping(address => mapping(bytes32 => address)) storage removeRoleInitiators
    )
        public
    {
        _checkRoleLevel(_role, _withSameRole, roleUserData);
        removeRoleInitiators[_user][_role] = msg.sender;
        emit RoleRemovingRequested(_user, _role);
    }
// Solidity 0.5.12
/**
 * @notice Checks whether the role has been already added
 * @param _role Role name
 */
function isExists(
        bytes32 _role,
        bytes32[] storage roleNames
    )
        private
        view
        returns (bool)
    {
        for (uint i = 0; i < roleNames.length; i++) {
            if (_role == roleNames[i]) {
                return true;
            }
        }
        return false;
    }
// Solidity 0.8.0
/**
 * @dev Override the base isApprovedForAll(address owner, address operator) to allow us to
 *      specifically allow the opense operator to transfer tokens
 * 
 * @param owner_ owner address
 * @param operator_ operator address
 * @return bool if the operator is approved for all
 */
function isApprovedForAll(
        address owner_,
        address operator_
    ) public view override returns (bool) {
        // Whitelist OpenSea proxy contract for easy trading.
        ProxyRegistry proxyRegistry = ProxyRegistry(_proxyAddress);
        if (address(proxyRegistry.proxies(owner_)) == operator_) {
            return true;
        }
        return ERC1155.isApprovedForAll(owner_, operator_);
    }
// Solidity 0.6.12
// View function to see pending JINs on frontend.
function pendingJin(uint256 _pid, address _user)
        external
        view
        returns (uint256)
    {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][_user];
        uint256 accJinPerShare = pool.accJinPerShare;
        uint256 lpSupply = pool.lpToken.balanceOf(address(this));
        if (block.number > pool.lastRewardBlock && lpSupply != 0) {
            uint256 multiplier = getMultiplier(
                pool.lastRewardBlock,
                block.number
            );
            uint256 jinReward = multiplier
                .mul(jinPerBlock)
                .mul(pool.allocPoint)
                .div(totalAllocPoint);
            accJinPerShare = accJinPerShare.add(
                jinReward.mul(1e12).div(lpSupply)
            );
        }
        return
            user.amount.mul(accJinPerShare).div(1e12).sub(user.rewardDebt);
    }
// Solidity 0.8.7
/// @notice Withdraws the tokens that have been deposited
/// Only `withdrawer` can call this.
/// @param _to The address where the withdrawn tokens should go
function withdraw(address payable _to) external {
        uint256 balance = token.balanceOf(address(this));
        require(msg.sender == withdrawer, "the caller is not the withdrawer");
        require(block.timestamp >= release_at || service_registry.deprecated(), "deposit not released yet");
        require(balance > 0, "nothing to withdraw");
        require(token.transfer(_to, balance), "token didn't transfer");
        selfdestruct(_to); // The contract can disappear.
    }
// Solidity 0.4.26
/**
 * Set fee parameters.
 *
 * @param _fixedFee fixed fee in token units
 * @param _minVariableFee minimum variable fee in token units
 * @param _maxVariableFee maximum variable fee in token units
 * @param _variableFeeNumerator variable fee numerator
 */
function setFeeParameters (
    uint256 _fixedFee,
    uint256 _minVariableFee,
    uint256 _maxVariableFee,
    uint256 _variableFeeNumerator) public delegatable payable {
    require (msg.sender == owner);

    require (_minVariableFee <= _maxVariableFee);
    require (_variableFeeNumerator <= MAX_FEE_NUMERATOR);

    fixedFee = _fixedFee;
    minVariableFee = _minVariableFee;
    maxVariableFee = _maxVariableFee;
    variableFeeNumerator = _variableFeeNumerator;

    FeeChange (
      _fixedFee, _minVariableFee, _maxVariableFee, _variableFeeNumerator);
  }
// Solidity 0.4.26
/**
 * Calculate fee for transfer of given number of tokens.
 *
 * @param _amount transfer amount to calculate fee for
 * @return fee for transfer of given amount
 */
function calculateFee (uint256 _amount)
    public delegatable view returns (uint256 _fee) {
    require (_amount <= MAX_TOKENS_COUNT);

    _fee = safeMul (_amount, variableFeeNumerator) / FEE_DENOMINATOR;
    if (_fee < minVariableFee) _fee = minVariableFee;
    if (_fee > maxVariableFee) _fee = maxVariableFee;
    _fee = safeAdd (_fee, fixedFee);
  }
// Solidity 0.8.7
/**
 * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met.
 * @param beneficiary Address performing the token purchase
 * @param weiAmount Value in wei involved in the purchase
 */
function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal {
        require(beneficiary != address(0), "beneficiary is the zero address");
        require(weiAmount != 0, "weiAmount is 0");
        require(weiAmount >= minDeposit && weiAmount <= maxDeposit, "Amount should be within 0.05 eth and 1 eth");
        require(weiRaised().add(weiAmount) <= fundingTarget, "Crowdsale goal reached");
        
        uint256 _existingbalance = balances[beneficiary];
        uint256 _newBalance = _existingbalance.add(weiAmount);
        require(_newBalance <= maxDeposit, "Maximum deposit exceeded!!!");
        
        balances[beneficiary] = _newBalance;
    }
// Solidity 0.8.7
/**
 * 
 * @dev Kickstart the ICO by setting the opning time and manually seting the closing time to a week after the opening time.
 */
function startIco( uint256 _openingTime) external onlyAdmin {
        require(_openingTime >= block.timestamp, "JPEGVaultICO: opening time is before current block timestamp");
        require(openingTime == 0 || hasClosed(), "You can't restart ICO in the middle of sales period");
        openingTime = _openingTime;
        closingTime = openingTime + 1 weeks;
     }
// Solidity 0.7.3
// This is used to prevent stack too deep errors
function calculateFee(
        int128 _gLiq,
        int128[] memory _bals,
        Storage.Curve storage curve,
        int128[] memory _weights
    ) internal view returns (int128 psi_) {
        int128 _beta = curve.beta;
        int128 _delta = curve.delta;

        psi_ = calculateFee(_gLiq, _bals, _beta, _delta, _weights);
    }
// Solidity 0.6.12
// Admin calls this function.
function setPoolInfo(
        uint256 _poolId,
        address _vault,
        IERC20 _token,
        uint256 _allocPoint,
        bool _withUpdate
    ) external onlyOwner {
        if (_withUpdate) {
            massUpdatePools();
        }

        if (_poolId >= poolLength) {
            poolLength = _poolId + 1;
        }

        vaultMap[_poolId] = _vault;

        totalAllocPoint = totalAllocPoint.sub(poolMap[_vault].allocPoint).add(_allocPoint);
        poolMap[_vault].allocPoint = _allocPoint;

        _token.approve(sodaMaster.pool(), type(uint256).max);
    }
// Solidity 0.4.22
// ===== Admin functions ===== //
function setFeeSchedule(
        uint _flatFee,
        uint _contractFee,
        uint _exerciseFee,
        uint _settlementFee
    ) public auth {
        flatFee = _flatFee;
        contractFee = _contractFee;
        exerciseFee = _exerciseFee;
        settlementFee = _settlementFee;

        require(contractFee < 5 ether);
        require(flatFee < 6.95 ether);
        require(exerciseFee < 20 ether);
        require(settlementFee < 20 ether);
    }
// Solidity 0.4.22
// ========== PUT OPTIONS EXCHANGE ========== //
function putBtoWithSto(
        uint    amount,
        uint    expiration,
        bytes32 nonce,
        uint    price,
        uint    size,
        uint    strike,
        uint    validUntil,
        bytes32 r,
        bytes32 s,
        uint8   v
    ) public hasFee(amount) {
        bytes32 h = keccak256(Action.SellPutToOpen, expiration, nonce, price, size, strike, validUntil, this);
        address maker = _getMaker(h, v, r, s);

        _validateOrder(amount, expiration, h, maker, price, validUntil, size, strike);
        _buyPutToOpen(amount, expiration, price, strike, msg.sender);
        _sellPutToOpen(amount, expiration, price, strike, maker);
    }
// Solidity 0.6.12
// Deposit tokens to Pool for Token allocation.
function deposit(uint256 _pid, uint256 _amount) public {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];

        updatePool(_pid);
        if (user.amount > 0) {
            uint256 pending = user.amount.mul(pool.accTokenPerShare).div(1e12).sub(user.rewardDebt);
            safeTokenTransfer(msg.sender, pending);
        }
        if(_amount > 0) { //kevin
            pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
            user.amount = user.amount.add(_amount);
        }
        user.rewardDebt = user.amount.mul(pool.accTokenPerShare).div(1e12);
        emit Deposit(msg.sender, _pid, _amount);
    }
// Solidity 0.6.12
// DepositFor tokens to Pool for Token allocation.
function depositFor(address _beneficiary, uint256 _pid, uint256 _amount) public {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][_beneficiary];
        updatePool(_pid);
        if (user.amount > 0) {
            uint256 pending = user.amount.mul(pool.accTokenPerShare).div(1e12).sub(user.rewardDebt);
            safeTokenTransfer(_beneficiary, pending);
        }
        if(_amount > 0) { //kevin
            pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount);
            user.amount = user.amount.add(_amount);
        }
        user.rewardDebt = user.amount.mul(pool.accTokenPerShare).div(1e12);
        emit Deposit(_beneficiary, _pid, _amount);
    }
// Solidity 0.5.4
/**
 	 * @dev Store the PublicKey info for a Name
 	 * @param _id The ID of the Name
 	 * @param _defaultKey The default public key for this Name
 	 * @param _writerKey The writer public key for this Name
 	 * @return true on success
 	 */
function initialize(address _id, address _defaultKey, address _writerKey)
		external
		isName(_id)
		keyNotTaken(_defaultKey)
		keyNotTaken(_writerKey)
		onlyFactory returns (bool) {
		require (!isExist(_id));

		keyToNameId[_defaultKey] = _id;
		if (_defaultKey != _writerKey) {
			keyToNameId[_writerKey] = _id;
		}
		PublicKey storage _publicKey = publicKeys[_id];
		_publicKey.created = true;
		_publicKey.defaultKey = _defaultKey;
		_publicKey.writerKey = _writerKey;
		_publicKey.keys.push(_defaultKey);
		if (_defaultKey != _writerKey) {
			_publicKey.keys.push(_writerKey);
		}
		return true;
	}
// Solidity 0.5.4
/**
 	 * @dev Add publicKey to list for a Name
 	 * @param _id The ID of the Name
 	 * @param _key The publicKey to be added
 	 * @param _nonce The signed uint256 nonce (should be Name's current nonce + 1)
 	 * @param _signatureV The V part of the signature
 	 * @param _signatureR The R part of the signature
 	 * @param _signatureS The S part of the signature
 	 */
function addKey(address _id,
		address _key,
		uint256 _nonce,
		uint8 _signatureV,
		bytes32 _signatureR,
		bytes32 _signatureS
	) public isName(_id) onlyAdvocate(_id) keyNotTaken(_key) senderNameNotCompromised {
		require (_nonce == _nameFactory.nonces(_id).add(1));
		bytes32 _hash = keccak256(abi.encodePacked(address(this), _id, _key, _nonce));
		require (ecrecover(_hash, _signatureV, _signatureR, _signatureS) == _key);
		require (_addKey(_id, _key));
	}
// Solidity 0.5.4
/**
 	 * @dev Get list of publicKeys of a Name
 	 * @param _id The ID of the Name
 	 * @param _from The starting index
 	 * @param _to The ending index
 	 * @return list of publicKeys
 	 */
function getKeys(address _id, uint256 _from, uint256 _to) public isName(_id) view returns (address[] memory) {
		require (isExist(_id));
		require (_from >= 0 && _to >= _from);

		PublicKey memory _publicKey = publicKeys[_id];
		require (_publicKey.keys.length > 0);

		if (_to >  _publicKey.keys.length.sub(1)) {
			_to = _publicKey.keys.length.sub(1);
		}
		address[] memory _keys = new address[](_to.sub(_from).add(1));

		for (uint256 i = _from; i <= _to; i++) {
			_keys[i.sub(_from)] = _publicKey.keys[i];
		}
		return _keys;
	}
// Solidity 0.5.4
/**
 	 * @dev Remove publicKey from the list
 	 * @param _id The ID of the Name
 	 * @param _key The publicKey to be removed
 	 */
function removeKey(address _id, address _key) public isName(_id) onlyAdvocate(_id) senderNameNotCompromised {
		require (this.isKeyExist(_id, _key));

		PublicKey storage _publicKey = publicKeys[_id];

		// Can't remove default key
		require (_key != _publicKey.defaultKey);
		// Can't remove writer key
		require (_key != _publicKey.writerKey);
		// Has to have at least defaultKey/writerKey
		require (_publicKey.keys.length > 1);

		keyToNameId[_key] = address(0);

		uint256 index;
		for (uint256 i = 0; i < _publicKey.keys.length; i++) {
			if (_publicKey.keys[i] == _key) {
				index = i;
				break;
			}
		}

		for (uint256 i = index; i < _publicKey.keys.length.sub(1); i++) {
			_publicKey.keys[i] = _publicKey.keys[i+1];
		}
		_publicKey.keys.length--;

		uint256 _nonce = _nameFactory.incrementNonce(_id);
		require (_nonce > 0);

		emit RemoveKey(_id, _key, _nonce);
	}