lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.24
/**
 * @dev Transfers tokens from a specific address [ERC20].
 * The address owner has to approve the spender beforehand.
 * @param db Token storage to operate on.
 * @param caller Address of the caller passed through the frontend.
 * @param from Address to debet the tokens from.
 * @param to Recipient address.
 * @param amount Number of tokens to transfer.
 */
function transferFrom(
        TokenStorage db,
        address caller,
        address from,
        address to,
        uint amount
    )
        external
        returns (bool success)
    {
        uint allowance = db.getAllowed(from, caller);
        db.subBalance(from, amount);
        db.addBalance(to, amount);
        db.setAllowed(from, caller, allowance.sub(amount));
        return true;
    }
// Solidity 0.4.24
/**
 * @dev Transfers tokens and subsequently calls a method on the recipient [ERC677].
 * If the recipient is a non-contract address this method behaves just like transfer.
 * @notice db.transfer either returns true or reverts.
 * @param db Token storage to operate on.
 * @param caller Address of the caller passed through the frontend.
 * @param to Recipient address.
 * @param amount Number of tokens to transfer.
 * @param data Additional data passed to the recipient's tokenFallback method.
 */
function transferAndCall(
        TokenStorage db,
        address caller,
        address to,
        uint256 amount,
        bytes data
    )
        external
        returns (bool)
    {
        require(
            db.transfer(caller, to, amount), 
            "unable to transfer"
        );
        if (to.isContract()) {
            IERC677Recipient recipient = IERC677Recipient(to);
            require(
                recipient.onTokenTransfer(caller, amount, data),
                "token handler returns false"
            );
        }
        return true;
    }
// Solidity 0.4.24
/**
 * @dev Recovers tokens from an address and reissues them to another address.
 * In case a user loses its private key the tokens can be recovered by burning
 * the tokens from that address and reissuing to a new address.
 * To recover tokens the contract owner needs to provide a signature
 * proving that the token owner has authorized the owner to do so.
 * @param from Address to burn tokens from.
 * @param to Address to mint tokens to.
 * @param h Hash which the token owner signed.
 * @param v Signature component.
 * @param r Signature component.
 * @param s Sigature component.
 * @return Amount recovered.
 */
function recover(
        TokenStorage token,
        address from,
        address to,
        bytes32 h,
        uint8 v,
        bytes32 r,
        bytes32 s
    )
        external
        returns (uint)
    {
        require(
            ecrecover(h, v, r, s) == from,
            "signature/hash does not recover from address"
        );
        uint amount = token.balanceOf(from);
        token.burn(from, amount);
        token.mint(to, amount);
        emit Recovered(from, to, amount);
        return amount;
    }
// Solidity 0.4.24
/**
 * @dev Prevents tokens to be sent to well known blackholes by throwing on known blackholes.
 * @param to The address of the intended recipient.
 */
function avoidBlackholes(address to) internal view {
        require(to != 0x0, "must not send to 0x0");
        require(to != address(this), "must not send to controller");
        require(to != address(token), "must not send to token storage");
        require(to != frontend, "must not send to frontend");
    }
// Solidity 0.5.13
/**
 * @dev initialize
 * @param _avatar the avatar to mint reputation from
 * @param _tokenContract the token contract
 * @param _agreementHash is a hash of agreement required to be added to the TX by participants
 */
function initialize(Avatar _avatar, IERC20 _tokenContract, CurveInterface _curve, bytes32 _agreementHash) external
    {
        require(avatar == Avatar(0), "can be called only one time");
        require(_avatar != Avatar(0), "avatar cannot be zero");
        tokenContract = _tokenContract;
        avatar = _avatar;
        curve = _curve;
        super.setAgreementHash(_agreementHash);
    }
// Solidity 0.5.13
/**
 * @dev redeemWithSignature function
 * @param _beneficiary the beneficiary address to redeem for
 * @param _signatureType signature type
 1 - for web3.eth.sign
 2 - for eth_signTypedData according to EIP #712.
 * @param _signature  - signed data by the staker
 * @return uint256 minted reputation
 */
