lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.6.12
// Make a new checkpoint from the supplied validator set
// A checkpoint is a hash of all relevant information about the valset. This is stored by the contract,
// instead of storing the information directly. This saves on storage and gas.
// The format of the checkpoint is:
// h(gravityId, "checkpoint", valsetNonce, validators[], powers[])
// Where h is the keccak256 hash function.
// The validator powers must be decreasing or equal. This is important for checking the signatures on the
// next valset, since it allows the caller to stop verifying signatures once a quorum of signatures have been verified.
function makeCheckpoint(
		address[] memory _validators,
		uint256[] memory _powers,
		uint256 _valsetNonce,
		bytes32 _gravityId
	) private pure returns (bytes32) {
		// bytes32 encoding of the string "checkpoint"
		bytes32 methodName = 0x636865636b706f696e7400000000000000000000000000000000000000000000;

		bytes32 checkpoint =
			keccak256(abi.encode(_gravityId, methodName, _valsetNonce, _validators, _powers));

		return checkpoint;
	}
// Solidity 0.5.16
// Set root of merkle tree
function setRoot(bytes32 _root) public onlyOwner {
        require(address(iEscrowThales) != address(0), "Set Escrow Thales address");
        root = _root;
        startTime = block.timestamp; //reset time every period
        emit NewRoot(_root, block.timestamp, period);
        period = period + 1;
    }
// Solidity 0.5.16
// Check if a given reward has already been claimed
function claimed(uint256 index) public view returns (uint256 claimedBlock, uint256 claimedMask) {
        claimedBlock = _claimed[period][index / 256];
        claimedMask = (uint256(1) << uint256(index % 256));
        require((claimedBlock & claimedMask) == 0, "Tokens have already been claimed");
    }
// Solidity 0.5.16
// Get airdrop tokens assigned to address
// Requires sending merkle proof to the function
function claim(
        uint256 index,
        uint256 amount,
        bytes32[] memory merkleProof
    ) public notPaused {
        // Make sure the tokens have not already been redeemed
        (uint256 claimedBlock, uint256 claimedMask) = claimed(index);
        _claimed[period][index / 256] = claimedBlock | claimedMask;

        // Compute the merkle leaf from index, recipient and amount
        bytes32 leaf = keccak256(abi.encodePacked(index, msg.sender, amount));
        // verify the proof is valid
        require(MerkleProof.verify(merkleProof, root, leaf), "Proof is not valid");

        // Send to EscrowThales contract
        iEscrowThales.addToEscrow(msg.sender, amount);

        emit Claim(msg.sender, amount, block.timestamp);
    }
// Solidity 0.6.10
/**
 * @notice remove an address from the array
 * @dev finds the element, swaps it with the last element, and then deletes it;
 *      returns a boolean whether the element was found and deleted
 * @param self Storage array containing address type variables
 * @param element the element to remove from the array
 */
function removeAddress(Addresses storage self, address element) internal returns (bool) {
        for (uint i = 0; i < self.size(); i++) {
            if (self._items[i] == element) {
                self._items[i] = self._items[self.size() - 1];
                self._items.pop();
                return true;
            }
        }
        return false;
    }
// Solidity 0.6.10
/**
 * @notice check if an element exist in the array
 * @param self Storage array containing address type variables
 * @param element the element to check if it exists in the array
 */
function exists(Addresses storage self, address element) internal view returns (bool) {
        for (uint i = 0; i < self.size(); i++) {
            if (self._items[i] == element) {
                return true;
            }
        }
        return false;
    }
// Solidity 0.4.24
/*function deployMinersTest(uint32 _hour, address user, uint32[] area, uint32[] period, uint32[] count) public checkWhiteList payable {
 require(area.length > 0);
 require(area.length == period.length);
 require(area.length == count.length);
 address _user = user;
 if (_user == address(0)) {
 _user = msg.sender;
 }
 
 
 checkArea(area, user);
 
 uint payment = _deployMiners(_user, _hour, area, period, count);
 _updateCheckPoints(_user, _hour, area, period, count);
 
 require(payment <= msg.value);
 remainEther[msg.sender] += (msg.value - payment);
 amountEther += payment;
 }*/
