lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.17
// sells your soul for a given price and a given reason!
function sellSoul(string reason, uint256 price) public payable{
        uint256 charonsObol;
        string storage has_reason = reasons[msg.sender];

        // require that user gives a reason
        require(bytes(reason).length > 0);

        // require to pay bookingFee
        require(msg.value >= bookingFee);

        // you cannot give away your soul for free, at least Charon wants some share
        charonsObol = price / obol;
        require(charonsObol > 0);

        // assert has not sold her or his soul, yet
        require(bytes(has_reason).length == 0);
        require(soulPrices[msg.sender] == 0);
        require(ownedBy[msg.sender] == address(0));

        // pay book keeping fee
        payCharon(msg.value);

        // store the reason forever on the blockchain
        reasons[msg.sender] = reason;
        // also the price is forever kept on the blockchain, so do not be too cheap
        soulPrices[msg.sender] = price;
        // and keep the soul in the soul book
        soulBook[soulsForSale + soulsSold] = msg.sender;
        soulsForSale += 1;
    }
// Solidity 0.4.17
// can transfer a soul to a different account, but beware you have to pay Charon again!
function transferSoul(address _to, address noSoulMate) public payable{
        uint256 charonsObol;

        // require correct ownership
        require(ownedBy[noSoulMate] == msg.sender);
        require(soulsOwned[_to] + 1 > soulsOwned[_to]);
        // require transfer fee is payed again
        charonsObol = soulPrices[noSoulMate] / obol;
        require(msg.value >= charonsObol);
        // pay Charon
        payCharon(msg.value);
        // transfer the soul
        soulsOwned[msg.sender] -= 1;
        soulsOwned[_to] += 1;
        ownedBy[noSoulMate] = _to;

        // Log the soul transfer
        SoulTransfer(msg.sender, _to);
    }
// Solidity 0.4.17
// transfers napkins to people
function payOutNapkins(uint256 amount) internal{
        // check for amount and wrap around
        require(amount > 0);
        // yeah some sanity check
        require(amount <= balances[this]);

        // send napkins from contract to msg.sender
        balances[this] -= amount;
        balances[msg.sender] += amount;
        // log napkin transfer
        Transfer(this, msg.sender, amount);
    }
// Solidity 0.5.0
/**
 * @notice Extract a bytes32 from a bytes.
 * @param data bytes from where the bytes32 will be extract
 * @param offset position of the first byte of the bytes32
 * @return address
 */
function extractBytes32(bytes memory data, uint offset)
    internal
    pure
    returns (bytes32 bs)
  {
    require(offset >= 0 && offset + 32 <= data.length, "offset value should be in the correct range");

    // solium-disable-next-line security/no-inline-assembly
    assembly {
        bs := mload(add(data, add(32, offset)))
    }
  }
// Solidity 0.5.0
/**
 * @notice Computes the fees.
 * @param _contentSize Size of the content of the block to be stored
 * @return the expected amount of fees in wei
 */
function getFeesAmount(uint256 _contentSize)
    public
    view
    returns(uint256)
  {
    // Transactions fee
    uint256 computedAllFee = _contentSize.mul(rateFeesNumerator);

    if (rateFeesDenominator != 0) {
      computedAllFee = computedAllFee.div(rateFeesDenominator);
    }

    if (computedAllFee <= minimumFee) {
      return minimumFee;
    } else {
      return computedAllFee;
    }
  }
// Solidity 0.5.0
/**
 * @notice Submit a new hash to the blockchain.
 *
 * @param _hash Hash of the request to be stored
 * @param _feesParameters fees parameters used to compute the fees. Here, it is the content size in an uint256
 */
function submitHash(string calldata _hash, bytes calldata _feesParameters)
    external
    payable
  {
    // extract the contentSize from the _feesParameters
    uint256 contentSize = uint256(Bytes.extractBytes32(_feesParameters, 0));

    // Check fees are paid
    require(getFeesAmount(contentSize) == msg.value, "msg.value does not match the fees");

    // Send fees to burner, throws on failure
    collectForREQBurning(msg.value);

    // declare the hash to the whole system through to RequestHashStorage
    requestHashStorage.declareNewHash(_hash, _feesParameters);
  }
