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.
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.
1.1 Create wallet
Create a new blockchain wallet. It retrieves the wallet's address and private key using the Crypto.com developer platform.
Arguments
Example Query
"Create a wallet"
Example Code
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",
},
blockchain_config={
"chainId": "chain-id",
"explorer-api-key": "your-api-key",
"private-key": "your-private-key",
"sso-wallet-url": "your-sso-wallet-url",
},
)
response = agent.interact("Create a wallet")
print(response)
1.2 Get Wallet Balance
Retrieve the balance of a specified wallet address.
Arguments
address (str): The address to get the balance for (e.g., "xyz.cro").
Example Query
"Get wallet balance of <example-wallet-address>"
Example Code
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",
},
blockchain_config={
"chainId": "chain-id",
"explorer-api-key": "your-api-key",
"private-key": "your-private-key",
"sso-wallet-url": "your-sso-wallet-url",
},
)
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
).
Arguments
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"
Example Code
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",
},
blockchain_config={
"chainId": "chain-id",
"explorer-api-key": "your-api-key",
"private-key": "your-private-key",
"sso-wallet-url": "your-sso-wallet-url",
},
)
response = agent.interact("Send <example-amount> Wei to <example-recipient> with data <example-data> through sso wallet")
print(response)
Last updated
Was this helpful?