# Block Information

The AI Agent SDK provides robust block operation capabilities, allowing developers to fetch blocks by tag (e.g., latest, pending) or by specific block number on Cronos Chains.

This feature makes it easy to retrieve detailed block information, enabling seamless integration of real-time blockchain data into your AI-powered applications.

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

#### 4.1 Get block by tag&#x20;

Retrieve block data for a specified tag using the Crypto.com developer platform.

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

* Arguments

  ```python
  tag (str): Integer of a block number in hex, or the string "earliest", "latest" 
  or "pending".
  tx_detail (str, optional): If "true", returns full transaction objects; 
  if "false", only transaction hashes.
  ```
* Example Query

  ```
  "Get <example-tag> block with detail"
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```python
  str: A formatted string containing the block data.
  ```
* Example Response

  ```
  The latest block data with details is as follows:

    Block Number: <example-block-number> 
    Block Hash: <example-block-hash>
    Parent Hash: <example-parent-hash>
    Timestamp: <example-timestamp>
    Transactions Root: <example-transaction-root>
    Receipts Root: <example-receipts-root>
    State Root: <example-state-root>
    Gas Limit: <example-gas-limit>
    Gas Used: <example-gas-used>
    Miner: <example-miner>
    Difficulty: <example-difficulty>
    Total Difficulty: <example-total-difficulty>
    Gas Price: <example-gas-price>
    Base Fee Per Gas: <example-base-fee-per-gase>
    Nonce: <example-nonce>
    Transactions:
      Transaction Hash: <example-transaction-hash>
      From: <example-from>
      To: <example-to>
      Value: <example-value>
      Gas: <example-gas>
      Transaction Index: <example-transaction-index>
      Max Fee Per Gas: <example-max-fee-per-gas>
      Max Priority Fee Per Gas: <example-max-priority-fee-per-gas>

  This block contains a single transaction and has not been mined by a specific miner. The details also indicate that the block has a gas limit of approximately <example-number> trillion and has utilized around <example-percentage> of that limit. If you need further information or specific details, please let me know!
  ```

{% 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 lastest block with detail")
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/block-information.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.