// Solidity 0.4.13
// compressBoard removes last col and last row and joins digits into one number.
function compressBoard(uint[81] _b) constant returns (uint) {
    uint cb = 0;
    uint mul = 1000000000000000000000000000000000000000000000000000000000000000;
    for (uint i = 0; i < 72; i++) {
      if (i % 9 == 8) {
        continue;
      }
      cb = cb + mul * _b[i];
      mul = mul / 10;
    }
    return cb;
  }
// Solidity 0.6.0
/**
 * @dev Add Account to User Linked List.
 * @param _owner Account Owner.
 * @param _account Smart Account Address.
 */
function addAccount(address _owner, uint64 _account) internal {
        if (userLink[_owner].last != 0) {
            userList[_owner][_account].prev = userLink[_owner].last;
            userList[_owner][userLink[_owner].last].next = _account;
        }
        if (userLink[_owner].first == 0) userLink[_owner].first = _account;
        userLink[_owner].last = _account;
        userLink[_owner].count = add(userLink[_owner].count, 1);
    }
// Solidity 0.6.0
/**
 * @dev Remove Account from User Linked List.
 * @param _owner Account Owner/User.
 * @param _account Smart Account Address.
 */
function removeAccount(address _owner, uint64 _account) internal {
        uint64 _prev = userList[_owner][_account].prev;
        uint64 _next = userList[_owner][_account].next;
        if (_prev != 0) userList[_owner][_prev].next = _next;
        if (_next != 0) userList[_owner][_next].prev = _prev;
        if (_prev == 0) userLink[_owner].first = _next;
        if (_next == 0) userLink[_owner].last = _prev;
        userLink[_owner].count = sub(userLink[_owner].count, 1);
        delete userList[_owner][_account];
    }
// Solidity 0.6.0
/**
 * @dev Remove Owner from Account Linked List.
 * @param _owner Account Owner.
 * @param _account Smart Account Address.
 */
function removeUser(address _owner, uint64 _account) internal {
        address _prev = accountList[_account][_owner].prev;
        address _next = accountList[_account][_owner].next;
        if (_prev != address(0)) accountList[_account][_prev].next = _next;
        if (_next != address(0)) accountList[_account][_next].prev = _prev;
        if (_prev == address(0)) accountLink[_account].first = _next;
        if (_next == address(0)) accountLink[_account].last = _prev;
        accountLink[_account].count = sub(accountLink[_account].count, 1);
        delete accountList[_account][_owner];
    }
// Solidity 0.8.4
// Function to mint new NFTs during the presale
function mintDuringPresale(uint256 _numOfTokens) public payable whenNotPaused nonReentrant {
        require(isPreSaleActive==true, "Presale Not Active");
        if(checkWhitelist==true) {
            require(presaleAccess[msg.sender] == true, "Presale Access Denied");
        }
        require(presaleClaimed[msg.sender].add(_numOfTokens) <= PRESALE_PURCHASE_LIMIT, 
            "Above Presale Purchase Limit");
        require(publicTotalSupply.add(_numOfTokens) <= PUBLIC_NFT, 'Purchase would exceed max NFTs');
        require(NFT_PRICE.mul(_numOfTokens) == msg.value, "Invalid Amount");

        if(donate==true) {
            checkDistribution(_numOfTokens);
        }

        for (uint256 i = 0; i < _numOfTokens; i++) {
            _safeMint(msg.sender, RESERVE_NFT.add(publicTotalSupply));
            publicTotalSupply = publicTotalSupply.add(1);
        }
        presaleClaimed[msg.sender] = presaleClaimed[msg.sender].add(_numOfTokens);
    }
