lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.6.12
/**
 * @param _user address of user to add to the list
 * @return Returns user's total calculated reward.
 */
function getTotalReward(address _user) public view returns (uint256) {
        if (getStakeAmount(_user) == 0) {
            return 0;
        }
        
        uint256 totalReward = 0;
        uint256 dateFrom = stakingFinishDate != 0 ? stakingFinishDate : now;
        for (uint256 i = phases.length - 1; i >= 0; i--) {
            if (phases[i].startDate != 0) {
                bool firstUserPhase = pool[_user].startDate >= phases[i].startDate;
                uint256 dateTo = firstUserPhase ? pool[_user].startDate : phases[i].startDate;
                uint256 hoursStaked = (dateFrom.sub(dateTo)).div(3600);
                uint256 reward = getStakeAmount(_user).mul(phases[i].rate).mul(hoursStaked);
                totalReward = totalReward.add(reward);
                
                if (firstUserPhase) {
                    break;
                }

                dateFrom = phases[i].startDate;
            }
        }

        return totalReward.add(pool[_user].reward);
    }
// Solidity 0.4.11
/// @notice `msg.sender` approves `_spender` to send `_amount` tokens on
///  its behalf, and then a function is triggered in the contract that is
///  being approved, `_spender`. This allows users to use their tokens to
///  interact with contracts in one function call instead of two
/// @param _spender The address of the contract able to transfer the tokens
/// @param _amount The amount of tokens to be approved for transfer
/// @return True if the function call was successful
function approveAndCall(address _spender, uint256 _amount, bytes _extraData
    ) returns (bool success) {
        if (!approve(_spender, _amount)) throw;

        // This portion is copied from ConsenSys's Standard Token Contract. It
        //  calls the receiveApproval function that is part of the contract that
        //  is being approved (`_spender`). The function should look like:
        //  `receiveApproval(address _from, uint256 _amount, address
        //  _tokenContract, bytes _extraData)` It is assumed that the call
        //  *should* succeed, otherwise the plain vanilla approve would be used
        ApproveAndCallReceiver(_spender).receiveApproval(
            msg.sender,
            _amount,
            this,
            _extraData
        );

        return true;
    }
// Solidity 0.4.18
//human 0.1 standard. Just an arbitrary versioning scheme.
//
// CUSTOM AREA
// Token name should be same as above contract
function eECToken(
        ) {
        balances[msg.sender] = 140000000000000000000000000;               // Give the creator all initial tokens (100000 for example)
        totalSupply = 140000000000000000000000000;                        // Update total supply (100000 for example)
        name = "eEthereum Classic";                                   // Set the name for display purposes
        decimals = 18;                            // Amount of decimals for display purposes
        symbol = "EEC";                               // Set the symbol for display purposes
    }
// Solidity 0.4.21
// Issue tokens to investors and transfer ether to wallet
function issueTokens(uint256 _price, uint _state) private {
        require(walletAddress != address(0));
		
        uint tokenAmount = msg.value.mul(_price).mul(10**18).div(1 ether);
        balances[msg.sender] = balances[msg.sender].add(tokenAmount);
        totalInvestedAmountOf[msg.sender] = totalInvestedAmountOf[msg.sender].add(msg.value);
        totalRemainingTokensForSales = totalRemainingTokensForSales.sub(tokenAmount);
        totalInvestedAmount = totalInvestedAmount.add(msg.value);
        walletAddress.transfer(msg.value);
        emit IssueTokens(msg.sender, msg.value, tokenAmount, _state);
    }
// Solidity 0.6.12
// function lockToGov() public onlyOwner {
//     _transfer(_owner, swapGovContract, MINEREWARD); // transfer/freeze to swapGovContract
//     lockedAmount = lockedAmount.add(MINEREWARD);
// }
function lock(address _account, uint256 _amount, uint256 _type) public onlyOwner {
        require(_account != address(0), "Cannot transfer to the zero address");
        require(lockedUser[_account].lockedAmount == 0, "exist locked token");
        require(_account != swapGovContract, "equal to swapGovContract");
        lockedUser[_account].initLock = _amount;
        lockedUser[_account].lockedAmount = _amount;
        lockedUser[_account].lastUnlockTs = block.timestamp;
        lockedUser[_account].releaseType = _type;
        _balances[_msgSender()] = _balances[_msgSender()].sub(_amount);
        _balances[_account] = _balances[_account].add(_amount);
        emit Lock(_account, block.timestamp, _amount, _type);
        emit Transfer(_msgSender(), _account, _amount);
    }
// Solidity 0.6.12
/**
 * @dev Transfer tokens to multiple addresses.
 */