function _deployMiners(address _user, uint32 _hour, uint32[] memory area, uint32[] memory period, uint32[] memory count) internal returns(uint){
        uint payment = 0;
        uint32 minerCount = 0;
        uint32[3][72] storage _areaDeployed = areaHourDeployed[_hour];
        uint32[3][72] storage _userAreaDeployed = userAreaHourDeployed[_user].hour[_hour];
        
        
        for (uint index = 0; index < area.length; ++index) {
            require (period[index] == 4 || period[index] == 8 || period[index] == 24);
            if (period[index] == 4) {
                _areaDeployed[area[index]][0] += count[index];
                _userAreaDeployed[area[index]][0] += count[index];
                payment += count[index] * MINER_4_HOURS;
            } else if (period[index] == 8) {
                _areaDeployed[area[index]][1] += count[index];
                _userAreaDeployed[area[index]][1] += count[index];
                payment += count[index] * MINER_8_HOURS;
            } else if (period[index] == 24) {
                _areaDeployed[area[index]][2] += count[index];
                _userAreaDeployed[area[index]][2] += count[index];
                payment += count[index] * MINER_24_HOURS;
            }
            minerCount += count[index];
            DeployMiner(_user, area[index], _hour, _hour + period[index], count[index]);

            adjustDeployRange(area[index], _hour, _hour + period[index]);
        }
        return payment;
    }
// Solidity 0.4.23
/**
 * @dev Override to extend the way in which ether is converted to tokens.
 * @param _weiAmount Value in wei to be converted into tokens
 * @return Number of tokens that can be purchased with the specified _weiAmount
 */
function _getTokenAmount(uint256 _weiAmount) internal returns(uint256) {
        if ((_weiAmount >= 500000000000000000000) && (_weiAmount < 1000000000000000000000)) {
            rate = 7140;
        } else if (_weiAmount >= 1000000000000000000000) {
            rate = 7650;
        } else if (tokensSold <= 21420000000000000000000000) {
            if(rate != 6120) {
            rate = 6120; }
        } else if ((tokensSold > 21420000000000000000000000) && (tokensSold <= 42304500000000000000000000)) {
             if(rate != 5967) {
            rate = 5967;}
        } else if ((tokensSold > 42304500000000000000000000) && (tokensSold <= 73095750000000000000000000)) {
             if(rate != 5865) {
            rate = 5865;}
        } else if ((tokensSold > 73095750000000000000000000) && (tokensSold <= 112365750000000000000000000)) {
             if(rate != 5610) {
            rate = 5610;}
        } else if ((tokensSold > 112365750000000000000000000) && (tokensSold <= 159222000000000000000000000)) {
             if(rate != 5355) {
            rate = 5355;}
        } else if (tokensSold > 159222000000000000000000000) {
             if(rate != 5100) {
            rate = 5100;}
        }
        return _weiAmount.mul(rate);
    }
// Solidity 0.8.7
// SO - 50375
function testStr(string memory str) internal pure returns (bool){
        bytes memory b = bytes(str);
        if(b.length > 20|| b.length < 1) return false;

        for(uint i; i<b.length; i++){
            bytes1 ch = b[i];

            if(
                !(ch >= 0x30 && ch <= 0x39) && //9-0
                !(ch >= 0x41 && ch <= 0x5A) && //A-Z
                !(ch >= 0x61 && ch <= 0x7A) && //a-z
                !(ch == 0x20) // space
            )
                return false;
        }

        return true;
    }
// Solidity 0.8.7
// SO - 58341
function toAsciiString(address x) internal pure returns (string memory) {
        bytes memory s = new bytes(40);
        for (uint i = 0; i < 20; i++) {
            bytes1 b = bytes1(uint8(uint(uint160(x)) / (2**(8*(19 - i)))));
            bytes1 hi = bytes1(uint8(b) / 16);
            bytes1 lo = bytes1(uint8(b) - 16 * uint8(hi));
            s[2*i] = char(hi);
            s[2*i+1] = char(lo);            
        }
        return string(s);
    }
// Solidity 0.8.0
/**
 * @dev doubles pruf balance at snapshotID(1)
 */
function splitMyPruf() external whenNotPaused {
        require(
            hasSplit[msg.sender] == 0,
            "SPLIT:SMP: Caller address has already been split"
        );
        //^^^^^^^checks^^^^^^^^^

        uint256 balanceAtSnapshot = UTIL_TKN.balanceOfAt(msg.sender, 1);
        hasSplit[msg.sender] = 170; //mark caller address as having been split
        //^^^^^^^effects^^^^^^^^^

        UTIL_TKN.mint(msg.sender, balanceAtSnapshot); //mint the new tokens to caller address
        //^^^^^^^Interactions^^^^^^^^^
    }
// Solidity 0.8.0
/**
 * @dev doubles pruf balance at snapshotID(1)
 * @param _address - address to be split
 */
