lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.24
/**
 * @dev Owner can burn a specific amount of tokens of other token holders.
 * @param _from The address of token holder whose tokens to be burned.
 * @param _amount The amount of token to be burned.
 */
function burnFrom(address _from, uint256 _amount) onlyOwner public {
        require(_from != address(0));
        require(_amount > 0);
        require(_amount <= balances[_from]);
        balances[_from] = SafeMath.sub(balances[_from],_amount);
        totalSupply = SafeMath.sub(totalSupply,_amount);
        emit Transfer(_from, address(0), _amount);
        emit Burn(_from, _amount);
    }
// Solidity 0.4.24
/// @dev Accepts ether and creates new tge tokens.
function createTokens() payable external {
      if (!tokenSaleActive) 
        revert();
      if (haltIco) 
	revert();	  
      if (msg.value == 0) 
        revert();
        
      uint256 tokens;
      tokens = SafeMath.mul(msg.value, icoTokenExchangeRate); // check that we're not over totals
      uint256 checkedSupply = SafeMath.add(totalSupply, tokens);
 
      // return money if something goes wrong
      if (tokenCreationCap < checkedSupply) 
        revert();  // odd fractions won't be found
 
      totalSupply = checkedSupply;
      balances[msg.sender] += tokens;  // safeAdd not needed; bad semantics to use here
      emit CreateToken(msg.sender, tokens);  // logs token creation
    }
// Solidity 0.5.17
//sav3 transfer function
function _transfer(address from, address to, uint256 amount) internal {
        // calculate liquidity lock amount
        // dont transfer burn from this contract
        // or can never lock full lockable amount
        if(locked && unlocked[from] != true && unlocked[to] != true)
            revert("Locked until end of presale");
            
        if (liquidityLockDivisor != 0 && feelessAddr[from] == false && feelessAddr[to] == false) {
            uint256 liquidityLockAmount = amount.div(liquidityLockDivisor);
            super._transfer(from, address(this), liquidityLockAmount);
            super._transfer(from, to, amount.sub(liquidityLockAmount));
        }
        else {
            super._transfer(from, to, amount);
        }
    }
// Solidity 0.8.4
//    function batchMintAndBurn(uint256[] memory oldID, uint256[] memory newId, bytes32[] memory leaves, bytes32[j][] memory proofs) external {
function batchMigration(uint256[] memory oldIds, uint256[] memory newIds, bytes32[] memory leaves, bytes32[][] memory proofs) external returns(address){
        for (uint i = 0; i < oldIds.length; i++) {
            // Don't allow reminting
            require(!_exists(newIds[i]), "Token already minted");

            // Verify that (oldId, newId) correspond to the Merkle leaf
            require(keccak256(abi.encodePacked(oldIds[i], newIds[i])) == leaves[i], "Ids don't match Merkle leaf");

            // Verify that (oldId, newId) is a valid pair in the Merkle tree
            //require(verify(merkleRoot, leaves[i], proofs[i]), "Not a valid element in the Merkle tree");

            // Verify that msg.sender is the owner of the old token
            require(Opensea(openseaSharedAddress).balanceOf(msg.sender, oldIds[i]), "Only token owner can mintAndBurn");
        } 

        for (uint j = 0; j < oldIds.length; j++) {
            Opensea(openseaSharedAddress).safeTransferFrom(msg.sender, burnAddress, oldIds[j], 1, "");
			_mint(msg.sender, newIds[j]);
			emit Arise(msg.sender, newIds[j]);
            totalSupply += 1;
		}
    }
// Solidity 0.4.24
// PRIVATE HELPERS FUNCTION
function safeSend(address addr, uint value)
        private {

        if (value == 0) {
            emit LOG_ZeroSend();
            return;
        }

        if (this.balance < value) {
            emit LOG_ValueIsTooBig();
            return;
        }
        //发送资金
        if (!(addr.call.gas(safeGas).value(value)())) {
            emit LOG_FailedSend(addr, value);
            if (addr != houseAddress) {
                
                if (!(houseAddress.call.gas(safeGas).value(value)())) LOG_FailedSend(houseAddress, value);
            }
        }

        emit LOG_SuccessfulSend(addr,value);
    }
// Solidity 0.6.12
/**
 * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
 * `recipient`, forwarding all available gas and reverting on errors.
 */
function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }
// Solidity 0.5.11
/**
 * OZ initializer; sets the option series expiration to (block.number
 * + parameter) block number; useful for tests
 */