function redeemWithSignature(
        address _beneficiary,
        bytes32 _agreementHash,
        uint256 _signatureType,
        bytes calldata _signature
        )
        external
        returns(uint256)
        {
        // Recreate the digest the user signed
        bytes32 delegationDigest;
        if (_signatureType == 2) {
            delegationDigest = keccak256(
                abi.encodePacked(
                    DELEGATION_HASH_EIP712, keccak256(
                        abi.encodePacked(
                        address(this),
                        _beneficiary,
                        _agreementHash)
                    )
                )
            );
        } else {
            delegationDigest = keccak256(
                        abi.encodePacked(
                        address(this),
                        _beneficiary,
                        _agreementHash)
                    ).toEthSignedMessageHash();
        }
        address redeemer = delegationDigest.recover(_signature);
        require(redeemer != address(0), "redeemer address cannot be 0");
        return _redeem(_beneficiary, redeemer, _agreementHash);
    }
// Solidity 0.5.13
/**
 * @dev redeem function
 * @param _beneficiary the beneficiary address to redeem for
 * @param _redeemer the redeemer address
 * @return uint256 minted reputation
 */
function _redeem(address _beneficiary, address _redeemer, bytes32 _agreementHash)
    private
    onlyAgree(_agreementHash)
    returns(uint256) {
        require(avatar != Avatar(0), "should initialize first");
        require(redeems[_redeemer] == false, "redeeming twice from the same account is not allowed");
        redeems[_redeemer] = true;
        uint256 tokenAmount = tokenContract.balanceOf(_redeemer);
        if (curve != CurveInterface(0)) {
            tokenAmount = curve.calc(tokenAmount);
        }
        if (_beneficiary == address(0)) {
            _beneficiary = _redeemer;
        }
        require(
        Controller(
        avatar.owner())
        .mintReputation(tokenAmount, _beneficiary, address(avatar)), "mint reputation should succeed");
        emit Redeem(_beneficiary, _redeemer, tokenAmount);
        return tokenAmount;
    }
// Solidity 0.4.24
/**
 * @dev Sets a new controller.
 * @param address_ Address of the controller.
 */
function setController(address address_) external onlyOwner {
        require(address_ != 0x0, "controller address cannot be the null address");
        emit Controller(ticker, controller, address_);
        controller = SmartController(address_);
        require(controller.getFrontend() == address(this), "controller frontend does not point back");
        require(controller.ticker() == ticker, "ticker does not match controller ticket");
    }
// Solidity 0.4.24
/**
 * @dev Burns tokens from token owner.
 * This removfes the burned tokens from circulation.
 * @param from Address of the token owner.
 * @param amount Number of tokens to burn.
 * @param h Hash which the token owner signed.
 * @param v Signature component.
 * @param r Signature component.
 * @param s Sigature component.
 */
function burnFrom(address from, uint amount, bytes32 h, uint8 v, bytes32 r, bytes32 s)
        external
        returns (bool ok)
    {
        ok = controller.burnFrom_withCaller(msg.sender, from, amount, h, v, r, s);
        emit Transfer(from, 0x0, amount);
    }
// Solidity 0.8.4
/**
 * @dev Converts a digit from 0 - 10000 into its corresponding rarity based on the given rarity tier.
 * @param _randinput The input from 0 - 10000 to use for rarity gen.
 * @param _rarityTier The tier to use.
 */
function rarityGen(uint256 _randinput, uint8 _rarityTier)
        internal
        view
        returns (string memory)
    {
        uint16 currentLowerBound = 0;
        for (uint8 i = 0; i < TIERS[_rarityTier].length; i++) {
            uint16 thisPercentage = TIERS[_rarityTier][i];
            if (
                _randinput >= currentLowerBound &&
                _randinput < currentLowerBound + thisPercentage
            ) return i.toString();
            currentLowerBound = currentLowerBound + thisPercentage;
        }

        revert();
    }
// Solidity 0.8.4
/**
 * @dev Generates a 9 digit hash from a tokenId, address, and random number.
 * @param _t The token id to be used within the hash.
 * @param _a The address to be used within the hash.
 * @param _c The custom nonce to be used within the hash.
 */
function hash(
        uint256 _t,
        address _a,
        uint256 _c
    ) internal returns (string memory) {
        require(_c < 10);

        // This will generate a 9 character string.
        //The last 8 digits are random, the first is 0, due to the mouse not being burned.
        string memory currentHash = "0";

        for (uint8 i = 0; i < 8; i++) {
            SEED_NONCE++;
            uint16 _randinput = uint16(
                uint256(
                    keccak256(
                        abi.encodePacked(
                            block.timestamp,
                            block.difficulty,
                            _t,
                            _a,
                            _c,
                            SEED_NONCE
                        )
                    )
                ) % 10000
            );

            currentHash = string(
                abi.encodePacked(currentHash, rarityGen(_randinput, i))
            );
        }

        if (hashToMinted[currentHash]) return hash(_t, _a, _c + 1);

        return currentHash;
    }