// Solidity 0.8.4
// Function to mint new NFTs during the public sale
function mint(uint256 _numOfTokens) public payable whenNotPaused nonReentrant {
        require(isMainSaleActive==true, "Sale Not Active");
        require(mainSaleClaimed[msg.sender].add(_numOfTokens) <= MAINSALE_PURCHASE_LIMIT, 
            "Above Main Sale Purchase Limit");
        require(publicTotalSupply.add(_numOfTokens) <= PUBLIC_NFT, "Purchase would exceed max NFTs");
        require(NFT_PRICE.mul(_numOfTokens) == msg.value, "Invalid Amount");
        
        if(donate==true) {
            checkDistribution(_numOfTokens);
        }

        for(uint256 i = 0; i < _numOfTokens; i++) {
            _mint(msg.sender, RESERVE_NFT.add(publicTotalSupply));
            publicTotalSupply = publicTotalSupply.add(1);
        }

        mainSaleClaimed[msg.sender] = mainSaleClaimed[msg.sender].add(_numOfTokens);
    }
// Solidity 0.8.4
// Function to check charity and treasury distribution
function checkDistribution(uint256 _numOfTokens) internal {
        if (publicTotalSupply < PUBLIC_NFT &&  publicTotalSupply.add(_numOfTokens) >= PUBLIC_NFT) {
            payable(communityTreasury).transfer(15 ether);
            payable(charity).transfer(12 ether);
        } else if (publicTotalSupply < 3675 && publicTotalSupply.add(_numOfTokens) >= 3675) {
            payable(communityTreasury).transfer(12 ether);
            payable(charity).transfer(8 ether);
        } else if (publicTotalSupply < 2450 &&  publicTotalSupply.add(_numOfTokens) >= 2450) {
            payable(communityTreasury).transfer(8 ether);
            payable(charity).transfer(6 ether);
        } else if (publicTotalSupply < 1225 && publicTotalSupply.add(_numOfTokens) >= 1225) {
            payable(communityTreasury).transfer(5 ether);
            payable(charity).transfer(4 ether);
        }
    }
// Solidity 0.8.1
/**
 * Reserve some GALAs for marketing and giveaway purpose.
 */
function reserveGiveaway(uint256 quantity) external onlyOwner {
        SaleConfig memory config = saleConfig;
        bool _publicSaleStarted = config.publicSaleStarted;
        bool _wlSaleStarted = config.wlSaleStarted;
        uint _reserved = config.reservedAmount;

        // the sale must not be started
        require (
            _publicSaleStarted == false && _wlSaleStarted == false,
            "The Reserve phase should only happen before the sale started!"
        );

        require(totalSupply() + quantity <= _reserved, "Exceeded giveaway supply");

        _safeMint(msg.sender, quantity);
    }
// Solidity 0.8.0
// mint a tx from clover to bsc chain
// note here we use the blockNumber + txIndex instead of txHash to identify the transaction
// because tx hash is not guarantee to be unique in substrate based chains.
// refer to: https://wiki.polkadot.network/docs/en/build-protocol-info#unique-identifiers-for-extrinsics
function mintTx(
        uint32 blockNumber,
        uint32 txIndex,
        address dest,
        uint256 amount
    ) public returns (bool) {
        require(
            hasRole(BRIDGE_ROLE, _msgSender()),
            "CloverBridge: must have bridge role"
        );
        require(dest != address(0), "SakuraBridge: invalid address");
        require(dest != address(this), "SakuraBridge: invalid dest address");
        require(
            _token.balanceOf(address(this)) >= amount,
            "SakuraBridge: balance is not enough in the bridge contract!"
        );

        uint64 txKey = getTxKey(blockNumber, txIndex);
        // check whether this tx is minted
        require(!_mintedTxs[txKey], "SakuraBridge: tx already minted!");

        // transfer might fail with some reason
        // e.g. the transfer is paused in the token contract
        require(
            _token.transfer(dest, amount),
            "SakuraBridge: transfer failed!"
        );
        _mintedTxs[txKey] = true;

        emit TxMinted(blockNumber, txIndex, dest, amount);
        return true;
    }
