# Counted Service Failed

Retrieves the total number of **service failures** recorded for a specific account on the CESS chain.\
This query is part of the **Audit pallet** and helps determine how often a storage miner has failed service verification tasks.

***

## Function Definition

```rust
pub async fn counted_service_failed(
    account: &str,
    block_hash: Option<H256>,
) -> Result<Option<u32>, Error>
```

***

## Description

This asynchronous method queries the CESS blockchain for the count of failed service challenges associated with a specific account. Optionally, a block\_hash can be provided to inspect the state of the chain at a particular block height.

***

### Parameters

| Name        | Type   | Description                                                                                    |
| ----------- | ------ | ---------------------------------------------------------------------------------------------- |
| account     | \&str  | A valid SS58-encoded account representing the miner or user to query.                          |
| block\_hash | Option | (Optional) Block hash used to query historical state. If omitted, the latest state is queried. |

***

### Returns

| Type          | Description                                                            |
| ------------- | ---------------------------------------------------------------------- |
| Ok(Some(u32)) | Returns the number of recorded service failures for the given account. |
| Ok(None)      | No record of service failures exists for the account.                  |
| Err(Error)    | The query failed due to invalid parameters or connection issues.       |

## Example

```rust
#[cfg(test)]
use cess_rust_sdk::chain::audit::query::StorageQuery;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let account = "cXgaee2N8E77JJv9gdsGAckv1Qsf3hqWYf7NL4q6ZuQzuAUtB";

    let result = StorageQuery::counted_service_failed(account, None).await?;

    match result {
        Some(count) => println!("Account {} has {} service failures.", account, count),
        None => println!("No service failure record found for account {}.", account),
    }

    Ok(())
}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.cess.network/developer/cess-sdk/sdk-rust/chain/audit/counted_service_failed.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
