# Transaction Module

Transaction module handles blockchain transaction operations and queries.

To learn more about how to use the AI Agent SDK to interact with the transaction module, please visit [AI Agent SDK Transaction Queries](/crypto.com-ai-agent-sdk/core-concepts-overview/blockchain-functions/transaction-queries.md).

#### 3.1 Get Transaction By Hash

Fetches a transaction by hash.

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

```python
get_transaction_by_hash
```

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

* Arguments

  ```python
  hash (str): The hash of the transaction.
  ```
* Example Code

  ```python
  from crypto_com_developer_platform_client import Transaction

  tx = Transaction.get_transaction_by_hash('example-hash')
  print(tx)
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```python
  The transaction details.
  ```
* Errors

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

  ```python
  {'status': 'Success', 'data': {'transaction': {'_type': 'TransactionResponse', 'accessList': example-list, 'blockNumber': example-block-number, 'blockHash': 'example-hash', 'blobVersionedHashes': example-hashes, 'chainId': 'example-chain0id', 'data': 'example-data', 'from': 'example-from', 'gasLimit': 'example-gas-limit', 'gasPrice': 'example-gas-price', 'hash': 'example-hash', 'maxFeePerGas': 'example-fee', 'maxPriorityFeePerGas': 'example-fee', 'maxFeePerBlobGas': example-fee, 'nonce': example-nonce, 'signature': {'_type': 'signature', 'networkV': 'example-V', 'r': 'example-r', 's': 'example-s', 'v': example-v}, 'to': 'example-to', 'index': example-index, 'type': example-type, 'value': 'example-value'}}}
  ```

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

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

```typescript
getTransactionByHash
```

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

* Arguments

  ```typescript
  {string} txHash: Transaction hash.
  ```
* Example Code

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

  const tx = await Transaction.getTransactionByHash('example-hash');
  console.log(tx);
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```typescript
  {Promise<ApiResponse<TransactionByHash>>}: A promise that resolves to the transaction result
  ```
* Example Return

  ```typescript
  {
    status: 'Success',
    data: {
      transaction: {
        _type: 'TransactionResponse',
        accessList: example-list,
        blockNumber: example-block-number,
        blockHash: 'example-hash',
        blobVersionedHashes: example-hashes,
        chainId: 'example-chain-id',
        data: 'example-data',
        from: 'example-from',
        gasLimit: 'example-gas-limit',
        gasPrice: 'example-gas-price',
        hash: 'example-hash',
        maxFeePerGas: 'example-fee',
        maxPriorityFeePerGas: 'example-fee',
        maxFeePerBlobGas: example-fee,
        nonce: example-nonce,
        signature: [example-singature],
        to: 'example-to',
        index: example-index,
        type: example-type,
        value: 'example-value'
      }
    }
  }
  ```

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

#### 3.2 Get Transaction Status

Fetches transaction status by hash.

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

```python
get_transaction_status
```

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

* Arguments

  ```python
  hash (str): The hash of the transaction.
  ```
* Example Code

  ```python
  from crypto_com_developer_platform_client import Transaction

  status = Transaction.get_transaction_status('example-hash')
  print(status)
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```python
  The transaction status.
  ```
* Errors

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

  ```python
  {'status': 'Success', 'data': {'status': 1}}
  ```

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

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

```typescript
getTransactionStatus
```

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

* Arguments

  ```typescript
  {string} txHash: Transaction hash.
  ```
* Example Code

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

  const status = await Transaction.getTransactionStatus('example-hash');
  console.log(status);
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```typescript
  Promise<ApiResponse<TransactionStatus>>}: A promise that resolves to the transaction status.
  ```
* Example Return

  ```typescript
  { status: 'Success', data: { status: 1 } }
  ```

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

#### 3.3 Get Transaction Count

Fetches transaction count for a wallet.

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

```python
get_transaction_count
```

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

* Arguments

  ```python
  wallet_address (str): The address to get the transaction count for.
  ```
