lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.8.4
/**
 * @notice Allows Blocksport to cancel an auction, refunding the bidder and returning the NFT to the seller.
 * This should only be used for extreme cases such as DMCA takedown requests. The reason should always be provided.
 */
function _adminCancelReserveAuction(uint256 auctionId, string memory reason)
        private
        onlyBlocksportAdmin
    {
        require(
            bytes(reason).length > 0,
            "NFTMarketReserveAuction: Include a reason for this cancellation"
        );
        ReserveAuction memory auction = auctionIdToAuction[auctionId];
        require(
            auction.amount > 0,
            "NFTMarketReserveAuction: Auction not found"
        );

        delete nftContractToTokenIdToAuctionId[auction.nftContract][
            auction.tokenId
        ];
        delete auctionIdToAuction[auctionId];

        IERC721Upgradeable(auction.nftContract).transferFrom(
            address(this),
            auction.seller,
            auction.tokenId
        );
        if (auction.bidder != address(0)) {
            _sendValueWithFallbackWithdrawWithMediumGasLimit(
                auction.bidder,
                auction.amount
            );
        }

        emit ReserveAuctionCanceledByAdmin(auctionId, reason);
    }
// Solidity 0.8.4
/**
 * @notice Allows Blocksport to ban token, refunding the bidder and returning the NFT to the seller.
 */
function adminBanToken(
        address nftContract,
        uint256 tokenId,
        string memory reason
    ) public onlyBlocksportAdmin {
        require(
            bytes(reason).length > 0,
            "NFTMarketReserveAuction: Include a reason for this ban"
        );
        require(!bannedTokens[nftContract][tokenId], "Token already banned");
        uint256 auctionId = getReserveAuctionIdFor(nftContract, tokenId);

        if (auctionIdToAuction[auctionId].tokenId == tokenId) {
            bannedAuction[nftContract][tokenId] = auctionIdToAuction[auctionId];
            _adminCancelReserveAuction(auctionId, reason);
            emit ReserveAuctionBannedByAdmin(auctionId, reason);
        }

        bannedTokens[nftContract][tokenId] = true;
        emit TokenBannedByAdmin(nftContract, tokenId, reason);
    }
// Solidity 0.8.4
/**
 * @notice Allows Blocksport to unban token, and list it again with no bids in the auction.
 */
function adminUnbanToken(address nftContract, uint256 tokenId)
        public
        onlyBlocksportAdmin
    {
        require(
            !bannedTokens[nftContract][tokenId],
            "NFTMarketReserveAuction: Token not banned"
        );

        if (bannedAuction[nftContract][tokenId].tokenId > 0) {
            ReserveAuction memory auction = bannedAuction[nftContract][tokenId];
            delete bannedAuction[nftContract][tokenId];
            createReserveAuction(nftContract, auction.tokenId, auction.amount);
            emit ReserveAuctionUnbannedByAdmin(auction.tokenId);
        }

        delete bannedTokens[nftContract][tokenId];
        emit TokenUnbannedByAdmin(nftContract, tokenId);
    }
// Solidity 0.4.15
/**
 * Begins the crowdsale (presale period)
 * @param tokenContractAddress - address of the `WIN` contract (token holder)
 * @dev must be called by one of owners
 */
function startPresale (address tokenContractAddress)   onlyOneOfOwners  {  
        require(state == State.NotStarted);

        win = WIN(tokenContractAddress);

        assert(win.balanceOf(this) >= tokensForPeriod(0));

        periods[0] = Period(now, NEVER, PRESALE_TOKEN_PRICE, 0);
        PeriodStarted(0,
            PRESALE_TOKEN_PRICE,
            tokensForPeriod(currentPeriod),
            now,
            NEVER,
            now);
        state = State.Presale;
    }
// Solidity 0.4.15
/**
 * Withdraws the money to be spent to Blind Croupier Project needs
 * @param  amount - amount of Wei to withdraw (total)
 */
function withdraw (uint256 amount)   onlyOneOfOwners  {  
        require(this.balance >= amount);

        uint totalShares = 0;
        for(var idx = 0; idx < owners.length; idx++) {
            totalShares += owners[idx].share;
        }

        for(idx = 0; idx < owners.length; idx++) {
            owners[idx].recipient.transfer(amount * owners[idx].share / totalShares);
        }
    }
