# Transaction Queries

The AI Agent SDK enables efficient transaction management on Cronos Chains by providing features for querying transactions by address or hash. It also supports fetching transaction statuses, making it easy to track and verify blockchain activities accurately.

This functionality allows developers to build AI agents capable of monitoring and analyzing transactions in real-time, enhancing their applications' reliability and responsiveness.

To learn more about the underlying Developer Platform functionalities, please visit [Developer Platform Client SDK Transaction Module](/crypto.com-developer-platform/on-chain-developer-platform-client-sdk/transaction-module.md).

#### 3.1 Get transaction by hash

Retrieve transaction details for the specified hash using the Crypto.com developer platform.

{% tabs %}
{% tab title="Query" %}

* Arguments

  ```python
  hash (str): The hash of the transaction to retrieve.
  ```
* Example Query

  ```
  "Get transaction of transaction hash <example-hash>"
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```python
  str: A formatted string containing the transaction details.
  ```
* Example Response

  ```
  The transaction details for the hash <example-hash> are as follows:

      Status: <example-status>
      Block Number: <example-block-number>
      From Address: <example-from>
      To Address: <example-to>
      Value: <example-value>
      Gas Price: <example-gas-price>
      Nonce: <example-nonce>
      Transaction Index: <example-transaction-index>  
      Gas Used: <example-gas-used>
  ```

{% endtab %}
{% endtabs %}

Example Code

```python
from crypto_com_agent_client import Agent

agent = Agent.init(
    llm_config={
        "provider": "OpenAI",
        "model": "gpt-4",
        "provider-api-key": "sk-proj-example-key",
        "temperature": "float-controlling-output-randomness",
        "transfer-limit": -1,  # -1 means no limit (unlimited), 0 disables transfers completely, any positive number (e.g. 5) allows exactly that transfer amount
    },
    blockchain_config={
        "api-key": "your-crypto.com-developer-platform-api-key",
        "private-key": "your-private-key",
        "sso-wallet-url": "your-sso-wallet-url",
        "timeout": "timeout-in-seconds-for-API-calls-default-20s")
    },
)
response = agent.interact("Get transaction of transaction hash <example-hash>")
print(response)
```

#### 3.2 Get transaction status

Retrieve the status of a transaction using its hash using the Crypto.com developer platform.

{% tabs %}
{% tab title="Query" %}

* Arguments

  ```python
  hash (str): The hash of the transaction to check.
  ```
* Example Query

  ```
  "Get transaction status of <example-transation-hash>"
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```python
  str: A formatted string containing the transaction status.
  ```
* Example Response

  ```
  The transaction status for the hash <example-transation-hash> is <example-result>.
  ```

{% endtab %}
{% endtabs %}

Example Code

```python
from crypto_com_agent_client import Agent

agent = Agent.init(
    llm_config={
        "provider": "OpenAI",
        "model": "gpt-4",
        "provider-api-key": "sk-proj-example-key",
        "temperature": "float-controlling-output-randomness",
        "transfer-limit": -1,  # -1 means no limit (unlimited), 0 disables transfers completely, any positive number (e.g. 5) allows exactly that transfer amount
    },
    blockchain_config={
        "api-key": "your-crypto.com-developer-platform-api-key",
        "private-key": "your-private-key",
        "sso-wallet-url": "your-sso-wallet-url",
        "timeout": "timeout-in-seconds-for-API-calls-default-20s")
    },
)
response = agent.interact("Get transaction status of <example-transation-hash>")
print(response)
```


---

# 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://ai-agent-sdk-docs.crypto.com/crypto.com-ai-agent-sdk/core-concepts-overview/blockchain-functions/transaction-queries.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.
