# Wallet Management

The SDK includes essential wallet features, such as wallet creation, balance checks, and support for Single Sign-On (SSO) wallets. These functionalities simplify dApp development and blockchain interactions.&#x20;

With just a few lines of code, developers can integrate wallet management capabilities into their AI agents, which makes it easier to build decentralized applications with enhanced blockchain interaction.

To learn more about the underlying Developer Platform functionalities, please visit [Developer Platform Client SDK Wallet Module](https://ai-agent-sdk-docs.crypto.com/crypto.com-developer-platform/on-chain-developer-platform-client-sdk/wallet-module).

{% hint style="warning" %}
**Security Warning: Private Key Storage**\
Private keys generated and stored locally on a developer's or end-user's machine may be exposed to compromise due to inadequate protection of the local environment. If the machine is infected with malware, improperly secured, or lacks encryption and access controls, unauthorized parties could gain access to the private key material. This could result in irreversible loss of digital assets, unauthorized transactions, or compromise of wallet integrity.
{% endhint %}

#### 1.1 Create wallet

Create a new blockchain wallet. It retrieves the wallet's address and private key using the Crypto.com developer platform.

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

* Example Query

  ```
  "Create a wallet"
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  <pre class="language-python"><code class="lang-python"><strong>str: A formatted string containing the wallet's address and private key.
  </strong></code></pre>
* Example Response

  ```
  A new wallet has been created successfully. Here are the details:
  - Wallet Address: <example-address>
  - Private Key: <example-private-key>
  Please ensure to store the private key securely, as it is essential for accessing your wallet.
  ```

{% endtab %}
{% endtabs %}

Example Code

```python
from crypto_com_agent_client import Agent

agent = Agent.init(
    llm_config={
        "provider": "OpenAI",
        "model": "gpt-4o-mini",
        "temperature": 1,
        "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("Create a wallet")
print(response)
```

#### 1.2 Get Wallet Balance

Retrieve the balance of a specified wallet address.

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

* Arguments

  ```python
  address (str): The address to get the balance for (e.g., "xyz.cro").
  ```
* Example Query

  ```
  "Get wallet balance of <example-wallet-address>"
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```python
  str: A formatted string containing the wallet balance.
  ```
* Example Response

  ```
  The wallet balance for address <example-wallet-address> is <example-balance>.
  ```

{% endtab %}
{% endtabs %}

Example Code

```python
from crypto_com_agent_client import Agent
agent = Agent.init(
    llm_config={
        "provider": "OpenAI",
        "model": "gpt-4o-mini",
        "provider-api-key": "sk-proj-example-key",
        "temperature": 1,
        "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 wallet balance of <example-wallet-address>")
print(response)
```

#### 1.3 Send via SSO Wallet

Generate a URL that can be used to initiate a token transfer through the SSO wallet interface. If "null" is specified as the receiver, it will use the null address (`0x0000000000000000000000000000000000000000`).

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

* Arguments

  ```python
  receiver (str): The recipient's blockchain address or "null" for null address.
  amount (int): The amount of tokens to transfer in Wei.
  data (str, optional): Additional data for the transfer. Defaults to "0x"
  ```
* Example Query

  ```
  "Send <example-amount> Wei to <example-recipient> with data <example-data> through sso wallet"
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```python
  str: A formatted URL for the SSO wallet transfer.
  ```
* Example Response

  ```
  The token transfer has been initiated. 
  You can use the following URL to complete the transaction through the SSO wallet:
  [Transfer Token](None/transfer-token?recipient=<example-recipient>&amount=<example-amount>&data=<example-data>)
  Please follow the link to proceed with the transfer.
  ```

{% endtab %}
{% endtabs %}

Example Code

```python
from crypto_com_agent_client import Agent

agent = Agent.init(
    llm_config={
        "provider": "OpenAI",
        "model": "gpt-4o-mini",
        "provider-api-key": "sk-proj-example-key",
        "temperature": 1,
        "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("Send <example-amount> Wei to <example-recipient> with data <example-data> through sso wallet")
print(response)
```