// Solidity 0.8.4
/**
 * @dev Returns the current cost of minting.
 */
function currentTokenCost() public view returns (uint256) {
        uint256 _totalSupply = totalSupply();

        if (_totalSupply <= 2000) return 1000000000000000000;
        if (_totalSupply > 2000 && _totalSupply <= 4000)
            return 1000000000000000000;
        if (_totalSupply > 4000 && _totalSupply <= 6000)
            return 2000000000000000000;
        if (_totalSupply > 6000 && _totalSupply <= 8000)
            return 3000000000000000000;
        if (_totalSupply > 8000 && _totalSupply <= 10000)
            return 4000000000000000000;

        revert();
    }
// Solidity 0.8.4
/**
 * @dev Returns the current ETH price to mint
 */
function currentPrice() public view returns (uint256) {
        if(block.timestamp < MINT_START) {
            return START_PRICE;
        }

        uint256 _mintTiersComplete = (block.timestamp - MINT_START).div(MINT_DELAY);
        if(PRICE_DIFF * _mintTiersComplete >= START_PRICE) {
            return 0;
        } else {
            return START_PRICE - (PRICE_DIFF * _mintTiersComplete);
        }
    }
// Solidity 0.8.4
/**
 * @dev Mints new tokens.
 */
function mintNfToken(uint256 _times) public payable {
        uint256 _totalSupply = totalSupply();
        uint256 _price = currentPrice();
        require((_times > 0 && _times <= 5));
        require(msg.value >= _times * _price);
        require(_totalSupply < MINTS_PER_TIER);
        require(block.timestamp >= MINT_START);
        
        for(uint256 i=0; i< _times; i++){
            mintInternal();
        }
    }
// Solidity 0.8.4
/**
 * @dev Returns the SVG and metadata for a token Id
 * @param _tokenId The tokenId to return the SVG and metadata for.
 */
function tokenURI(uint256 _tokenId)
        public
        view
        override
        returns (string memory)
    {
        require(_exists(_tokenId));

        string memory tokenHash = _tokenIdToHash(_tokenId);

        return
            string(
                abi.encodePacked(
                    "data:application/json;base64,",
                    Library.encode(
                        bytes(
                            string(
                                abi.encodePacked(
                                    '{"name": "NfToken #',
                                    Library.toString(_tokenId),
                                    '", "description": "This is a collection of 10,000 unique images. All the metadata and images are generated and stored 100% on-chain. No IPFS, no API.", "image": "data:image/svg+xml;base64,',
                                    Library.encode(
                                        bytes(hashToSVG(tokenHash))
                                    ),
                                    '","attributes":',
                                    hashToMetadata(tokenHash),
                                    "}"
                                )
                            )
                        )
                    )
                )
            );
    }
// Solidity 0.8.4
/**
 * @dev Returns a hash for a given tokenId
 * @param _tokenId The tokenId to return the hash for.
 */
function _tokenIdToHash(uint256 _tokenId)
        public
        view
        returns (string memory)
    {
        string memory tokenHash = tokenIdToHash[_tokenId];
        //If this is a burned token, override the previous hash
        if (ownerOf(_tokenId) == 0x000000000000000000000000000000000000dEaD) {
            tokenHash = string(
                abi.encodePacked(
                    "1",
                    Library.substring(tokenHash, 1, 9)
                )
            );
        }

        return tokenHash;
    }
// Solidity 0.8.4
/**
 * @dev Returns the wallet of a given wallet. Mainly for ease for frontend devs.
 * @param _wallet The wallet to get the tokens of.
 */
function walletOfOwner(address _wallet)
        public
        view
        returns (uint256[] memory)
    {
        uint256 tokenCount = balanceOf(_wallet);

        uint256[] memory tokensId = new uint256[](tokenCount);
        for (uint256 i; i < tokenCount; i++) {
            tokensId[i] = tokenOfOwnerByIndex(_wallet, i);
        }
        return tokensId;
    }
// Solidity 0.4.18
/// @notice The `escapeHatch()` should only be called as a last resort if a
/// security issue is uncovered or something unexpected happened
/// @param _token to transfer, use 0x0 for ether
function escapeHatch(address _token) public onlyEscapeHatchCallerOrOwner {   
        require(escapeBlacklist[_token]==false);

        uint256 balance;

        /// @dev Logic for ether
        if (_token == 0x0) {
            balance = this.balance;
            escapeHatchDestination.transfer(balance);
            EscapeHatchCalled(_token, balance);
            return;
        }
        /// @dev Logic for tokens
        ERC20 token = ERC20(_token);
        balance = token.balanceOf(this);
        token.transfer(escapeHatchDestination, balance);
        EscapeHatchCalled(_token, balance);
    }