// Solidity 0.4.24
/*
 	function selleth(uint amount) public payable {
 	    //address user = msg.sender;
 	    //canOf[user] = myuseOf(user);
 	    //require(balances[user] >= amount );
 	    //uint money = amount * sellPrice;
 	   // balances[msg.sender] += money;
 	    owner.transfer(amount);
 	}*/
function sell(uint256 amount) public returns(bool success) {
		//address user = msg.sender;
		//canOf[msg.sender] = myuseOf(msg.sender);
		//require(!frozenAccount[msg.sender]);
		uint256 canuse = getcanuse(msg.sender);
		require(canuse >= amount);
		uint moneys = amount / sellPrice;
		require(msg.sender.send(moneys));
		balances[msg.sender] -= amount;
		balances[this] += amount;
		//_totalSupply += amount;
		//canOf[msg.sender] -= amount;
		
		//this.transfer(moneys);Transfer(this, msg.sender, revenue);  
		emit Transfer(this, msg.sender, moneys);
		//canOf[user] -= amount;
		return(true);
	}
// Solidity 0.4.13
/**
 * Multiplication with safety check
 */
function Mul(uint a, uint b) constant internal returns (uint) {
      uint c = a * b;
      //check result should not be other wise until a=0
      assert(a == 0 || c / a == b);
      return c;
    }
// Solidity 0.4.13
/**
 * Division with safety check
 */
function Div(uint a, uint b) constant internal returns (uint) {
      //overflow check; b must not be 0
      assert(b > 0);
      uint c = a / b;
      assert(a == b * c + a % b);
      return c;
    }
// Solidity 0.4.13
/**
 * Subtraction with safety check
 */
function Sub(uint a, uint b) constant internal returns (uint) {
      //b must be greater that a as we need to store value in unsigned integer
      assert(b <= a);
      return a - b;
    }
// Solidity 0.4.13
/**
 * Addition with safety check
 */
function Add(uint a, uint b) constant internal returns (uint) {
      uint c = a + b;
      //result must be greater as a or b can not be negative
      assert(c>=a && c>=b);
      return c;
    }
// Solidity 0.4.13
//Contructor to define EXH Token token properties
function EXH() public {

    // lock the transfer function during Sale
    locked = true;

    //initial token supply is 0
    totalSupply = 0;

    //Name for token set to EXH Token
    name = 'EXH Token';

    // Symbol for token set to 'EXH'
    symbol = 'EXH';
 
    decimals = 18;
  }
// Solidity 0.4.13
//Implementation for transferring EXH Token to provided address 
function transfer(address _to, uint _value) onlyPayloadSize(2 * 32) public onlyUnlocked returns (bool){

    //Check provided EXH Token should not be 0
    if (_value > 0 && !(_to == address(0))) {
      //deduct EXH Token amount from transaction initiator
      balances[msg.sender] = balances[msg.sender].Sub(_value);
      //Add EXH Token to balace of target account
      balances[_to] = balances[_to].Add(_value);
      //Emit event for transferring EXH Token
      Transfer(msg.sender, _to, _value);
      return true;
    }
    else{
      return false;
    }
  }
// Solidity 0.4.13
//Transfer initiated by spender 
function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3 * 32) public onlyUnlocked returns (bool) {

    //Check provided EXH Token should not be 0
    if (_value > 0 && (_to != address(0) && _from != address(0))) {
      //Get amount of EXH Token for which spender is authorized
      var _allowance = allowed[_from][msg.sender];
      //Add amount of EXH Token in trarget account's balance
      balances[_to] = balances[_to].Add( _value);
      //Deduct EXH Token amount from _from account
      balances[_from] = balances[_from].Sub( _value);
      //Deduct Authorized amount for spender
      allowed[_from][msg.sender] = _allowance.Sub( _value);
      //Emit event for Transfer
      Transfer(_from, _to, _value);
      return true;
    }else{
      return false;
    }
  }
// Solidity 0.4.13
/*
 * To start Sale from Presale
 */