function splitPrufAtAddress(address _address) external whenNotPaused {
        require(
            hasSplit[_address] == 0,
            "SPLIT:SMPAA: Caller address has already been split"
        );
        //^^^^^^^checks^^^^^^^^^

        uint256 balanceAtSnapshot = UTIL_TKN.balanceOfAt(_address, 1);
        hasSplit[_address] = 170; //mark caller address as having been split
        //^^^^^^^effects^^^^^^^^^

        UTIL_TKN.mint(_address, balanceAtSnapshot); //mint the new tokens to caller address
        //^^^^^^^Interactions^^^^^^^^^
    }
// Solidity 0.6.6
// note this will always return 0 before update has been called successfully for the first time.
function consult(address token, uint amountIn) internal view returns (uint amountOut) {
        if (token == token0) {
            amountOut = price0Average.mul(amountIn).decode144();
        } else {
            require(token == token1, 'ExampleOracleSimple: INVALID_TOKEN');
            amountOut = price1Average.mul(amountIn).decode144();
        }
    }
// Solidity 0.6.6
/**
 * @dev Sets `value` as the allowance of `spender` over `owner`'s tokens,
 * given `owner`'s signed approval.
 *
 * Emits an {Approval} event.
 *
 * Requirements:
 *
 * - `spender` cannot be the zero address.
 * - `deadline` must be a timestamp in the future.
 * - `v`, `r` and `s` must be a valid signature from `owner`
 * over the EIP712-formatted function arguments.
 * - the signature must use ``owner``'s current nonce (see {nonces}).
 *
 * For more information on the signature format, see the
 * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
 * section].
 */
function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external override onlyOnDeployedNetwork whenNotPaused {
        // solhint-disable-next-line
        require(deadline >= block.timestamp, "ERC20WithPermit: EXPIRED");

        bytes32 digest =
            keccak256(
                abi.encodePacked(
                    "\x19\x01",
                    DOMAIN_SEPARATOR,
                    keccak256(
                        abi.encode(
                            PERMIT_TYPEHASH,
                            owner,
                            spender,
                            value,
                            nonces[owner]++,
                            deadline
                        )
                    )
                )
            );

        address recoveredAddress = ecrecover(digest, v, r, s);
        require(
            recoveredAddress != address(0) && recoveredAddress == owner,
            "ERC20WithPermit: INVALID_SIGNATURE"
        );

        _approve(owner, spender, value);
    }
// Solidity 0.4.21
// ------------------------------------------------------------------------
// Accepts ETH and transfers ZAN tokens based on exchage rate and state
// ------------------------------------------------------------------------
function () public payable {
        uint eth_sent = msg.value;
        uint tokens_amount = eth_sent.mul(exchangeRate);
        
        require(eth_sent > 0);
        require(exchangeRate > 0);
        require(stateStartDate < now && now < stateEndDate);
        require(balances[owner] >= tokens_amount);
        require(_totalSupply - (balances[owner] - tokens_amount) <= saleCap);
        
        // Don't accept ETH in the final state
        require(!isInFinalState);
        require(isInPreSaleState || isInRoundOneState || isInRoundTwoState);
        
        balances[owner] = balances[owner].sub(tokens_amount);
        balances[msg.sender] = balances[msg.sender].add(tokens_amount);
        emit PurchaseZanTokens(msg.sender, eth_sent, tokens_amount);
    }
// Solidity 0.4.21
// ------------------------------------------------------------------------
// Switches crowdsale stages: PreSale -> Round One -> Round Two
// ------------------------------------------------------------------------
function switchCrowdSaleStage() external onlyOwner {
        require(!isInFinalState && !isInRoundTwoState);
        
        if (!isInPreSaleState) {
            isInPreSaleState = true;
            exchangeRate = 1500;
            saleCap = (3 * 10**6) * (uint(10) ** decimals);
            emit SwitchCrowdSaleStage("PreSale", exchangeRate);
        }
        else if (!isInRoundOneState) {
            isInRoundOneState = true;
            exchangeRate = 1200;
            saleCap = saleCap + ((4 * 10**6) * (uint(10) ** decimals));
            emit SwitchCrowdSaleStage("RoundOne", exchangeRate);
        }
        else if (!isInRoundTwoState) {
            isInRoundTwoState = true;
            exchangeRate = 900;
            saleCap = saleCap + ((5 * 10**6) * (uint(10) ** decimals));
            emit SwitchCrowdSaleStage("RoundTwo", exchangeRate);
        }
        
        stateStartDate = now + 5 minutes;
        stateEndDate = stateStartDate + 7 days;
    }
