> For the complete documentation index, see [llms.txt](https://ai-agent-sdk-docs.crypto.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ai-agent-sdk-docs.crypto.com/crypto.com-developer-platform/on-chain-developer-platform-client-sdk/block-module.md).

# Block Module

Block module for accessing blockchain block data.

To learn more about how to use the AI Agent SDK to interact with the wallet module, please visit [AI Agent SDK Block Information](/crypto.com-ai-agent-sdk/core-concepts-overview/blockchain-functions/block-information.md).

#### 4.1 Get Current Block

Get the current latest block.

{% tabs %}
{% tab title="Python" %}
Function Name

```python
get_current
```

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

* Example Code

  ```python
  from crypto_com_developer_platform_client import Block

  block = Block.get_current()
  print(block)
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```python
  The latest block data.
  ```
* Errors

  ```python
  ValueError: If the Block class is not initialized with a Client instance.
  ```
* Example Return

  ```python
  {'status': 'Success', 'data': {'blockNumber': example-block-number}}
  ```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="TypeScript" %}
Function Name

```typescript
getCurrentBlock
```

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

* Example Code

  ```typescript
  import { Block } from '@crypto.com/developer-platform-client';

  const block = await Block.getCurrentBlock();
  console.log(block);
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```typescript
  Promise<ApiResponse<BlockNumber>>: A promise that resolves to the current block data.
  ```
* Example Return

  ```typescript
  { status: 'Success', data: { blockNumber: example-number } }
  ```

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

#### 4.2 Get Block By Tag

Get a block by tag or block number.

{% tabs %}
{% tab title="Python" %}
Function Name

```python
get_by_tag
```

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

* Arguments

  ```python
  tag (str): Integer of a block number in hex, or the string "earliest", "latest" or "pending", as in https://ethereum.org/en/developers/docs/apis/json-rpc/#default-block
  tx_detail (str): If true it returns the full transaction objects, if false only the hashes of the transactions.
  ```
* Example Code

  ```python
  from crypto_com_developer_platform_client import Block

  block = Block.get_by_tag("latest", "true")
  print(block)
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```python
  The block data.
  ```
* Errors

  ```python
  ValueError: If the Block class is not initialized with a Client instance.
  ```
* Example Return

  ```python
  {'status': 'Success', 'data': {'block': {'_type': 'Block', 'baseFeePerGas': 'example-fee', 'difficulty': 'example-difficulty', 'extraData': 'example-data', 'gasLimit': 'example-gas-limit', 'gasUsed': 'example-gas-used', 'blobGasUsed': 'example-blob-gas-used', 'excessBlobGas': 'example-gas', 'hash': 'example-hash', 'miner': 'example-address', 'prevRandao': 'example-randao', 'nonce': 'example-nonce', 'number': example-number, 'parentHash': 'example-hash', 'timestamp': example-timestamp, 'parentBeaconBlockRoot': 'example-hash', 'stateRoot': 'example-hash', 'receiptsRoot': 'example-hash', 'transactions': ['example-transactions']}}}
  ```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="TypeScript" %}
Function Name

```typescript
getBlockByTag
```

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

* Arguments

  ```typescript
  (string} blockTag: Block identifier ('latest', 'pending', or block number in hex).
  {string} txDetail: Whether to include transaction details ('true' or 'false').
  ```
* Example Code

  ```typescript
  import { Block } from '@crypto.com/developer-platform-client';

  const block = await Block.getBlockByTag('latest', 'true');
  console.log(block);
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```typescript
  Promise<ApiResponse<BlockData>>: A promise that resolves to the block data.
  ```
* Example Return

  ```typescript
  {
    status: 'Success',
    data: {
      block: {
        _type: 'Block',
        baseFeePerGas: 'example-fee',
        difficulty: 'example-difficulty',
        extraData: 'example-data',
        gasLimit: 'example-gas-limit',
        gasUsed: 'example-gas-used',
        blobGasUsed: example-gas,
        excessBlobGas: example-gas,
        hash: 'example-hash',
        miner: 'example-hash',
        prevRandao: 'example-hash',
        nonce: 'example-nonce',
        number: example-number,
        parentHash: 'example-hash',
        timestamp: example-timestamp,
        parentBeaconBlockRoot: example-block-root,
        stateRoot: 'example-hash',
        receiptsRoot: 'example-hash',
        transactions: [example-transaction-array]
      }
    }
  }



  ```

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}