function initializeInTestMode(
        string calldata name,
        string calldata symbol,
        IERC20 _underlyingAsset,
        uint8 _underlyingAssetDecimals,
        IERC20 _strikeAsset,
        uint256 _strikePrice) external initializer
    {
        _initialize(
            name,
            symbol,
            _underlyingAsset,
            _underlyingAssetDecimals,
            _strikeAsset,
            _strikePrice,
            ~uint256(0)
        );
        isTestingDeployment = true;
    }
// Solidity 0.5.11
/**
 * OZ initializer; sets the option series expiration to an exact
 * block number
 */
function initialize(
        string calldata name,
        string calldata symbol,
        IERC20 _underlyingAsset,
        uint8 _underlyingAssetDecimals,
        IERC20 _strikeAsset,
        uint256 _strikePrice,
        uint256 _expirationBlockNumber) external initializer
    {
        _initialize(
            name,
            symbol,
            _underlyingAsset,
            _underlyingAssetDecimals,
            _strikeAsset,
            _strikePrice,
            _expirationBlockNumber
        );
    }
// Solidity 0.7.6
/// @dev Setup function sets initial storage of contract.
/// @param _owners List of Safe owners.
/// @param _threshold Number of required confirmations for a Safe transaction.
/// @param to Contract address for optional delegate call.
/// @param data Data payload for optional delegate call.
/// @param fallbackHandler Handler for fallback calls to this contract
/// @param paymentToken Token that should be used for the payment (0 is ETH)
/// @param payment Value that should be paid
/// @param paymentReceiver Adddress that should receive the payment (or 0 if tx.origin)
function setup(
        address[] calldata _owners,
        uint256 _threshold,
        address to,
        bytes calldata data,
        address fallbackHandler,
        address paymentToken,
        uint256 payment,
        address payable paymentReceiver
    ) external {
        // setupOwners checks if the Threshold is already set, therefore preventing that this method is called twice
        setupOwners(_owners, _threshold);
        if (fallbackHandler != address(0)) internalSetFallbackHandler(fallbackHandler);
        // As setupOwners can only be called if the contract has not been initialized we don't need a check for setupModules
        setupModules(to, data);

        if (payment > 0) {
            // To avoid running into issues with EIP-170 we reuse the handlePayment function (to avoid adjusting code of that has been verified we do not adjust the method itself)
            // baseGas = 0, gasPrice = 1 and gas = payment => amount = (payment + 0) * 1 = payment
            handlePayment(payment, 0, 1, paymentToken, paymentReceiver);
        }
        emit SafeSetup(msg.sender, _owners, _threshold, to, fallbackHandler);
    }
// Solidity 0.7.6
/**
 * @dev Checks whether the signature provided is valid for the provided data, hash. Will revert otherwise.
 * @param dataHash Hash of the data (could be either a message hash or transaction hash)
 * @param data That should be signed (this is passed to an external validator contract)
 * @param signatures Signature data that should be verified. Can be ECDSA signature, contract signature (EIP-1271) or approved hash.
 */
function checkSignatures(
        bytes32 dataHash,
        bytes memory data,
        bytes memory signatures
    ) public view {
        // Load threshold to avoid multiple storage loads
        uint256 _threshold = threshold;
        // Check that a threshold is set
        require(_threshold > 0, "GS001");
        checkNSignatures(dataHash, data, signatures, _threshold);
    }
// Solidity 0.7.6
/// @dev Allows to estimate a Safe transaction.
///      This method is only meant for estimation purpose, therefore the call will always revert and encode the result in the revert data.
///      Since the `estimateGas` function includes refunds, call this method to get an estimated of the costs that are deducted from the safe with `execTransaction`
/// @param to Destination address of Safe transaction.
/// @param value Ether value of Safe transaction.
/// @param data Data payload of Safe transaction.
/// @param operation Operation type of Safe transaction.
/// @return Estimate without refunds and overhead fees (base transaction and payload data gas costs).
/// @notice Deprecated in favor of common/StorageAccessible.sol and will be removed in next version.
function requiredTxGas(
        address to,
        uint256 value,
        bytes calldata data,
        Enum.Operation operation
    ) external returns (uint256) {
        uint256 startGas = gasleft();
        // We don't provide an error message here, as we use it to return the estimate
        require(execute(to, value, data, operation, gasleft()));
        uint256 requiredGas = startGas - gasleft();
        // Convert response to string and return via error message
        revert(string(abi.encodePacked(requiredGas)));
    }
