def get_data_from_script_hex(script: str) -> str:
    """Parses an OP_RETURN script (as hex string) and returns the data
    contained in it

    Parameters
    ----------
    script : str
        The OP_RETURN script as hex string

    Returns
    -------
    str
        Data included in the transaction as hex string

    Raises
    ------
    ValueError
        If script is not a valid OP_RETURN script
    """

    # NOTE: We parse from hex-field, not asm-field, because for small values
    # the asm is decoded as integer
    # Sanity check that hex is a OP_RETURN transaction:
    if len(script) < 6 or script[0:2] != "6a":
        raise ValueError("Argument is not valid OP_RETURN script")
    sec = int(script[2:4], 16)
    if sec > 76:
        # NOTE: This is only invalid if OP_RETURN values cannot exceed 256
        # bytes, else 77/78 could be valid
        raise ValueError("Argument is not valid OP_RETURN script")

    if sec == 76:
        # Size is encoded in next byte
        size = int(script[4:6], 16)
        data = script[6:]
    else:
        size = sec
        data = script[4:]

    if len(data) / 2 != size:
        raise ValueError(
            "Argument is not valid OP_RETURN script: Size mismatch")

    return data