// Solidity 0.5.0
// set a token upgrader
function setTokenUpgrader(address _newToken)
        external
        onlyUpgradeMaster
        notInUpgradingState
    {
        require(canUpgrade());
        require(_newToken != address(0));

        tokenUpgrader = TokenUpgrader(_newToken);

        // Handle bad interface
        require(tokenUpgrader.isTokenUpgrader());

        // Make sure that token supplies match in source and target
        require(tokenUpgrader.originalSupply() == totalSupply());

        emit TokenUpgraderIsSet(address(tokenUpgrader));
    }
// Solidity 0.6.12
// Deposits underlying assets from the user into the vault contract
function deposit(uint256 _amount) public nonReentrant {
        require(!address(msg.sender).isContract() && msg.sender == tx.origin, "deposit: !contract");
        require(isActive, 'deposit: !vault');
        require(strategy != address(0), 'deposit: !strategy');
        
        uint256 _pool = balance();
        uint256 _before = token.balanceOf(address(this));
        token.safeTransferFrom(msg.sender, address(this), _amount);
        uint256 _after = token.balanceOf(address(this));
        _amount = _after.sub(_before); // Additional check for deflationary tokens
        deposits[msg.sender] = deposits[msg.sender].add(_amount);
        totalDeposited = totalDeposited.add(_amount);
        uint256 shares = 0;
        if (totalSupply() == 0) {
            uint256 userMultiplier = tiers[msg.sender].mul(tierMultiplier).add(tierBase); // 5 %, 10 %, 15 %, 20 %, 25 %
            shares = _amount.mul(userMultiplier).div(tierBase);
        } else {
            uint256 userMultiplier = tiers[msg.sender].mul(tierMultiplier).add(tierBase); // 5 %, 10 %, 15 %, 20 %, 25 %
            shares = (_amount.mul(userMultiplier).div(tierBase).mul(totalSupply())).div(_pool);
        }

        _mint(msg.sender, shares);
        issued[msg.sender] = issued[msg.sender].add(shares);
        depositBlocks[msg.sender] = block.number;
        emit Deposit(msg.sender, _amount);
        emit SharesIssued(msg.sender, shares);
    }
// Solidity 0.6.12
// Purchase a multiplier tier for the user
function purchaseMultiplier(uint256 _tiers) external returns (uint256 newTier) {
        require(isActive, '!active');
        require(strategy != address(0), '!strategy');
        require(_tiers > 0, '!tiers');
        uint256 multipliersLength = multiplierCosts.length;
        require(tiers[msg.sender].add(_tiers) <= multipliersLength, '!max');

        uint256 totalCost = 0;
        uint256 lastMultiplier = tiers[msg.sender].add(_tiers);
        for (uint256 i = tiers[msg.sender]; i < multipliersLength; i++) {
            if (i == lastMultiplier) {
                break;
            }
            totalCost = totalCost.add(multiplierCosts[i]);
        }

        require(IERC20(yvs).balanceOf(msg.sender) >= totalCost, '!yvs');
        yvs.safeTransferFrom(msg.sender, address(this), totalCost);
        newTier = tiers[msg.sender].add(_tiers);
        tiers[msg.sender] = newTier;
        emit MultiplierPurchased(msg.sender, _tiers, totalCost);
    }
// Solidity 0.4.19
// only for burn after sale
function burnaftersale(uint256 _value) public {
    require(_value <= balances[msg.sender]);
    // no need to require value <= totalSupply, since that would imply the
    // sender's balance is greater than the totalSupply, which *should* be an assertion failure
    address burner = msg.sender;
    balances[burner] = balances[burner].sub(_value);
    totalSupply = totalSupply.sub(_value);
    burnedAfterSaleCount = burnedAfterSaleCount.add(_value);
    Burn(burner, _value);
    }
// Solidity 0.4.18
/**
 * @dev The Ownable constructor sets the original `owner` of the contract to the sender
 * account.
 */
function Ownable() {
    /**
    * ownerManualMinter contains the eth address of the party allowed to manually mint outside the crowdsale contract
    * this is setup at construction time 
    */ 

    ownerManualMinter = 0x163dE8a97f6B338bb498145536d1178e1A42AF85 ; // To be changed right after contract is deployed
    owner = msg.sender;
  }