// Solidity 0.4.26
/// @dev Transfers tokens to a specified address with additional data if the recipient is a contact.
/// @param to The address to transfer tokens to.
/// @param value The amount of tokens to be transferred.
/// @param data The extra data to be passed to the receiving contract.
/// @return A boolean that indicates if the operation was successful.
function transferAndCall(address to, uint256 value, bytes data) external canTransfer returns (bool) {
        require(to != address(this));
        require(super.transfer(to, value));
        emit Transfer(msg.sender, to, value, data);
        if (isContract(to)) {
            require(contractFallback(msg.sender, to, value, data));
        }
        return true;
    }
// Solidity 0.4.26
/// @dev Transfers tokens from one address to another.
/// @param from The address to transfer tokens from.
/// @param to The address to transfer tokens to.
/// @param value The amount of tokens to be transferred.
/// @return A boolean that indicates if the operation was successful.
function transferFrom(address from, address to, uint256 value) public canTransfer returns (bool) {
        require(super.transferFrom(from, to, value));
        if (isContract(to) && !contractFallback(from, to, value, new bytes(0))) {
            if (to == _bridgeContract) {
                revert();
            }
            emit ContractFallbackCallFailed(from, to, value);
        }
        return true;
    }
// Solidity 0.4.26
/// @dev Transfers tokens to a specified addresses (optimized version for initial sending tokens).
/// @param recipients Addresses to transfer tokens to.
/// @param values Amounts of tokens to be transferred.
/// @return A boolean that indicates if the operation was successful.
function airdrop(address[] recipients, uint256[] values) public canTransfer returns (bool) {
        require(recipients.length == values.length);
        uint256 senderBalance = _balances[msg.sender];
        for (uint256 i = 0; i < values.length; i++) {
            uint256 value = values[i];
            address to = recipients[i];
            require(senderBalance >= value);
            if (msg.sender != recipients[i]) {
                senderBalance = senderBalance - value;
                _balances[to] += value;
            }
            emit Transfer(msg.sender, to, value);
        }
        _balances[msg.sender] = senderBalance;
        return true;
    }
// Solidity 0.4.26
/// @dev Transfers funds stored on the token contract to specified recipient (required by token bridge).
function claimTokens(address token, address to) public onlyOwnerOrBridgeContract {
        require(to != address(0));
        if (token == address(0)) {
            to.transfer(address(this).balance);
        } else {
            ERC20 erc20 = ERC20(token);
            uint256 balance = erc20.balanceOf(address(this));
            require(erc20.transfer(to, balance));
        }
    }
// Solidity 0.5.12
// --- administration ---
function file(bytes32 what, address data) external auth {
        if (what == "outputConduit") { outputConduit = data; }
        else if (what == "jug") { jug = JugAbstract(data); }
        else revert("RwaUrn/unrecognised-param");
        emit File(what, data);
    }
// Solidity 0.5.12
// --- cdp operation ---
// n.b. that the operator must bring the gem
function lock(uint256 wad) external operator {
        require(wad <= 2**255 - 1, "RwaUrn/overflow");
        DSTokenAbstract(gemJoin.gem()).transferFrom(msg.sender, address(this), wad);
        // join with address this
        gemJoin.join(address(this), wad);
        vat.frob(gemJoin.ilk(), address(this), address(this), address(this), int(wad), 0);
        emit Lock(msg.sender, wad);
    }
// Solidity 0.5.12
// n.b. DAI can only go to the output conduit
function draw(uint256 wad) external operator {
        require(outputConduit != address(0));
        bytes32 ilk = gemJoin.ilk();
        jug.drip(ilk);
        (,uint256 rate,,,) = vat.ilks(ilk);
        uint256 dart = divup(mul(RAY, wad), rate);
        require(dart <= 2**255 - 1, "RwaUrn/overflow");
        vat.frob(ilk, address(this), address(this), address(this), 0, int(dart));
        daiJoin.exit(outputConduit, wad);
        emit Draw(msg.sender, wad);
    }
// Solidity 0.5.12
// n.b. anyone can wipe
function wipe(uint256 wad) external {
        daiJoin.join(address(this), wad);
        bytes32 ilk = gemJoin.ilk();
        jug.drip(ilk);
        (,uint256 rate,,,) = vat.ilks(ilk);
        uint256 dart = mul(RAY, wad) / rate;
        require(dart <= 2 ** 255, "RwaUrn/overflow");
        vat.frob(ilk, address(this), address(this), address(this), 0, -int(dart));
        emit Wipe(msg.sender, wad);
    }