// Solidity 0.7.6
/// @dev Returns the bytes that are hashed to be signed by owners.
/// @param to Destination address.
/// @param value Ether value.
/// @param data Data payload.
/// @param operation Operation type.
/// @param safeTxGas Gas that should be used for the safe transaction.
/// @param baseGas Gas costs for that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)
/// @param gasPrice Maximum gas price that should be used for this transaction.
/// @param gasToken Token address (or 0 if ETH) that is used for the payment.
/// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).
/// @param _nonce Transaction nonce.
/// @return Transaction hash bytes.
function encodeTransactionData(
        address to,
        uint256 value,
        bytes calldata data,
        Enum.Operation operation,
        uint256 safeTxGas,
        uint256 baseGas,
        uint256 gasPrice,
        address gasToken,
        address refundReceiver,
        uint256 _nonce
    ) public view returns (bytes memory) {
        bytes32 safeTxHash =
            keccak256(
                abi.encode(
                    SAFE_TX_TYPEHASH,
                    to,
                    value,
                    keccak256(data),
                    operation,
                    safeTxGas,
                    baseGas,
                    gasPrice,
                    gasToken,
                    refundReceiver,
                    _nonce
                )
            );
        return abi.encodePacked(bytes1(0x19), bytes1(0x01), domainSeparator(), safeTxHash);
    }
// Solidity 0.7.6
/// @dev Returns hash to be signed by owners.
/// @param to Destination address.
/// @param value Ether value.
/// @param data Data payload.
/// @param operation Operation type.
/// @param safeTxGas Fas that should be used for the safe transaction.
/// @param baseGas Gas costs for data used to trigger the safe transaction.
/// @param gasPrice Maximum gas price that should be used for this transaction.
/// @param gasToken Token address (or 0 if ETH) that is used for the payment.
/// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).
/// @param _nonce Transaction nonce.
/// @return Transaction hash.
function getTransactionHash(
        address to,
        uint256 value,
        bytes calldata data,
        Enum.Operation operation,
        uint256 safeTxGas,
        uint256 baseGas,
        uint256 gasPrice,
        address gasToken,
        address refundReceiver,
        uint256 _nonce
    ) public view returns (bytes32) {
        return keccak256(encodeTransactionData(to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce));
    }
// Solidity 0.8.0
//A user can withdraw its staking tokens even if there is no rewards tokens on the contract account
function withdraw(uint256 nonce) public override nonReentrant {
        require(stakeAmounts[msg.sender][nonce] > 0, "LockStakingRewardMinAmountFixedAPY: This stake nonce was withdrawn");
        require(stakeLocks[msg.sender][nonce] < block.timestamp, "LockStakingRewardMinAmountFixedAPY: Locked");
        uint amount = stakeAmounts[msg.sender][nonce];
        uint amountRewardEquivalent = stakeAmountsRewardEquivalent[msg.sender][nonce];
        _totalSupply = _totalSupply.sub(amount);
        _totalSupplyRewardEquivalent = _totalSupplyRewardEquivalent.sub(amountRewardEquivalent);
        _balances[msg.sender] = _balances[msg.sender].sub(amount);
        _balancesRewardEquivalent[msg.sender] = _balancesRewardEquivalent[msg.sender].sub(amountRewardEquivalent);
        stakingToken.safeTransfer(msg.sender, amount);
        stakeAmounts[msg.sender][nonce] = 0;
        stakeAmountsRewardEquivalent[msg.sender][nonce] = 0;
        emit Withdrawn(msg.sender, amount);
    }
// Solidity 0.5.11
/**
 * Unlocks some amount of the strike token by burning option tokens.
 *
 * This mechanism ensures that users can only redeem tokens they've
 * previously lock into this contract.
 *
 * Options can only be burned while the series is NOT expired.
 */
function burn(uint256 amount) external beforeExpiration {
        require(amount <= lockedBalance[msg.sender], "Not enough underlying balance");

        // Burn option tokens
        lockedBalance[msg.sender] = lockedBalance[msg.sender].sub(amount);
        _burn(msg.sender, amount.mul(1e18));

        // Unlocks the strike token
        require(strikeAsset.transfer(msg.sender, amount.mul(strikePrice)), "Couldn't transfer back strike tokens to caller");
    }
// Solidity 0.5.11
/**
 * Allow put token holders to use them to sell some amount of units
 * of the underlying token for the amount * strike price units of the
 * strike token.
 *
 * It presumes the caller has already called IERC20.approve() on the
 * underlying token contract to move caller funds.
 *
 * During the process:
 *
 * - The amount * strikePrice of strike tokens are transferred to the
 * caller
 * - The amount of option tokens are burned
 * - The amount of underlying tokens are transferred into
 * this contract as a payment for the strike tokens
 *
 * Options can only be exchanged while the series is NOT expired.
 *
 * @param amount The amount of underlying tokens to be sold for strike
 * tokens
 */