// Solidity 0.8.7
// function sliceBytes32To10(bytes32 input) public pure returns (bytes10 output) {
//     assembly {
//         output := input
//     }
// }
function claim(address _to, uint256 _tokenId, string memory _tokenMidContent) public {
        require(_tokenId >= 0 && _tokenId < 2392, "Token ID invalid");
        if (_tokenId >= 0 && _tokenId < 104) {
            require(bytes(_tokenMidContent).length == 429, "Token Content Size invalid");
            require(_tokenMidContentHashes[_tokenId] == keccak256(abi.encodePacked(_tokenMidContent)), "Token Content invalid");
        } else {
            _tokenMidContent = "";
        }
        _safeMint(_to, _tokenId);
        _tokenMidContents[_tokenId] = _tokenMidContent;
    }
// Solidity 0.8.7
/// @dev not test for functions related to signature
function verifySignature(
        uint256[] memory _tokenIds,
        uint256 _price,
        address _paymentTokenAddress,
        bytes memory _signature
    ) internal view returns (bool) {
        bytes32 messageHash = getMessageHash(
            _tokenIds,
            _price,
            _paymentTokenAddress
        );
        bytes32 ethSignedMessageHash = getEthSignedMessageHash(messageHash);
        return recoverSigner(ethSignedMessageHash, _signature) == owner();
    }
// Solidity 0.8.7
// ----- PUBLIC METHODS ----- //
function buyToken(
        uint256[] memory _tokenIds,
        uint256 _price,
        address _paymentToken,
        address _receiver,
        bytes memory _signature
    ) external payable {
        require(_tokenIds.length == 1, "More than one token");
        require(
            verifySignature(_tokenIds, _price, _paymentToken, _signature),
            "Signature mismatch"
        );
        if (_price != 0) {
            if (_paymentToken == address(0)) {
                require(msg.value >= _price, "Not enough ether");
                if (_price < msg.value) {
                    payable(msg.sender).transfer(msg.value - _price);
                }
            } else {
                require(
                    IERC20(_paymentToken).transferFrom(
                        msg.sender,
                        address(this),
                        _price
                    )
                );
            }
        }
        address[] memory receivers = new address[](1);
        receivers[0] = _receiver;
        IUniqCollections(_shopAddress).batchMintSelectedIds(
            _tokenIds,
            receivers
        );
    }
// Solidity 0.8.4
//called when transfers happened, to ensure new users will generate tokens too
function rewardSystemUpdate(address from, address to) external {
        require(msg.sender == address(PixelTigers));
        if(from != address(0)){
            storeRewards[from] += pendingReward(from);
            lastUpdate[from] = block.timestamp;
        }
        if(to != address(0)){
            storeRewards[to] += pendingReward(to);
            lastUpdate[to] = block.timestamp;
        }
    }
// Solidity 0.5.0
// Register player
function playerRegister(string memory name, uint64[] memory numbers) payable public {
    require(contractActive == true, "Contract was disabled");
    require(state == State.Accepting, "Game state is not valid");
    require(numbers.length > 0, "At least 1 number");
    require(msg.value >= minPrice * numbers.length, "Value is not valid");

    for (uint i = 0; i < playerList.length; i++) {
      require(playerList[i].playerAddress != msg.sender);
      for (uint j = 0; j < playerList[i].playerNumbers.length; j++) {
        require(playerList[i].playerNumbers[j] <= maxLuckyNumberRandom);
      }
    }

    totalFund += msg.value;
    Player memory player = Player(msg.sender, name, numbers);
    playerList.push(player);
    emit PlayerRegisterEvent(player.playerAddress);

    if (playerList.length >= playerInSession) {
      finishGame();

      if (contractActive) {
        // Init new game session
        gameInit();
      }
    }
  }
// Solidity 0.6.12
// Emergency drain in case of a bug
// Adds all funds to owner to refund people
// Designed to be as simple as possible
function emergencyDrain24hAfterLiquidityGenerationEventIsDone() public onlyOwner {
        require(contractStartTimestamp.add(8 days) < block.timestamp, "Liquidity generation grace period still ongoing"); // About 24h after liquidity generation happens
        (bool success, ) = msg.sender.call.value(address(this).balance)("");
        require(success, "Transfer failed.");
        _balances[msg.sender] = _balances[address(this)];
        _balances[address(this)] = 0;
    }
// Solidity 0.4.24
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to `to` account
// - Owner's account must have sufficient balance to transfer
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
        require(to != address(0));
        require(tokens > 0);
        require(balances[msg.sender] >= tokens); 
        
        balances[msg.sender] = balances[msg.sender].sub(tokens);
        balances[to] = balances[to].add(tokens);
        emit Transfer(msg.sender, to, tokens);
        return true;
    }
