Crypto.com AI Agent SDK
  • Getting Started
    • Introduction
    • Quick Start Guide: Simulation Entry Point
  • Core Concepts Overview
    • Plugins
    • Tools
    • Blockchain Functions
      • Wallet Management
      • Token Interaction
      • Transaction Queries
      • Block Information
      • Contract Operations
      • CronosID Operations
      • Defi Operations
      • Crypto.com Exchange
    • Built-in Telegram Feature
    • Advanced Usage: Custom Instructions
    • Dynamic AI Model Manager
  • Crypto.com On-Chain Developer Platform
    • Developer Platform API Methods
  • On-Chain Functions and Examples
    • AI Agent Chatbot
    • "Magic Link" Signer
  • Resources for Developers
Powered by GitBook
On this page

Was this helpful?

  1. Core Concepts Overview
  2. Blockchain Functions

Block Information

The AI Agent SDK provides robust block operation capabilities, allowing developers to fetch blocks by tag (e.g., latest, pending) or by specific block number on Cronos Chains.

This feature makes it easy to retrieve detailed block information, enabling seamless integration of real-time blockchain data into your AI-powered applications.

4.1 Get block by tag

Retrieve block data for a specified tag using the Crypto.com developer platform.

  • Arguments

    tag (str): Integer of a block number in hex, or the string "earliest", "latest" 
    or "pending".
    tx_detail (str, optional): If "true", returns full transaction objects; 
    if "false", only transaction hashes.
  • Example Query

    "Get <example-tag> block with detail"
  • Returns

    str: A formatted string containing the block data.
  • Example Response

    The latest block data with details is as follows:
    
      Block Number: <example-block-number> 
      Block Hash: <example-block-hash>
      Parent Hash: <example-parent-hash>
      Timestamp: <example-timestamp>
      Transactions Root: <example-transaction-root>
      Receipts Root: <example-receipts-root>
      State Root: <example-state-root>
      Gas Limit: <example-gas-limit>
      Gas Used: <example-gas-used>
      Miner: <example-miner>
      Difficulty: <example-difficulty>
      Total Difficulty: <example-total-difficulty>
      Gas Price: <example-gas-price>
      Base Fee Per Gas: <example-base-fee-per-gase>
      Nonce: <example-nonce>
      Transactions:
        Transaction Hash: <example-transaction-hash>
        From: <example-from>
        To: <example-to>
        Value: <example-value>
        Gas: <example-gas>
        Transaction Index: <example-transaction-index>
        Max Fee Per Gas: <example-max-fee-per-gas>
        Max Priority Fee Per Gas: <example-max-priority-fee-per-gas>
    
    This block contains a single transaction and has not been mined by a specific miner. The details also indicate that the block has a gas limit of approximately <example-number> trillion and has utilized around <example-percentage> of that limit. If you need further information or specific details, please let me know!

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 lastest block with detail")
print(response)
PreviousTransaction QueriesNextContract Operations

Last updated 1 day ago

Was this helpful?