Transaction Queries
The AI Agent SDK enables efficient transaction management on Cronos Chains by providing features for querying transactions by address or hash. It also supports fetching transaction statuses, making it easy to track and verify blockchain activities accurately.
This functionality allows developers to build AI agents capable of monitoring and analyzing transactions in real-time, enhancing their applications' reliability and responsiveness.
3.1 Get transaction by hash
Retrieve transaction details for the specified hash using the Crypto.com developer platform.
Arguments
hash (str): The hash of the transaction to retrieve.
Example Query
"Get transaction of transaction hash <example-hash>"
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 transaction of transaction hash <example-hash>")
print(response)
3.2 Get transaction by address
Retrieve a list of transactions for the specified blockchain address from the Crypto.com developer platform within a specified block range.
Arguments
address (str): The blockchain address to query (CronosIds with the `.cro` suffix are supported). startBlock (int): The starting block number to get transactions from. The maximum range is 10,000 blocks. endBlock (int): The ending block number to get transactions to. The maximum range is 10,000 blocks. session (str, optional): Session identifier for pagination. Defaults to "". limit (str, optional): Maximum number of transactions to return. Defaults to "20".
Example Query
"Get transactions of <example-address> from block <example-start-block> to <example-end-block>"
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 transactions of <example-address> from block <example-start-block> to <example-end-block>")
print(response)
3.3 Get transaction status
Retrieve the status of a transaction using its hash using the Crypto.com developer platform.
Arguments
hash (str): The hash of the transaction to check.
Example Query
"Get transaction status of <example-transation-hash>"
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 transaction status of <example-transation-hash>")
print(response)
Last updated
Was this helpful?