// Solidity 0.8.4
// Mint function for OG sale
// Caller MUST be OG-Whitelisted to use this function!
function freeWhitelistMint() external isWallet enoughSupply(maxMintsOg) {
        require(freeWhitelistEnabled, 'OG sale not enabled');
        if (isGenesis) {
            require(genesisOg[msg.sender] >= maxMintsOg, 'Not a wiggle world OG');
            genesisOg[msg.sender] = genesisOg[msg.sender] - maxMintsOg;
        } else {
            require(freeWhitelist[msg.sender] >= maxMintsOg, 'Not a wiggle world OG');
            freeWhitelist[msg.sender] = freeWhitelist[msg.sender] - maxMintsOg;
        }
        _safeMint(msg.sender, maxMintsOg);
    }
// Solidity 0.8.4
// Mint function for whitelist sale
// Requires minimum ETH value of unitPrice * quantity
// Caller MUST be whitelisted to use this function!
function paidWhitelistMint(uint256 quantity) external payable isWallet enoughSupply(quantity) {
        require(paidWhitelistEnabled, 'Whitelist sale not enabled');
        require(msg.value >= quantity * unitPrice, 'Not enough ETH');
        if (isGenesis) {
            require(genesisWhitelist[msg.sender] >= quantity, 'No whitelist mints left');
            genesisWhitelist[msg.sender] = genesisWhitelist[msg.sender] - quantity;
        } else {
            require(paidWhitelist[msg.sender] >= quantity, 'No whitelist mints left');
            paidWhitelist[msg.sender] = paidWhitelist[msg.sender] - quantity;
        }
        _safeMint(msg.sender, quantity);
        refundIfOver(quantity * unitPrice);
    }
// Solidity 0.8.4
// Mint function for public sale
// Requires minimum ETH value of unitPrice * quantity
function publicMint(uint256 quantity) external payable isWallet enoughSupply(quantity) {
        require(publicMintEnabled, 'Minting not enabled');
        require(quantity <= maxMints, 'Illegal quantity');
        require(numberMinted(msg.sender) + quantity <= maxMints, 'Cant mint that many');
        require(msg.value >= quantity * unitPrice, 'Not enough ETH');
        _safeMint(msg.sender, quantity);
        refundIfOver(quantity * unitPrice);
    }
// Solidity 0.8.4
// Mint function for developers (owner)
// Mints a maximum of 20 NFTs to the recipient
// Used for devs, marketing, friends, family
// Capped at 55 mints total
function devMint(uint256 quantity, address recipient)
        external
        onlyOwner
        enoughSupply(quantity)
    {
        if (isGenesis) {
            require(remainingDevSupply - quantity >= genesisDevCutoff, 'No dev supply (genesis)');
        } else {
            require(remainingDevSupply - quantity >= 0, 'Not enough dev supply');
        }
        require(quantity <= maxMints, 'Illegal quantity');
        require(numberMinted(recipient) + quantity <= maxMints, 'Cant mint that many (dev)');
        remainingDevSupply = remainingDevSupply - quantity;
        _safeMint(recipient, quantity);
    }
// Solidity 0.8.4
// Returns the correct URI for the given tokenId based on contract state
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), 'Nonexistent token');
        if (
            (tokenId < genesisCollectionSize && genesisRevealed == false) ||
            (tokenId >= genesisCollectionSize && revealed == false)
        ) {
            return
                bytes(notRevealedURI).length > 0
                    ? string(
                        abi.encodePacked(
                            notRevealedURI,
                            Strings.toString(tokenId % numBackgrounds),
                            baseExtension
                        )
                    )
                    : '';
        }
        return
            bytes(baseURI).length > 0
                ? string(abi.encodePacked(baseURI, Strings.toString(tokenId), baseExtension))
                : '';
    }
// Solidity 0.8.4
// Update relevant mint format variables.
// Should only be called once,
// To change price between genesis and second mint.
function updateMintFormat(
        uint256 _ogSlots,
        uint256 _ogWlSlots,
        uint256 _wlSlots,
        uint256 _maxMints,
        uint256 _numBackgrounds
    ) external onlyOwner {
        maxMintsOg = _ogSlots;
        ogWlMints = _ogWlSlots;
        maxMintsWhitelist = _wlSlots;
        maxMints = _maxMints;
        numBackgrounds = _numBackgrounds;
    }
