Skip to main content
Glama

compare_blocks

Analyze and compare Bitcoin blockchain statistics between two specific block heights to identify differences in transaction data, mining details, and network metrics.

Instructions

Compare block statistics between two block heights side by side.

Args: height1: First block height height2: Second block height

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
height1Yes
height2Yes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The implementation of the compare_blocks tool, which takes two block heights, retrieves their statistics, and returns a side-by-side comparison including deltas for key metrics.
    def compare_blocks(height1: int, height2: int) -> str:
        """Compare block statistics between two block heights side by side.
    
        Args:
            height1: First block height
            height2: Second block height
        """
        try:
            stats1 = get_rpc().getblockstats(height1)
            stats2 = get_rpc().getblockstats(height2)
        except Exception as e:
            return json.dumps({"error": str(e)})
        compare_keys = [
            "total_fee", "avgfee", "medianfee", "maxfee", "minfee",
            "total_weight", "total_size", "txs", "subsidy",
            "avgfeerate", "mediantime",
        ]
        comparison = {}
        for key in compare_keys:
            v1 = stats1.get(key)
            v2 = stats2.get(key)
            if v1 is None and v2 is None:
                continue
            entry = {"block_1": v1, "block_2": v2}
            if isinstance(v1, (int, float)) and isinstance(v2, (int, float)):
                entry["delta"] = v2 - v1
            comparison[key] = entry
        return json.dumps({
            "height_1": height1,
            "height_2": height2,
            "comparison": comparison,
        })

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/Bortlesboat/bitcoin-mcp'

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