Skip to main content
Glama

get_transaction_by_hash

Retrieve detailed transaction information by specifying its hash using the Cryo MCP Server. Query Ethereum blockchain data for precise insights into transaction details.

Instructions

Get detailed information about a transaction by its hash

Args:
    tx_hash: The transaction hash to look up
    
Returns:
    Detailed information about the transaction

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tx_hashYes

Implementation Reference

  • The main handler function for the 'get_transaction_by_hash' tool. It uses Ethereum JSON-RPC calls (eth_getTransactionByHash and eth_getTransactionReceipt) to fetch and combine transaction details including block info, gas usage, status, and EIP-1559 fields if applicable.
    @mcp.tool()
    def get_transaction_by_hash(
        tx_hash: str
    ) -> Dict[str, Any]:
        """
        Get detailed information about a transaction by its hash
        
        Args:
            tx_hash: The transaction hash to look up
            
        Returns:
            Detailed information about the transaction
        """
        # Ensure we have the RPC URL
        rpc_url = os.environ.get("ETH_RPC_URL", DEFAULT_RPC_URL)
        
        # Use RPC directly to get the transaction
        payload = {
            "jsonrpc": "2.0",
            "method": "eth_getTransactionByHash",
            "params": [tx_hash],
            "id": 1
        }
        
        try:
            response = requests.post(rpc_url, json=payload)
            response_data = response.json()
            
            if 'result' in response_data and response_data['result']:
                tx_data = response_data['result']
                
                # Get the receipt as well for additional information (gas used, status)
                receipt_payload = {
                    "jsonrpc": "2.0",
                    "method": "eth_getTransactionReceipt",
                    "params": [tx_hash],
                    "id": 2
                }
                
                receipt_response = requests.post(rpc_url, json=receipt_payload)
                receipt_data = receipt_response.json()
                
                if 'result' in receipt_data and receipt_data['result']:
                    receipt = receipt_data['result']
                    
                    # Combine transaction and receipt data
                    result = {
                        "transaction_hash": tx_hash,
                        "block_number": int(tx_data.get("blockNumber", "0x0"), 16),
                        "block_hash": tx_data.get("blockHash"),
                        "from_address": tx_data.get("from"),
                        "to_address": tx_data.get("to"),
                        "value": tx_data.get("value"),
                        "value_decimal": int(tx_data.get("value", "0x0"), 16),
                        "gas_limit": int(tx_data.get("gas", "0x0"), 16),
                        "gas_price": int(tx_data.get("gasPrice", "0x0"), 16),
                        "nonce": int(tx_data.get("nonce", "0x0"), 16),
                        "input": tx_data.get("input"),
                        "transaction_index": int(tx_data.get("transactionIndex", "0x0"), 16),
                        "gas_used": int(receipt.get("gasUsed", "0x0"), 16),
                        "status": int(receipt.get("status", "0x0"), 16),
                        "logs_count": len(receipt.get("logs", [])),
                        "contract_address": receipt.get("contractAddress")
                    }
                    
                    # Handle EIP-1559 transactions
                    if "maxFeePerGas" in tx_data:
                        result["max_fee_per_gas"] = int(tx_data.get("maxFeePerGas", "0x0"), 16)
                        result["max_priority_fee_per_gas"] = int(tx_data.get("maxPriorityFeePerGas", "0x0"), 16)
                        result["transaction_type"] = int(tx_data.get("type", "0x0"), 16)
                    
                    return result
                else:
                    # Return just the transaction data if receipt is not available
                    return {
                        "transaction_hash": tx_hash,
                        "block_number": int(tx_data.get("blockNumber", "0x0"), 16),
                        "block_hash": tx_data.get("blockHash"),
                        "from_address": tx_data.get("from"),
                        "to_address": tx_data.get("to"),
                        "value": tx_data.get("value"),
                        "value_decimal": int(tx_data.get("value", "0x0"), 16),
                        "gas_limit": int(tx_data.get("gas", "0x0"), 16),
                        "gas_price": int(tx_data.get("gasPrice", "0x0"), 16),
                        "nonce": int(tx_data.get("nonce", "0x0"), 16),
                        "input": tx_data.get("input"),
                        "transaction_index": int(tx_data.get("transactionIndex", "0x0"), 16),
                        "error": "Failed to retrieve transaction receipt"
                    }
            else:
                return {"error": f"Transaction not found: {tx_hash}"}
        except Exception as e:
            return {"error": f"Exception when fetching transaction: {e}"}
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure but offers minimal information. It states what the tool does but doesn't cover important aspects like error handling (what happens with invalid hashes), performance characteristics, rate limits, authentication requirements, or whether this is a read-only operation. The description is functionally correct but lacks operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured with clear sections for purpose, arguments, and returns. Each sentence serves a distinct purpose without redundancy. The formatting with headers makes it easy to parse, though the 'Returns' section could be more specific given there's no output schema.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations, no output schema, and 0% schema description coverage, the description is insufficiently complete. It covers the basic operation but lacks critical information about what 'detailed information' includes, error conditions, performance expectations, and how this tool relates to the available SQL query alternatives on the server.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description explicitly documents the single parameter 'tx_hash' and its purpose ('The transaction hash to look up'), which adds value beyond the schema's 0% description coverage. However, it doesn't provide format details (e.g., hex string, length requirements) or validation rules that would be helpful for proper usage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Get') and resource ('detailed information about a transaction'), making it immediately understandable. However, it doesn't differentiate this tool from potential siblings like 'query_blockchain_sql' or 'query_dataset' that might also retrieve transaction data through different mechanisms.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'query_blockchain_sql' and 'query_dataset' available, there's no indication whether this is the preferred method for transaction lookups, if it's faster for single transactions, or when SQL queries would be more appropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/z80dev/cryo-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server