// Solidity 0.8.4
// Set the mint state
function setMintState(uint256 _state) external onlyOwner {
        if (_state == 1) {
            freeWhitelistEnabled = true;
        } else if (_state == 2) {
            paidWhitelistEnabled = true;
        } else if (_state == 3) {
            publicMintEnabled = true;
        } else {
            freeWhitelistEnabled = false;
            paidWhitelistEnabled = false;
            publicMintEnabled = false;
        }
    }
// Solidity 0.8.4
// Seed the appropriate whitelist
function setWhitelist(address[] calldata addrs, bool isOG) external onlyOwner {
        if (isOG) {
            for (uint256 i = 0; i < addrs.length; i++) {
                if (isGenesis) {
                    genesisOg[addrs[i]] = maxMintsOg;
                    genesisWhitelist[addrs[i]] = ogWlMints;
                } else {
                    freeWhitelist[addrs[i]] = maxMintsOg;
                    paidWhitelist[addrs[i]] = ogWlMints;
                }
            }
        } else {
            for (uint256 i = 0; i < addrs.length; i++) {
                if (isGenesis) {
                    genesisWhitelist[addrs[i]] = maxMintsWhitelist;
                } else {
                    paidWhitelist[addrs[i]] = maxMintsWhitelist;
                }
            }
        }
    }
// Solidity 0.4.19
/*
 Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender.
 param _spender The address which will spend the funds.
 param _value The amount of Roman Lanskoj's tokens to be spent.
 */
function approve(address _spender, uint256 _value) returns (bool) {
 
    // To change the approve amount you first have to reduce the addresses`
    //  allowance to zero by calling `approve(_spender, 0)` if it is not
    //  already 0 to mitigate the race condition described here:
    //  https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
    require((_value == 0) || (allowed[msg.sender][_spender] == 0));
 
    allowed[msg.sender][_spender] = _value;
    Approval(msg.sender, _spender, _value);
    return true;
  }
// Solidity 0.3.6
/**
 * @notice Transfer `_amount` from `_caller` to `_to`.
 *
 * @param _caller Origin address
 * @param _to Address that will receive.
 * @param _amount Amount to be transferred.
 */
function transfer(address _caller, address _to, uint256 _amount) onlyAsset returns (bool success) {
    assert(allowTransactions);
    assert(!frozenAccount[_caller]);
    assert(balanceOf[_caller] >= _amount);
    assert(balanceOf[_to] + _amount >= balanceOf[_to]);
    activateAccount(_caller);
    activateAccount(_to);
    balanceOf[_caller] -= _amount;
    if (_to == address(this)) treasuryBalance += _amount;
    else {
        uint256 fee = feeFor(_caller, _to, _amount);
        balanceOf[_to] += _amount - fee;
        treasuryBalance += fee;
    }
    Transfer(_caller, _to, _amount);
    return true;
  }
// Solidity 0.8.4
/// @notice Calculate atomic number for a given tokenId and token hash
/// @dev The reason it needs both is that atomic number is partially based on tokenId.
/// @param _tokenId The tokenId of the Atom
/// @param _hash Hash of Atom
/// @return Atomic number of the given Atom
function calculateAtomicNumber(uint _tokenId, bytes32 _hash, uint generation) private pure returns(uint){
        if(_tokenId == 1) return 0;

        bytes32 divisor = 0x0000000001000000000000000000000000000000000000000000000000000000;
        uint salt = uint(_hash)/uint(divisor);

        uint max;
        if(generation >= 13){
            max = 118;
        }else if(generation >= 11){
            max = 86;
        }else if(generation >= 9){
            max = 54;
        }else if(generation >= 7){
            max = 36;
        }else if(generation >= 5){
            max = 18;
        }else if(generation >= 3){
            max = 10;
        }else if(generation >= 1){
            max = 2;
        }

        uint gg;
        if(generation >= 8){
            gg = 2;
        }else{
            gg = 1;
        }


        uint decimal = 10000000000000000;
        uint divisor2 = uint(0xFFFFFFFFFF);


        uint unrounded = max * decimal * (salt ** gg) / (divisor2 ** gg);
        uint rounded = ceil(
            unrounded,
            decimal
        );
        return rounded/decimal;
    }
// Solidity 0.3.6
/**
 * @notice Transfer `_amount` from `_from` to `_to`, invoked by `_caller`.
 *
 * @param _caller Invoker of the call (owner of the allowance)
 * @param _from Origin address
 * @param _to Address that will receive
 * @param _amount Amount to be transferred.
 * @return result of the method call
 */