function exchange(uint256 amount) external beforeExpiration {
        // Gets the payment from the caller by transfering them
        // to this contract
        uint256 underlyingAmount = amount * 10 ** uint256(underlyingAssetDecimals);
        require(underlyingAsset.transferFrom(msg.sender, address(this), underlyingAmount), "Couldn't transfer strike tokens from caller");

        // Transfers the strike tokens back in exchange
        _burn(msg.sender, amount.mul(1e18));
        require(strikeAsset.transfer(msg.sender, amount.mul(strikePrice)), "Couldn't transfer strike tokens to caller");
    }
// Solidity 0.5.11
/**
 * OZ initializer
 */
function _initialize(
        string memory name,
        string memory symbol,
        IERC20 _underlyingAsset,
        uint8 _underlyingAssetDecimals,
        IERC20 _strikeAsset,
        uint256 _strikePrice,
        uint256 _expirationBlockNumber) private
    {
        ERC20Detailed.initialize(name, symbol, 18);

        underlyingAsset = _underlyingAsset;
        underlyingAssetDecimals = _underlyingAssetDecimals;
        strikeAsset = _strikeAsset;
        strikePrice = _strikePrice;
        expirationBlockNumber = _expirationBlockNumber;
    }
// Solidity 0.8.4
// Update the rewards for the given user when one or more Zillas arise
function updateRewardOnArise(address _user, uint256 _amount) external {
        require(msg.sender == address(zillaContract), "Not the Zilla contract");

        // Check the timestamp of the block against the end yield date
        uint256 time = min(block.timestamp, END_YIELD);
        uint256 timerUser = lastUpdate[_user];

        // If one or more Zillas of the user were already minted, update the rewards to the new yield
        if (timerUser > 0) {
            rewards[_user] += getPendingRewards(_user,time) + (_amount * ARISE_ISSUANCE);
        }
        else {
            rewards[_user] += _amount * ARISE_ISSUANCE;
        }
        // Update the mapping to the newest update
        lastUpdate[_user] = time;
    }
// Solidity 0.8.4
// Called on transfers / update rewards in the Zilla contract, allowing the new owner to get $ZILLA tokens
function updateReward(address _from, address _to) external {
        require(msg.sender == address(zillaContract), "Not the Zilla contract");

        uint256 time = min(block.timestamp, END_YIELD);
        uint256 timerFrom = lastUpdate[_from];
        if (timerFrom > 0) {
            rewards[_from] += getPendingRewards(_from, time);
        }
        if (timerFrom != END_YIELD) {
            lastUpdate[_from] = time;
        }
        if (_to != address(0)) {
            uint256 timerTo = lastUpdate[_to];
            if (timerTo > 0) {
                rewards[_to] += getPendingRewards(_from, time);
            }
            if (timerTo != END_YIELD) {
                lastUpdate[_to] = time;
            }
        }
    }
// Solidity 0.8.4
// Mint $ZILLA tokens and send them to the user
function getReward(address _to) external {
        require(msg.sender == address(zillaContract), "Not the Zilla contract");
        uint256 reward = rewards[_to];
        if (reward > 0) {
            rewards[_to] = 0;
            _mint(_to, reward);
            emit RewardPaid(_to, reward);
        }
    }