// Solidity 0.8.2
// ERC721 gas limits how much fun we can have
// mint (almost) any number junks
function fuck(uint _numFucks) public payable {
        // NOTE: DON'T use totalSupply() because they are BURNABLE
        require(
            areWeFucking == true,
            "TOO EARLY. sale hasn't started."
        );
        require(
            _tokenIdTracker.current() < ARBITRARY_QUANTITY,
            "TOO LATE. all junks have been sold."
        );
        require(
            _tokenIdTracker.current()+_numFucks < ARBITRARY_QUANTITY,
            "TOO MANY. there aren't this many junks left."
        );
        require(
            msg.value >= howMuchBondage(_numFucks),
            "TOO LITTLE. pls send moar eth."
        );

        gasm(_numFucks);
    }
// Solidity 0.8.2
// calculate how much the cost for a number of junks, across the bondage curve
function howMuchBondage(uint _hits) public view returns (uint) {        
        require(
            _tokenIdTracker.current()+_hits < ARBITRARY_QUANTITY,
            "TOO MANY. there aren't this many junks left."
        );

        uint _cost;
        uint _index;

        for (_index; _index < _hits; _index++) {
            uint currTokenId = _tokenIdTracker.current();
            _cost += howMuchForAHit(currTokenId + _index);
        }

        return _cost;
    }
// Solidity 0.8.2
// lists the junks owned by the address
function exposeJunk(address _owner) external view returns(uint[] memory) {
        uint junks = balanceOf(_owner);
        if (junks == 0) {
            return new uint[](0);
        } else {
            uint[] memory result = new uint[](junks);
            for (uint i = 0; i < junks; i++) {
                result[i] = tokenOfOwnerByIndex(_owner, i);
            }
            return result;
        }
    }
// Solidity 0.8.2
// special, reserved for devs
function wank(uint _numWanks) public onlyOwner {
        require(
            areWeFucking == false,
            "TOO LATE. this should happen first."
        );
        
        // how many we're keeping
        uint maxWanks = ARBITRARY_QUANTITY - SEXY*25 - MEME*4 - MUCH*6; // 595
        uint latestId = _tokenIdTracker.current();

        require(
            latestId < maxWanks,
            "TOO LATE. all the dev mints are minted."
        );

        // limit the number for minting
        uint toWank;
        if (_numWanks < ARBITRARY_LIMIT) {
            toWank = _numWanks;
        } else {
            toWank = ARBITRARY_LIMIT;
        }

        // mint the max number if possible
        if (latestId+toWank < maxWanks) {
            gasm(toWank);
        } else {
            uint wanksLeft = maxWanks - latestId;
            // else mint as many as possible
            gasm(wanksLeft);
        }
    }
// Solidity 0.5.17
// Send additional tokens for new rate + Update rate for individual tokens 
function updateRewardAmount(address stakingToken, uint256 newRate) public onlyOwner {
        require(block.timestamp >= stakingRewardsGenesis, 'StakingRewardsFactory::notifyRewardAmount: not ready');

        StakingRewardsInfo storage info = stakingRewardsInfoByStakingToken[stakingToken];
        require(info.stakingRewards != address(0), 'StakingRewardsFactory::notifyRewardAmount: not deployed');

        if (info.rewardAmount > 0) {
            uint256 rewardAmount = info.rewardAmount.add(newRate);
            info.rewardAmount = 0;
            require(
                IERC20(rewardsToken).transfer(info.stakingRewards, newRate),
                'StakingRewardsFactory::notifyRewardAmount: transfer failed'
            );
            
            StakingRewards(info.stakingRewards).updateRewardAmount(rewardAmount);
        }
    }
// Solidity 0.6.12
/**
 * @notice Lets the manager create a wallet for an owner account.
 * The wallet is initialised with the version manager module, a version number and a first guardian.
 * The wallet is created using the CREATE opcode.
 * @param _owner The account address.
 * @param _versionManager The version manager module
 * @param _guardian The guardian address.
 * @param _version The version of the feature bundle.
 */
function createWallet(
        address _owner,
        address _versionManager,
        address _guardian,
        uint256 _version
    )
        external
        onlyManager
    {
        validateInputs(_owner, _versionManager, _guardian, _version);
        Proxy proxy = new Proxy(walletImplementation);
        address payable wallet = address(proxy);
        configureWallet(BaseWallet(wallet), _owner, _versionManager, _guardian, _version);
    }