function transferFrom(address _caller, address _from, address _to, uint256 _amount) onlyAsset returns (bool success) {
    assert(allowTransactions);
    assert(!frozenAccount[_caller]);
    assert(!frozenAccount[_from]);
    assert(balanceOf[_from] >= _amount);
    assert(balanceOf[_to] + _amount >= balanceOf[_to]);
    assert(_amount <= allowance[_from][_caller]);
    balanceOf[_from] -= _amount;
    uint256 fee = feeFor(_from, _to, _amount);
    balanceOf[_to] += _amount - fee;
    treasuryBalance += fee;
    allowance[_from][_caller] -= _amount;
    activateAccount(_from);
    activateAccount(_to);
    activateAccount(_caller);
    Transfer(_from, _to, _amount);
    return true;
  }
// Solidity 0.6.10
/**
 * @dev Moves tokens `_amount` from `_sender` to `_recipient`.
 * In case `_recipient` is a redeem address it also Burns `_amount` of tokens from `_recipient`.
 *
 * Emits a {Transfer} event.
 *
 * Requirements:
 *
 * - {userRegistry.canTransferFrom} should not revert
 */
function transferFrom(
        address _sender,
        address _recipient,
        uint256 _amount
    ) public override returns (bool) {
        userRegistry.canTransferFrom(_msgSender(), _sender, _recipient);

        super.transferFrom(_sender, _recipient, _amount);

        if (userRegistry.isRedeemFrom(_msgSender(), _sender, _recipient)) {
            _redeem(_recipient, _amount);
        }

        return true;
    }
// Solidity 0.3.6
/**
 * @notice Approve Approves spender `_spender` to transfer `_amount` from `_caller`
 *
 * @param _caller Address that grants the allowance
 * @param _spender Address that receives the cheque
 * @param _amount Amount on the cheque
 * @param _extraData Consequential contract to be executed by spender in same transcation.
 * @return result of the method call
 */
function approveAndCall(address _caller, address _spender, uint256 _amount, bytes _extraData) onlyAsset returns (bool success) {
    assert(allowTransactions);
    assert(!frozenAccount[_caller]);
    allowance[_caller][_spender] = _amount;
    activateAccount(_caller);
    activateAccount(_spender);
    activateAllowanceRecord(_caller, _spender);
    TokenRecipient spender = TokenRecipient(_spender);
    assert(Relay(assetAddress).relayReceiveApproval(_caller, _spender, _amount, _extraData));
    Approval(_caller, _spender, _amount);
    return true;
  }
// Solidity 0.7.3
// get minimal proxy creation code
function minimalProxyCreationCode(address logic) internal pure returns (bytes memory) {
        bytes10 creation = 0x3d602d80600a3d3981f3;
        bytes10 prefix = 0x363d3d373d3d3d363d73;
        bytes20 targetBytes = bytes20(logic);
        bytes15 suffix = 0x5af43d82803e903d91602b57fd5bf3;
        return abi.encodePacked(creation, prefix, targetBytes, suffix);
    }
// Solidity 0.4.24
// Allow the owner to easily create the default dice games
function createDefaultGames() public
    {
        require(allGames.length == 0);
        
        addNewStakeDiceGame(500); // 5% chance
        addNewStakeDiceGame(1000); // 10% chance
        addNewStakeDiceGame(1500); // 15% chance
        addNewStakeDiceGame(2000); // 20% chance
        addNewStakeDiceGame(2500); // 25% chance
        addNewStakeDiceGame(3000); // 30% chance
        addNewStakeDiceGame(3500); // 35% chance
        addNewStakeDiceGame(4000); // 40% chance
        addNewStakeDiceGame(4500); // 45% chance
        addNewStakeDiceGame(5000); // 50% chance
        addNewStakeDiceGame(5500); // 55% chance
        addNewStakeDiceGame(6000); // 60% chance
        addNewStakeDiceGame(6500); // 65% chance
        addNewStakeDiceGame(7000); // 70% chance
        addNewStakeDiceGame(7500); // 75% chance
        addNewStakeDiceGame(8000); // 80% chance
        addNewStakeDiceGame(8500); // 85% chance
        addNewStakeDiceGame(9000); // 90% chance
        addNewStakeDiceGame(9500); // 95% chance
    }
// Solidity 0.4.24
// Allow the owner to add new games with different winning chances
function addNewStakeDiceGame(uint256 _winningChance) public
    {
        require(msg.sender == owner);
        
        // Deploy a new StakeDiceGame contract
        StakeDiceGame newGame = new StakeDiceGame(this, _winningChance);
        
        // Store the fact that this new address is a StakeDiceGame contract
        addressIsStakeDiceGameContract[newGame] = true;
        allGames.push(newGame);
    }