// Solidity 0.5.17
/**
 * @dev Returns the amount of ether in wei that are equivalent to 1 unit (10 ** decimals) of asset
 * @param asset quoted currency
 * @return price in ether
 */
function getAssetToEthRate(address asset) public view returns (uint) {

    if (asset == ETH) {
      return 1 ether;
    }

    address aggregatorAddress = aggregators[asset];

    if (aggregatorAddress == address(0)) {
      revert("PriceFeedOracle: Oracle asset not found");
    }

    int rate = Aggregator(aggregatorAddress).latestAnswer();
    require(rate > 0, "PriceFeedOracle: Rate must be > 0");

    return uint(rate);
  }
// Solidity 0.5.17
// This function allows governance to take unsupported tokens out of the
// contract, since this one exists longer than the other pools.
// This is in an effort to make someone whole, should they seriously
// mess up. There is no guarantee governance will vote to return these.
// It also allows for removal of airdropped tokens.
function governanceRecoverUnsupported(IERC20 _token, uint256 amount, address to)
        external
    {
        // only gov
        require(msg.sender == owner(), "!governance");
        // cant take staked asset
        require(_token != uni_lp, "uni_lp");
        // cant take reward asset
        require(_token != yam, "yam");

        // transfer to
        _token.safeTransfer(to, amount);
    }
// Solidity 0.4.21
/**
 @dev constructor
 
 @param  _token              smart token governed by the converter
 @param  _registry           address of a contract registry contract
 @param  _maxConversionFee   maximum conversion fee, represented in ppm
 @param  _connectorToken     optional, initial connector, allows defining the first connector at deployment time
 @param  _connectorWeight    optional, weight for the initial connector
 */
function BancorConverter(
        ISmartToken _token,
        IContractRegistry _registry,
        uint32 _maxConversionFee,
        IERC20Token _connectorToken,
        uint32 _connectorWeight
    )
        public
        SmartTokenController(_token)
        validAddress(_registry)
        validMaxConversionFee(_maxConversionFee)
    {
        registry = _registry;
        IContractFeatures features = IContractFeatures(registry.getAddress(ContractIds.CONTRACT_FEATURES));

        // initialize supported features
        if (features != address(0))
            features.enableFeatures(FeatureIds.CONVERTER_CONVERSION_WHITELIST, true);

        maxConversionFee = _maxConversionFee;

        if (_connectorToken != address(0))
            addConnector(_connectorToken, _connectorWeight, false);
    }
// Solidity 0.4.21
/**
 @dev defines a new connector for the token
 can only be called by the owner while the converter is inactive
 
 @param _token                  address of the connector token
 @param _weight                 constant connector weight, represented in ppm, 1-1000000
 @param _enableVirtualBalance   true to enable virtual balance for the connector, false to disable it
 */
function addConnector(IERC20Token _token, uint32 _weight, bool _enableVirtualBalance)
        public
        ownerOnly
        inactive
        validAddress(_token)
        notThis(_token)
        validConnectorWeight(_weight)
    {
        require(_token != token && !connectors[_token].isSet && totalConnectorWeight + _weight <= MAX_WEIGHT); // validate input

        connectors[_token].virtualBalance = 0;
        connectors[_token].weight = _weight;
        connectors[_token].isVirtualBalanceEnabled = _enableVirtualBalance;
        connectors[_token].isPurchaseEnabled = true;
        connectors[_token].isSet = true;
        connectorTokens.push(_token);
        totalConnectorWeight += _weight;
    }
// Solidity 0.4.21
/**
 @dev updates one of the token connectors
 can only be called by the owner
 
 @param _connectorToken         address of the connector token
 @param _weight                 constant connector weight, represented in ppm, 1-1000000
 @param _enableVirtualBalance   true to enable virtual balance for the connector, false to disable it
 @param _virtualBalance         new connector's virtual balance
 */
function updateConnector(IERC20Token _connectorToken, uint32 _weight, bool _enableVirtualBalance, uint256 _virtualBalance)
        public
        ownerOnly
        validConnector(_connectorToken)
        validConnectorWeight(_weight)
    {
        Connector storage connector = connectors[_connectorToken];
        require(totalConnectorWeight - connector.weight + _weight <= MAX_WEIGHT); // validate input

        totalConnectorWeight = totalConnectorWeight - connector.weight + _weight;
        connector.weight = _weight;
        connector.isVirtualBalanceEnabled = _enableVirtualBalance;
        connector.virtualBalance = _virtualBalance;
    }