# Functions and Example Queries of AI agent services

### Introduction

This page provides detailed information on various on-chain functions and example queries available through the Crypto.com AI Agent SDK. Each function is accompanied by a sample query and explanation of the response format, offering developers guidance on how to interact with Cronos Chains using the AI agent services.

### 1. Transfer native token

Sends a transaction from one address to another.

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

* Example Query&#x20;

```
query: "Send 1 ZKCRO to 0xRecipientAddress"
```

**Function Name**: `SendTransaction`

* **Function Argument**:

  ```json
  {
    "to": "0xRecipientAddress",
    "amount": 1,
    "symbol": "ZKCRO"
  }
  ```

{% endtab %}

{% tab title="Response" %}

```json
{
  "status": "Success",
  "action": "SendTransaction",
  "message": "Signature url created successfully. Please sign the transaction on this link",
  "data": {
    "magicLink": "https://{provider}/sign-transaction/{transactionId}?token={token}"
  }
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
This function returns a magic link. [Read more about Magic Link](https://ai-agent-sdk-docs.crypto.com/crypto.com-ai-agent-sdk/ai-agent-sdk-examples/magic-link-signer).
{% endhint %}

### 2.  Obtain on-chain balance

Fetches the balance of multiple wallet addresses.

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

* Example Query&#x20;

```
query: "Get balance for 0xWalletAddress1 and 0xWalletAddress2"
```

**Function Name**: `GetBalance`

* **Function Argument**:

  ```json
  {
    "walletAddresses": ["0xWalletAddress1", "0xWalletAddress2"]
  }
  ```

{% endtab %}

{% tab title="Response" %}

```json
{
  "status": "Success",
  "action": "GetBalance",
  "message": "Balances: 0xAddress: 0.5 ETH",
  "data": {
    "balances": [
      {
        "address": "0xAddress",
        "balanceWei": "500000000000000000",
        "balanceEth": "0.5",
        "balanceVUsd": "1000"
      }
    ]
  }
}
```

{% endtab %}
{% endtabs %}

### 3. **Get Latest Block**

Fetches the latest block information.

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

* Example Query&#x20;

```
query: "Get latest block height"
```

**Function Name**: `GetLatestBlock`

* **Function Argument**:

  ```json
  {}
  ```

{% endtab %}

{% tab title="Response" %}

```json
{
  "status": "Success",
  "action": "GetLatestBlock",
  "message": "Latest block height: 123456",
  "data": {
    "blockHeight": 123456,
    "timestamp": "2023-09-24T14:22:00.000Z"
  }
}
```

{% endtab %}
{% endtabs %}

### **4. Get Transactions by Address**

Fetches transactions for a specific address.

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

* Example Query&#x20;

```
query: "Show transactions for 0xYourAddress"
```

**Function Name**: `GetTransactionsByAddress`

* **Function Argument**:

  ```json
  {
    "address": "0xYourAddress",
    "session": "ExplorerPageSession", // TODO: automatically adjust page based on user instruction
    "limit": 20
  }
  ```

{% endtab %}

{% tab title="Response" %}

```json
{
  "status": "Success",
  "action": "GetTransactionsByAddress",
  "message": "Retrieved 20 transactions for 0xAddress",
  "data": {
    "transactions": [...],
    "pagination": {...}
  }
}
```

{% endtab %}
{% endtabs %}

### 5. **Get Contract ABI**

Fetches the ABI (Application Binary Interface) of a contract.

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

* Example Query&#x20;

```
query: "Fetch the ABI for contract at 0xContractAddress"
```

**Function Name**: `GetContractABI`

* **Function Argument**:

  ```json
  {
    "address": "0xContractAddress"
  }
  ```

{% endtab %}

{% tab title="Response" %}

```json
{
  "status": "Success",
  "action": "GetContractABI",
  "message": "Fetched ABI for contract at 0xContractAddress",
  "data": { "abi": result }
}
```

{% endtab %}
{% endtabs %}

### 6. **Get Transaction by Hash**

Fetches the details of a transaction using its hash.

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

* Example Query&#x20;

```
query: "Get transaction details for 0xTransactionHash"
```

**Function Name**: `GetTransactionByHash`

* **Function Argument**:

  ```json
  {
    "txHash": "0xTransactionHash"
  }
  ```

{% endtab %}

{% tab title="Response" %}

```json
{
  "status": "Success",
  "action": "GetTransactionByHash",
  "message": "Retrieved details for transaction 0xTransactionHash",
  "data": { ... }
}
```

{% endtab %}
{% endtabs %}

### 7. **Get Block by Number**

Fetches the details of a block using its block number.

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

* Example Query&#x20;

```
query: "Fetch details of the latest block"
```

**Function Name**: `GetBlocksByNumber`

* **Function Argument**:

  ```json
  {
    "blockNumbers": ["latest"],
    "txDetail": false
  }
  ```

{% endtab %}

{% tab title="Response" %}

```json
{
  "status": "Success",
  "action": "GetBlocksByNumber",
  "message": "Retrieved information for blocks",
  "data": { ... }
}
```

{% endtab %}
{% endtabs %}

### 8. **Get Transaction Status**

Fetches the status of a transaction using its hash.

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

* Example Query&#x20;

```
query: "What is the status of transaction 0xTransactionHash?"
```

**Function Name**: `GetTransactionStatus`

* **Function Argument**:

  ```json
  {
    "txHash": "0xTransactionHash"
  }
  ```

{% endtab %}

{% tab title="Response" %}

```json
{
  "status": "Success",
  "action": "GetTransactionStatus",
  "message": "Transaction status: Success",
  "data": { ... }
}
```

{% endtab %}
{% endtabs %}

### 9. Wrapping zkCRO

Wraps zkCRO tokens into wrapped tokens.

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

* Example Query&#x20;

```
query: "Wrap 100 zkCRO tokens"
```

**Function Name**: `WrapToken`

* **Function Argument**:

  ```json
  {
    "amount": 100
  }
  ```

{% endtab %}

{% tab title="Response" %}

```json
{
  "status": "Success",
  "action": "WrapToken",
  "message": "Signature URL created successfully. Please sign the transaction on this link.",
  "data": {
    "magicLink": "http://{provider}/wrap-token/{transactionId}?token={token}"
  }
}
```

{% endtab %}
{% endtabs %}

**Note:** This function returns a magic link. [Read more about Magic Link](https://ai-agent-sdk-docs.crypto.com/crypto.com-ai-agent-sdk/ai-agent-sdk-examples/magic-link-signer).

### **10. Swap Token**

Swaps one token into another (e.g., zkCRO to VUSD).

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

* Example Query&#x20;

```
query: "Swap 100 zkCRO tokens to VUSD"
```

**Function Name**: `SwapToken`

* **Function Argument**:

  ```json
  {
    "amount": 100
  }
  ```

{% endtab %}

{% tab title="Response" %}

```json
{
  "status": "Success",
  "action": "SwapToken",
  "message": "Signature URL created successfully. Please sign the transaction on this link.",
  "data": {
    "magicLink": "http://{provider}/swap-token/{transactionId}?token={token}"
  }
}
```

{% endtab %}
{% endtabs %}

**Note:** This function returns a magic link. [Read more about Magic Link](https://ai-agent-sdk-docs.crypto.com/crypto.com-ai-agent-sdk/ai-agent-sdk-examples/magic-link-signer).


---

# 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/outdated-contents/functions-and-example-queries-of-ai-agent-services.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.
