# Challenge Snapshot

Retrieves the challenge snapshot data for a specific account. This snapshot contains metadata about the ongoing or most recent challenge for the miner, including various details such as challenge state, failure count, and other associated information.

***

## Function Definition

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

```

***

## Description

This asynchronous query retrieves the challenge snapshot for the given account. The snapshot provides critical information about the miner's current challenge, such as challenge status, the number of failed attempts, and other related data.

You can provide a block\_hash to query the state at a specific block or omit it to get the most recent state of the chain.

***

## Parameters

| Name         | Type           | Description                                                                                                                            |
| ------------ | -------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `account`    | `&str`         | A valid **SS58-encoded account** representing the miner or storage provider to query.                                                  |
| `block_hash` | `Option<H256>` | *(Optional)* Block hash for querying state at a specific point in the blockchain. If omitted, the query returns the most recent state. |

***

## Returns

| Type                      | Description                                                                                                                               |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `Ok(Some(ChallengeInfo))` | The challenge snapshot for the specified account. Contains metadata like challenge state, failure count, and other details.               |
| `Ok(None)`                | No challenge snapshot available for the account, meaning the miner is not currently involved in a challenge or there is no relevant data. |
| `Err(Error)`              | If the query fails due to invalid data, connectivity issues, or other errors.                                                             |

***

## Example

```rust
use cess_rust_sdk::chain::audit::query::StorageQuery as AuditQuery;

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

    let result = AuditQuery::challenge_snapshot(account, None).await?;

    match result {
        Some(snapshot) => {
            println!("Challenge Snapshot for account {}: {:?}", account, snapshot);
        },
        None => {
            println!("No challenge snapshot 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/challenge_snapshot.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.