* Example Code

  ```python
  from crypto_com_developer_platform_client import Transaction

  count = Transaction.get_transaction_count('example-wallet')
  print(count)
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```python
  The transaction count for the wallet address.
  ```
* Errors

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

  ```python
  {'status': 'Success', 'data': {'count': example-count}}
  ```

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

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

```typescript
getTransactionCount
```

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

* Arguments

  ```typescript
  {string} walletAddress: Wallet address.
  ```
* Example Code

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

  const count = await Transaction.getTransactionCount('example-address');
  console.log(count);
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```typescript
  {Promise<ApiResponse<TransactionCount>>}: A promise that resolves to the transaction count.
  ```
* Example Return

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

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

#### 3.4 Get Gas Price

Fetches current gas price.

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

```python
get_gas_price
```

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

* Example Code

  ```python
  from crypto_com_developer_platform_client import Transaction

  price = Transaction.get_gas_price()
  print(price)
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```python
  The current gas price.
  ```
* Errors

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

  ```python
  {'status': 'Success', 'data': {'gasPrice': 'example-gas-price'}}
  ```

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

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

```typescript
getGasPrice
```

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

* Example Code

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

  const gasPrice = await Transaction.getGasPrice();
  console.log(gasPrice);
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```typescript
  {Promise<ApiResponse<GasPrice>>}: A promise that resolves to the gas price.
  ```
* Example Return

  ```typescript
  { status: 'Success', data: { gasPrice: 'example-gas-price' } }
  ```

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

#### 3.5 Get Fee Data

Fetches current fee data.

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

```python
get_fee_data
```

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

* Example Code

  ```python
  from crypto_com_developer_platform_client import Transaction

  data = Transaction.get_fee_data()
  print(data)
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```python
  The current fee data.
  ```
* Errors

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

  ```python
  {'status': 'Success', 'data': {'feeData': {'_type': 'FeeData', 'gasPrice': 'example-gas-price', 'maxFeePerGas': 'example-fee', 'maxPriorityFeePerGas': 'example-fee'}}}
  ```

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

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

```typescript
getFeeData
```

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

* Example Code

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

  const feeData = await Transaction.getFeeData();
  console.log(feeData);
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```typescript
  {Promise<ApiResponse<FeeData>>}: A promise that resolves to the fee data.
  ```
* Example Return

  ```typescript
  {
    status: 'Success',
    data: {
      feeData: {
        _type: 'FeeData',
        gasPrice: 'example-gas-price',
        maxFeePerGas: 'example-fee',
        maxPriorityFeePerGas: 'example-fee'
      }
    }
  }
  ```

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

#### 3.6 Estimate Gas

Estimates gas for a transaction.

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

```python
estimate_gas
```

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

* Arguments

  ```python
  payload (dict): The payload for gas estimation, including fields like `from`, `to`, `value`, `gasLimit`, `gasPrice`, `data`.
  ```
* Example Code

  ```python
  from crypto_com_developer_platform_client import Transaction

  gas = Transaction.estimate_gas({'from': 'example-from', 'to': 'example-to', 'value': 'example-value', 'gasLimit': 'example-gas-limit', 'gasPrice': 'example-gas-price', 'data': 'example-data'})
  print(gas)
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```python
  The estimated gas information.
  ```
* Errors

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

  ```python
  {'status': 'Success', 'data': {'gasLimit': 'example-gas-limit'}}
  ```

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

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

```typescript
estimateGas
```

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

* Arguments

  ```typescript
  {object} payload: Transaction payload (from, to, value, gasLimit, gasPrice, data).
  ```
* Example Code

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

  const estimation = await Transaction.estimateGas({from: 'example-from', to: 'example-to', value: 'example-value', gasLimit: 'example-gas-limit', gasPrice: 'example-gas-price', data: 'example-data'});
  console.log(estimation);
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```typescript
  {Promise<ApiResponse<EstimateGasData>>}: A promise that resolves to the estimate gas data.
  ```
* Example Return

  ```typescript
  { status: 'Success', data: { gasLimit: 'example-gas-limit' } }
  ```

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


---

# 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-developer-platform/on-chain-developer-platform-client-sdk/transaction-module.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.