function start() public onlyOwner {
    //Set block number to current block number
    assert(startBlock == 0);
    startBlock = now;            
    //Set end block number
    endBlock = now.Add(durationCrowdSale.Add(durationPreSale));
    //Sale presale is started
    crowdsaleStatus = 1;
    //Emit event when crowdsale state changes
    StateChanged(true);  
  }
// Solidity 0.4.13
/*
 * To start Crowdsale
 */
function startSale() public onlyOwner
  {
    if(now > startBlock.Add(durationPreSale) && now <= endBlock){
        crowdsaleStatus = 1;
        crowdSaleType = 1;
        if(crowdSaleType != 1)
        {
          totalSupplyCrowdsale = totalSupplyPreSale;
        }
        //Emit event when crowdsale state changes
        StateChanged(true); 
    }
    else
      revert();
  }
// Solidity 0.4.13
/*
 * To extend duration of Crowdsale
 */
function updateDuration(uint time) public onlyOwner
  {
      require(time != 0);
      assert(startBlock != 0);
      assert(crowdSaleType == 1 && crowdsaleStatus != 2);
      durationCrowdSale = durationCrowdSale.Add(time);
      endBlock = endBlock.Add(time);
      //Emit event when crowdsale state changes
      StateChanged(true);
  }
// Solidity 0.4.13
/*
 * To enable vesting of B type EXH Token
 */
function MintAndTransferToken(address beneficiary,uint exhToCredit,bytes32 comment) external onlyOwner {
    //Available after the crowdsale is started
    assert(startBlock != 0);
    //Check whether tokens are available or not
    assert(totalSupplyMintTransfer <= maxCapMintTransfer);
    //Check whether the amount of token are available to transfer
    require(totalSupplyMintTransfer.Add(exhToCredit) <= maxCapMintTransfer);
    //Update EXH Token balance for beneficiary
    balances[beneficiary] = balances[beneficiary].Add(exhToCredit);
    //Update total supply for EXH Token
    totalSupply = totalSupply.Add(exhToCredit);
    //update total supply for EXH token in mint and transfer
    totalSupplyMintTransfer = totalSupplyMintTransfer.Add(exhToCredit);
    // send event for transferring EXH Token on offline payment
    MintAndTransferEXH(beneficiary, exhToCredit,comment);
    //Emit event when crowdsale state changes
    StateChanged(true);  
  }
// Solidity 0.4.13
/*
 * To get price for EXH Token
 */
function getPrice() public constant returns (uint result) {
      if (crowdSaleType == 0) {
            return (PRICE.Mul(100)).Div(70);
      }
      if (crowdSaleType == 1) {
          uint crowdsalePriceBracket = 1 weeks;
          uint startCrowdsale = startBlock.Add(durationPreSale);
            if (now > startCrowdsale && now <= startCrowdsale.Add(crowdsalePriceBracket)) {
                return ((PRICE.Mul(100)).Div(80));
            }else if (now > startCrowdsale.Add(crowdsalePriceBracket) && now <= (startCrowdsale.Add(crowdsalePriceBracket.Mul(2)))) {
                return (PRICE.Mul(100)).Div(85);
            }else if (now > (startCrowdsale.Add(crowdsalePriceBracket.Mul(2))) && now <= (startCrowdsale.Add(crowdsalePriceBracket.Mul(3)))) {
                return (PRICE.Mul(100)).Div(90);
            }else if (now > (startCrowdsale.Add(crowdsalePriceBracket.Mul(3))) && now <= (startCrowdsale.Add(crowdsalePriceBracket.Mul(4)))) {
                return (PRICE.Mul(100)).Div(95);
            }
      }
      return PRICE;
  }
// Solidity 0.4.13
/*
 * Finalize the crowdsale
 */