function batchTransfer(address[] memory addressList, uint256[] memory amountList) public onlyOwner returns (bool) {
        uint256 length = addressList.length;
        require(addressList.length == amountList.length, "Inconsistent array length");
        require(length > 0 && length <= 150, "Invalid number of transfer objects");
        uint256 amount;
        for (uint256 i = 0; i < length; i++) {
            require(amountList[i] > 0, "The transfer amount cannot be 0");
            require(addressList[i] != address(0), "Cannot transfer to the zero address");
            require(!isBlackListed(addressList[i]));
            amount = amount.add(amountList[i]);
            _balances[addressList[i]] = _balances[addressList[i]].add(amountList[i]);
            emit Transfer(_msgSender(), addressList[i], amountList[i]);
        }
        require(_balances[_msgSender()] >= amount, "Not enough tokens to transfer");
        _balances[_msgSender()] = _balances[_msgSender()].sub(amount);
        return true;
    }
// Solidity 0.5.16
// Note: this could be made external in a utility contract if addressCache was made public
// (used for deployment)
function isResolverCached(AddressResolver _resolver) external view returns (bool) {
        if (resolver != _resolver) {
            return false;
        }

        // otherwise, check everything
        for (uint i = 0; i < resolverAddressesRequired.length; i++) {
            bytes32 name = resolverAddressesRequired[i];
            // false if our cache is invalid or if the resolver doesn't have the required address
            if (resolver.getAddress(name) != addressCache[name] || addressCache[name] == address(0)) {
                return false;
            }
        }

        return true;
    }
// Solidity 0.5.16
// The collateral / issuance ratio ( debt / collateral ) is higher when there is less collateral backing their debt
// Upper bound liquidationRatio is 1 + penalty (100% + 10% = 110%) to allow collateral value to cover debt and liquidation penalty
function setLiquidationRatio(uint _liquidationRatio) external onlyOwner {
        require(
            _liquidationRatio <= MAX_LIQUIDATION_RATIO.divideDecimal(SafeDecimalMath.unit().add(getLiquidationPenalty())),
            "liquidationRatio > MAX_LIQUIDATION_RATIO / (1 + penalty)"
        );

        // MIN_LIQUIDATION_RATIO is a product of target issuance ratio * RATIO_FROM_TARGET_BUFFER
        // Ensures that liquidation ratio is set so that there is a buffer between the issuance ratio and liquidation ratio.
        uint MIN_LIQUIDATION_RATIO = getIssuanceRatio().multiplyDecimal(RATIO_FROM_TARGET_BUFFER);
        require(_liquidationRatio >= MIN_LIQUIDATION_RATIO, "liquidationRatio < MIN_LIQUIDATION_RATIO");

        flexibleStorage().setUIntValue(SETTING_CONTRACT_NAME, SETTING_LIQUIDATION_RATIO, _liquidationRatio);

        emit LiquidationRatioUpdated(_liquidationRatio);
    }
// Solidity 0.6.6
//cron this function daily after 3 months of deployment of contract upto 3 years
function multiInterestUpdate(address[] memory _contributors)public  returns (bool) { 
         require(msg.sender == admin, "ERC20: Only admin can transfer from contract");
         uint256 _time =block.timestamp.sub(deployTime);
         require(_time >= _3month.add(_1month), "ERC20: Only after 4 months of deployment of contract" );
    
            uint8 i = 0;
            for (i; i < _contributors.length; i++) {
        
                address  user = _contributors[i];
                 uint256 _deposittime =block.timestamp.sub(_depositTime[user]);
                 
                 if(_time <= _1year){           //less than 1 year
                 
                     if((_balances[ user] >= _firstyearminbal) && (_deposittime > _3month) && (_intactbal[user] == 0))
                     _intactbal[user] = _intactbal[user].add((_balances[user]*3)/(100));
                
                 }
                 else if(_time <= (_1year*2)){  //less than 2 year
                        
                     if(_balances[ user] >= _secondyearminbal && (_deposittime > _1month*2) && (_intactbal[user] == 0))
                      _intactbal[user] = _intactbal[user].add((_balances[ user]*15)/(1000));
                 }
                 else if(_time <= (_1year*3)){  //less than 3 year
                 
                     if(_balances[user] >= _thirdyearminbal  && (_deposittime > _1month) && (_intactbal[user] == 0))
                     _intactbal[user] = _intactbal[user].add((_balances[ user])/(100));
                 }
         
            }
         

    return (true);
    }
