Token Interaction
The AI Agent SDK offers powerful token interaction capabilities on the Cronos blockchain. It supports retrieving token balances for both native tokens and ERC20 tokens, performing token transfers, as well as wrapping and swapping tokens.
This comprehensive feature set makes it easy for developers to build AI agents that smoothly interact with tokens.
To learn more about the underlying Developer Platform functionalities, please visit Developer Platform Client SDK Token Module.
2.1 Get native balance
Query the native token balance for the specified blockchain address using the Crypto.com developer platform.
Arguments
address (str): The blockchain address to query.Example Query
"Get native balance of <example-address>"
Returns
str: A formatted string containing the native token balance for the address.Example Response
The native balance for address <example-address> is <example-amount> CRO (CRO being the native token).
Example Code
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",
},
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 native balance of <example-address>")
print(response)2.2 Get ERC20 Token Balance
Query the ERC20 token balance for the specified blockchain address and ERC20 contract address.
Arguments
Example Query
Returns
Example Response
Example Code
2.3 Transfer native token
Transfer native tokens (cro, CRO, tcro, tCRO, zkcro, zkCRO, zktcro, zkTCRO) to a specified address using the Crypto.com developer platform.
Arguments
Example Query
Returns
Example Response
Example Code
2.4 Transfer ERC20 token
Transfer ERC20 tokens to a specified address.
Arguments
Example Query
Returns
Example Response
Example Code
2.5 Wrap token
Wrap native tokens into wrapped tokens using the Crypto.com developer platform.
Arguments
Example Query
Returns
Example Response
Example Code
2.6 Swap token
Swap tokens between two different tokens.
Arguments
Example Query
Returns
Example Response
Example Code
Last updated
Was this helpful?