// Solidity 0.7.6
//random number
function random(
		uint256 from,
		uint256 to,
		uint256 salty
	) public view returns (uint256) {
		uint256 seed =
			uint256(
				keccak256(
					abi.encodePacked(
						block.timestamp +
							block.difficulty +
							((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (block.timestamp)) +
							block.gaslimit +
							((uint256(keccak256(abi.encodePacked(_msgSender())))) / (block.timestamp)) +
							block.number +
							salty
					)
				)
			);
		return seed.mod(to - from) + from;
	}
// Solidity 0.4.18
/// NAC Broker Presale Token
/// @dev Constructor
function NamiCrowdSale(address _escrow, address _namiMultiSigWallet, address _namiPresale) public {
        require(_namiMultiSigWallet != 0x0);
        escrow = _escrow;
        namiMultiSigWallet = _namiMultiSigWallet;
        namiPresale = _namiPresale;
        // 
        balanceOf[_escrow] += 100000000000000000000000000; // 100 million NAC
        totalSupply += 100000000000000000000000000;
    }
// Solidity 0.4.18
/// @dev Returns number of tokens owned by given address.
/// @param _owner Address of token owner.
function burnTokens(address _owner) public
        onlyCrowdsaleManager
    {
        // Available only during migration phase
        require(currentPhase == Phase.Migrating);

        uint tokens = balanceOf[_owner];
        require(tokens != 0);
        balanceOf[_owner] = 0;
        totalSupply -= tokens;
        LogBurn(_owner, tokens);

        // Automatically switch phase when migration is done.
        if (totalSupply == 0) {
            currentPhase = Phase.Migrated;
            LogPhaseSwitch(Phase.Migrated);
        }
    }
// Solidity 0.4.18
/*/
 *  Administrative functions
 /*/
function setPresalePhase(Phase _nextPhase) public
        onlyEscrow
    {
        bool canSwitchPhase
            =  (currentPhase == Phase.Created && _nextPhase == Phase.Running)
            || (currentPhase == Phase.Running && _nextPhase == Phase.Paused)
                // switch to migration phase only if crowdsale manager is set
            || ((currentPhase == Phase.Running || currentPhase == Phase.Paused)
                && _nextPhase == Phase.Migrating
                && crowdsaleManager != 0x0)
            || (currentPhase == Phase.Paused && _nextPhase == Phase.Running)
                // switch to migrated only if everyting is migrated
            || (currentPhase == Phase.Migrating && _nextPhase == Phase.Migrated
                && totalSupply == 0);

        require(canSwitchPhase);
        currentPhase = _nextPhase;
        LogPhaseSwitch(_nextPhase);
    }
// Solidity 0.4.18
// internal migrate migration tokens
function _migrateToken(address _from, address _to)
        internal
    {
        PresaleToken presale = PresaleToken(namiPresale);
        uint256 newToken = presale.balanceOf(_from);
        require(newToken > 0);
        // burn old token
        presale.burnTokens(_from);
        // add new token to _to
        balanceOf[_to] = balanceOf[_to].add(newToken);
        // add new token to totalSupply
        totalSupply = totalSupply.add(newToken);
        LogMigrate(_from, _to, newToken);
    }
// Solidity 0.4.18
/**
 * @dev Transfer the specified amount of tokens to the specified address.
 *      Invokes the `tokenFallback` function if the recipient is a contract.
 *      The token transfer fails if the recipient is a contract
 *      but does not implement the `tokenFallback` function
 *      or the fallback function to receive funds.
 *
 * @param _to    Receiver address.
 * @param _value Amount of tokens that will be transferred.
 * @param _price price to sell token.
 */
function transferToExchange(address _to, uint _value, uint _price) public {
        uint codeLength;
        
        assembly {
            codeLength := extcodesize(_to)
        }
        
        balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value);
        balanceOf[_to] = balanceOf[_to].add(_value);
        if (codeLength > 0) {
            ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
            receiver.tokenFallbackExchange(msg.sender, _value, _price);
            TransferToExchange(msg.sender, _to, _value, _price);
        }
    }
// Solidity 0.4.24
/**
 	* @dev Activates voucher. Checks nonce amount and signature and if it is correct
 	* send amount of tokens to caller
 	* @param nonce voucher's nonce
 	* @param amount voucher's amount
 	* @param signature voucher's signature
 	*/
function activateVoucher(uint256 nonce, uint256 amount, bytes signature) public {
		require(!usedNonces[nonce], "nonce is already used");
		require(nonce != 0, "nonce should be greater than zero");
		require(amount != 0, "amount should be greater than zero");
		usedNonces[nonce] = true;

		address beneficiary = msg.sender;

		bytes32 message = prefixed(keccak256(abi.encodePacked(
			this,
			nonce,
			amount,
		  beneficiary)));

		address signedBy = recoverSigner(message, signature);
		require(signedBy == signerAddress);

		require(token.transfer(beneficiary, amount));
		emit VoucherRedemption(msg.sender, nonce, amount);
	}
// Solidity 0.4.18
// only escrow can call
function resetSession()
        public
        onlyEscrow
    {
        require(!session.isReset && !session.isOpen);
        session.priceOpen = 0;
        session.priceClose = 0;
        session.isReset = true;
        session.isOpen = false;
        session.investOpen = false;
        session.investorCount = 0;
        for (uint i = 0; i < MAX_INVESTOR; i++) {
            session.investor[i] = 0x0;
            session.win[i] = false;
            session.amountInvest[i] = 0;
        }
    }