function finalize() public onlyOwner {
    //Make sure Sale is running
    assert(crowdsaleStatus==1 && crowdSaleType==1);
    // cannot finalise before end or until maxcap is reached
      assert(!((totalSupplyCrowdsale < maxCap && now < endBlock) && (maxCap.Sub(totalSupplyCrowdsale) >= valueOneEther)));  
      //Indicates Sale is ended
      
      //Checks if the fundraising goal is reached in crowdsale or not
      if (totalSupply < 5300000e18)
        refundStatus = 2;
      else
        refundStatus = 1;
      
    //crowdsale is ended
    crowdsaleStatus = 2;
    //Emit event when crowdsale state changes
    StateChanged(true);
  }
// Solidity 0.4.13
/*
 * Refund the investors in case target of crowdsale not achieved
 */
function refund() public onlyOwner {
      assert(refundStatus == 2);
      uint batchSize = countInvestorsRefunded.Add(50) < countTotalInvestors ? countInvestorsRefunded.Add(50): countTotalInvestors;
      for(uint i=countInvestorsRefunded.Add(1); i <= batchSize; i++){
          address investorAddress = investorList[i];
          Investor storage investorStruct = investors[investorAddress];
          //If purchase has been made during CrowdSale
          if(investorStruct.exhSentCrowdsaleType1 > 0 && investorStruct.exhSentCrowdsaleType1 <= balances[investorAddress]){
              //return everything
              investorAddress.transfer(investorStruct.weiReceivedCrowdsaleType1);
              //Reduce ETHReceived
              ETHReceived = ETHReceived.Sub(investorStruct.weiReceivedCrowdsaleType1);
              //Update totalSupply
              totalSupply = totalSupply.Sub(investorStruct.exhSentCrowdsaleType1);
              // reduce balances
              balances[investorAddress] = balances[investorAddress].Sub(investorStruct.exhSentCrowdsaleType1);
              //set everything to zero after transfer successful
              investorStruct.weiReceivedCrowdsaleType1 = 0;
              investorStruct.exhSentCrowdsaleType1 = 0;
              countInvestorsRefundedInCrowdsale = countInvestorsRefundedInCrowdsale.Add(1);
          }
      }
      //Update the number of investors that have recieved refund
      countInvestorsRefunded = batchSize;
      StateChanged(true);
  }
// Solidity 0.4.24
// ------------------------------------------------------------------------
// Allocate a particular amount of tokens from onwer to an account
// ------------------------------------------------------------------------
function allocate(address to, uint amount) public onlyOwner {
        require(to != address(0));
        require(!frozenAccount[to]);
        require(!halted && amount > 0);
        require(balances[owner] >= amount);

        balances[owner] = balances[owner].sub(amount);
        balances[to] = balances[to].add(amount);
        emit Transfer(address(0), to, amount);
    }
// Solidity 0.4.23
// calculation of the percentage of profit depending on the balance sheet
// returns the percentage times 10
function calculateProfitPercent(uint bal) private pure returns (uint) {
        if (bal >= 1e22) { // balance >= 10000 ETH
            return 50;
        }
        if (bal >= 7e21) { // balance >= 7000 ETH
            return 47;
        }
        if (bal >= 5e21) { // balance >= 5000 ETH
            return 45;
        }
        if (bal >= 3e21) { // balance >= 3000 ETH
            return 42;
        }
        if (bal >= 1e21) { // balance >= 1000 ETH
            return 40;
        }
        if (bal >= 5e20) { // balance >= 500 ETH
            return 35;
        }
        if (bal >= 2e20) { // balance >= 200 ETH
            return 30;
        }
        if (bal >= 1e20) { // balance >= 100 ETH
            return 27;
        } else {
            return 25;
        }
    }
// Solidity 0.4.23
// transfer default refback and referrer percents of invested
function transferRefPercents(uint value, address sender) private {
        if (msg.data.length != 0) {
            address referrer = bytesToAddress(msg.data);
            if(referrer != sender) {
                sender.transfer(value * refBack / 100);
                referrer.transfer(value * refPercent / 100);
            } else {
                defaultReferrer.transfer(value * refPercent / 100);
            }
        } else {
            defaultReferrer.transfer(value * refPercent / 100);
        }
    }