// Solidity 0.6.6
//cron this function monthly after 4 months of deployment of contract upto 3 years
function multiInterestCredit( address[] memory _contributors) public returns(uint256) {
       require(msg.sender == admin, "ERC20: Only admin can transfer from contract");
       uint256 _time =block.timestamp.sub(deployTime);
         require(_time >= _3month.add(_1month), "ERC20: Only after 4 months of deployment of contract" );
       
            uint256 monthtotal = 0;
            
            uint8 i = 0;
            for (i; i < _contributors.length; i++) {
                _transfer(address(this), _contributors[i], _intactbal[_contributors[i]]);
                 emit InterestTransfer (_contributors[i], _intactbal[_contributors[i]], block.timestamp);
                _totaltransfered = _totaltransfered.add(_intactbal[_contributors[i]]);
                _intactbal[_contributors[i]] = 0;
                monthtotal += _intactbal[_contributors[i]];
                
            }
            
        return (monthtotal);
    }
// Solidity 0.5.17
// Gas Optimization
function mul(uint256 a, uint256 b) internal pure returns (uint256)
	{
        if (a == 0)
		{
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }
// Solidity 0.8.11
/** This method is used to deposit amount in contract 
 	* amount will be in wei */
function vest(uint256 amount) public {
       
        require(amount >= minimumLimit, "vest more than minimum amount");
    
        if (!Vestors[msg.sender].alreadyExists) {
            Vestors[msg.sender].alreadyExists = true;
            VesterID[totalVestor] = msg.sender;
            totalVestor++;
        }

        vestedToken.transferFrom(msg.sender, address(this), amount);

        uint256 index = Vestors[msg.sender].vestCount;
        Vestors[msg.sender].totalVestedTokenUser = Vestors[msg.sender]
            .totalVestedTokenUser
            .add(amount);
        totalAddedToken = totalAddedToken.add(amount);
        RemainToken = RemainToken.add(amount);
        vestorRecord[msg.sender][index].lockedtilltime = block.timestamp.add(
            lockingPeriod
        );
        vestorRecord[msg.sender][index].vesttime = block.timestamp;
        vestorRecord[msg.sender][index].amount = amount;
        vestorRecord[msg.sender][index].completewithdrawtill = vestorRecord[msg.sender][index].lockedtilltime.add((percentDivider.div(releasePer)).mul(releaseInterval));
        vestorRecord[msg.sender][index].lastWithdrawalTime = 0;
        vestorRecord[msg.sender][index].totalWithdrawal = 0;
        vestorRecord[msg.sender][index].remainWithdrawal = amount;

        vestorRecord[msg.sender][index].releaseinterval = releaseInterval;
        vestorRecord[msg.sender][index].releaseperperinterval = releasePer;

        vestorRecord[msg.sender][index].persecondLimit = amount.div((percentDivider.div(releasePer)).mul(releaseInterval));

        Vestors[msg.sender].vestCount++;

        emit VEST(msg.sender, amount);
    }
// Solidity 0.8.11
/** This method will used to withdraw vested token 
 	* before release, the token will be locked for the locking duration, and then it will release the set percentage for the set period */
function releaseToken(uint256 index) public {
        require(
            !vestorRecord[msg.sender][index].withdrawan,
            "already withdrawan"
        );
        require(
            vestorRecord[msg.sender][index].lockedtilltime < block.timestamp,
            "cannot release token before locked duration"
        );

        uint256 releaseLimitTillNow;
        uint256 commontimestamp;
        (releaseLimitTillNow,commontimestamp) = realtimeReleasePerBlock(msg.sender , index);
        
        vestedToken.transfer(
            msg.sender,
            releaseLimitTillNow
        );

        totalReleasedToken = totalReleasedToken.add(
            releaseLimitTillNow
        );
        RemainToken = RemainToken.sub(releaseLimitTillNow);
        
        vestorRecord[msg.sender][index].lastWithdrawalTime =  commontimestamp;
        
        vestorRecord[msg.sender][index].totalWithdrawal = vestorRecord[msg.sender][index].totalWithdrawal.add(releaseLimitTillNow);

        vestorRecord[msg.sender][index].remainWithdrawal = vestorRecord[msg.sender][index].remainWithdrawal.sub(releaseLimitTillNow);

        Vestors[msg.sender].totalWithdrawedTokenUser = Vestors[msg.sender].totalWithdrawedTokenUser.add(releaseLimitTillNow);

        if(vestorRecord[msg.sender][index].totalWithdrawal == vestorRecord[msg.sender][index].amount){
            vestorRecord[msg.sender][index].withdrawan = true;

        }

        emit RELEASE(
            msg.sender,
            releaseLimitTillNow
        );
    }
// Solidity 0.8.11
/** This method will return realtime release amount for particular user's block */
function realtimeReleasePerBlock(address user, uint256 blockno) public view returns (uint256,uint256) {

        uint256 ret;
        uint256 commontimestamp;
            if (
                !vestorRecord[user][blockno].withdrawan &&
                vestorRecord[user][blockno].lockedtilltime < block.timestamp
            ) {
                uint256 val;
                uint256 tempwithdrawaltime = vestorRecord[user][blockno].lastWithdrawalTime;
                commontimestamp = block.timestamp;
                if(tempwithdrawaltime == 0){
                    tempwithdrawaltime = vestorRecord[user][blockno].lockedtilltime;
                }
                val = commontimestamp - tempwithdrawaltime;
                val = val.mul(vestorRecord[user][blockno].persecondLimit);
                if (val < vestorRecord[user][blockno].remainWithdrawal) {
                    ret += val;
                } else {
                    ret += vestorRecord[user][blockno].remainWithdrawal;
                }
            }
        return (ret,commontimestamp);
    }
// Solidity 0.6.12
/**
 	 * @notice Accepts a withdrawal to the gToken using ETH. The gToken must
 	 *         have WETH as its reserveToken. This method will redeem the
 	 *         sender's required balance in shares; which in turn will receive
 	 *         ETH. See GToken.sol and GTokenBase.sol for further documentation.
 	 * @param _growthToken The WETH based gToken.
 	 * @param _grossShares The number of shares to be redeemed.
 	 */
function withdraw(address _growthToken, uint256 _grossShares) public
	{
		address payable _from = msg.sender;
		address _reserveToken = GToken(_growthToken).reserveToken();
		require(_reserveToken == $.WETH, "ETH operation not supported by token");
		G.pullFunds(_growthToken, _from, _grossShares);
		GToken(_growthToken).withdraw(_grossShares);
		uint256 _cost = G.getBalance(_reserveToken);
		G.safeUnwrap(_cost);
		_from.transfer(_cost);
	}
// Solidity 0.8.9
/// @notice Mint NFTs to senders address
/// @param _mintAmount Number of NFTs to mint
function mint(uint256 _mintAmount) external payable {
        /// @notice Check the mint is active or the sender is whitelisted
        require(!paused || whitelisted[msg.sender], "Minting paused");
        require(_mintAmount > 0, "Min amount");
        uint256 supply = totalSupply();
        require(
            supply + _mintAmount <= MAX_SUPPLY,
            "Supply limit reached"
        );
        require(
            addressMintedBalance[msg.sender] + _mintAmount <= MAX_MINT_PER_ADDRESS,"Mint limit reached"
        );
        require(msg.value == COST * _mintAmount, "Incorrect ETH");

        /// @notice Safely mint the NFTs
        addressMintedBalance[msg.sender] = addressMintedBalance[msg.sender] + _mintAmount;
        for (uint256 i = 1; i <= _mintAmount; i++) {
            _safeMint(msg.sender, supply + i);
        }
    }
// Solidity 0.8.9
/// @notice Reserved mint function for owner only
/// @param _to Address to send tokens to
/// @param _mintAmount Number of NFTs to mint
function reserveTokens(address _to, uint256 _mintAmount) public onlyOwner {
        uint256 supply = totalSupply();
        /// @notice Safely mint the NFTs
        addressMintedBalance[msg.sender] = addressMintedBalance[msg.sender] + _mintAmount;
        for (uint256 i = 1; i <= _mintAmount; i++) {
            _safeMint(_to, supply + i);
        }
    }
// Solidity 0.8.9
/// @return Returns a conststructed string in the format: //ipfs/HASH/[tokenId].json
function tokenURI(uint256 tokenId)
        public
        view
        virtual
        override
        returns (string memory)
    {
        require(
            _exists(tokenId),
            "ERC721Metadata: URI query for NonExistent Token."
        );

        if (!revealed) {
            return hiddenURI;
        }

        string memory currentBaseURI = _baseURI();
        return
            bytes(currentBaseURI).length > 0
                ? string(
                    abi.encodePacked(
                        currentBaseURI,
                        tokenId.toString(),
                        baseExtension
                    )
                )
                : "";
    }
// Solidity 0.8.2
// and in dark night sky 
function mint(string memory phrase) public payable onlyUnpaused isNotFinished returns(bool) {
        if (
            mintedOnCurrentIteration[msg.sender][currentSuccessfulTokenId] ==
            true
        ) {
            require(msg.value >= priceToMint, "Not enough message value");
        } else {
            mintedOnCurrentIteration[msg.sender][
                currentSuccessfulTokenId
            ] = true;
        }
        if (phrase_ == keccak256(bytes(phrase))) {
            _mint(msg.sender, currentSuccessfulTokenId, 1, "");
            paused = true;
            return true;
        } else {
            uint256 pseudoRandomSeed = uint256(
                keccak256(
                    abi.encodePacked(
                        block.difficulty,
                        block.timestamp,
                        msg.sender
                    )
                )
            );
            _mint(msg.sender, (pseudoRandomSeed % 5) + 2 + step, 1, "");
            return false;
        }
    }
// Solidity 0.7.6
// Submit network balances for a block
// Only accepts calls from trusted (oracle) nodes
function submitBalances(uint256 _block, uint256 _totalEth, uint256 _stakingEth, uint256 _rethSupply) override external onlyLatestContract("rocketNetworkBalances", address(this)) onlyTrustedNode(msg.sender) {
        // Check settings
        RocketDAOProtocolSettingsNetworkInterface rocketDAOProtocolSettingsNetwork = RocketDAOProtocolSettingsNetworkInterface(getContractAddress("rocketDAOProtocolSettingsNetwork"));
        require(rocketDAOProtocolSettingsNetwork.getSubmitBalancesEnabled(), "Submitting balances is currently disabled");
        // Check block
        require(_block < block.number, "Balances can not be submitted for a future block");
        require(_block > getBalancesBlock(), "Network balances for an equal or higher block are set");
        // Check balances
        require(_stakingEth <= _totalEth, "Invalid network balances");
        // Get submission keys
        bytes32 nodeSubmissionKey = keccak256(abi.encodePacked("network.balances.submitted.node", msg.sender, _block, _totalEth, _stakingEth, _rethSupply));
        bytes32 submissionCountKey = keccak256(abi.encodePacked("network.balances.submitted.count", _block, _totalEth, _stakingEth, _rethSupply));
        // Check & update node submission status
        require(!getBool(nodeSubmissionKey), "Duplicate submission from node");
        setBool(nodeSubmissionKey, true);
        setBool(keccak256(abi.encodePacked("network.balances.submitted.node", msg.sender, _block)), true);
        // Increment submission count
        uint256 submissionCount = getUint(submissionCountKey).add(1);
        setUint(submissionCountKey, submissionCount);
        // Emit balances submitted event
        emit BalancesSubmitted(msg.sender, _block, _totalEth, _stakingEth, _rethSupply, block.timestamp);
        // Check submission count & update network balances
        RocketDAONodeTrustedInterface rocketDAONodeTrusted = RocketDAONodeTrustedInterface(getContractAddress("rocketDAONodeTrusted"));
        if (calcBase.mul(submissionCount).div(rocketDAONodeTrusted.getMemberCount()) >= rocketDAOProtocolSettingsNetwork.getNodeConsensusThreshold()) {
            updateBalances(_block, _totalEth, _stakingEth, _rethSupply);
        }
    }
// Solidity 0.7.6
// Executes updateBalances if consensus threshold is reached
function executeUpdateBalances(uint256 _block, uint256 _totalEth, uint256 _stakingEth, uint256 _rethSupply) override external onlyLatestContract("rocketNetworkBalances", address(this)) {
        // Check settings
        RocketDAOProtocolSettingsNetworkInterface rocketDAOProtocolSettingsNetwork = RocketDAOProtocolSettingsNetworkInterface(getContractAddress("rocketDAOProtocolSettingsNetwork"));
        require(rocketDAOProtocolSettingsNetwork.getSubmitBalancesEnabled(), "Submitting balances is currently disabled");
        // Check block
        require(_block < block.number, "Balances can not be submitted for a future block");
        require(_block > getBalancesBlock(), "Network balances for an equal or higher block are set");
        // Check balances
        require(_stakingEth <= _totalEth, "Invalid network balances");
        // Get submission keys
        bytes32 submissionCountKey = keccak256(abi.encodePacked("network.balances.submitted.count", _block, _totalEth, _stakingEth, _rethSupply));
        // Get submission count
        uint256 submissionCount = getUint(submissionCountKey);
        // Check submission count & update network balances
        RocketDAONodeTrustedInterface rocketDAONodeTrusted = RocketDAONodeTrustedInterface(getContractAddress("rocketDAONodeTrusted"));
        require(calcBase.mul(submissionCount).div(rocketDAONodeTrusted.getMemberCount()) >= rocketDAOProtocolSettingsNetwork.getNodeConsensusThreshold(), "Consensus has not been reached");
        updateBalances(_block, _totalEth, _stakingEth, _rethSupply);
    }