Skip to main content
Glama

estimate_transaction_cost

Estimate Bitcoin transaction fees in sats and USD for different urgency levels and address types. Compare costs to see potential savings from waiting.

Instructions

Estimate Bitcoin transaction cost in sats AND USD at different urgency levels. Supports address types: p2pkh (legacy), p2sh-p2wpkh (nested segwit), p2wpkh (native segwit), p2tr (taproot). Shows how much you save by waiting.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
input_countNo
output_countNo
address_typeNop2wpkh

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The estimate_transaction_cost function is registered as an MCP tool and calculates Bitcoin transaction costs based on input/output counts and address types.
            est_days_until_halving = round(blocks_until_halving * 10 / 60 / 24)
    
            # Annual inflation rate
            blocks_per_year = 365.25 * 24 * 6  # ~52,560
            annual_new_btc = blocks_per_year * subsidy_btc
            inflation_rate_pct = round((annual_new_btc / total_mined) * 100, 3) if total_mined > 0 else 0
    
            return json.dumps({
                "circulating_supply_btc": round(total_mined, 8),
                "max_supply_btc": 21_000_000,
                "pct_mined": round((total_mined / 21_000_000) * 100, 2),
                "current_subsidy_btc": subsidy_btc,
                "halvings_completed": halvings,
                "current_height": height,
                "next_halving_height": next_halving_height,
                "blocks_until_halving": blocks_until_halving,
                "est_days_until_halving": est_days_until_halving,
                "annual_inflation_rate_pct": inflation_rate_pct,
            })
        except Exception as e:
            hint = _connection_hint(e)
            return json.dumps({"error": str(e), "hint": hint})
    
    
    @mcp.tool()
    def get_halving_countdown() -> str:
        """Get a focused countdown to the next Bitcoin halving: blocks remaining, estimated date, and subsidy change."""
        try:
            rpc = get_rpc()
            height = rpc.getblockcount()
            halvings = height // 210_000
            current_subsidy = 50.0 / (2 ** halvings)
            next_subsidy = 50.0 / (2 ** (halvings + 1))
            next_halving_height = (halvings + 1) * 210_000
            blocks_remaining = next_halving_height - height
    
            # Estimate time using recent block rate
            try:
                stats = rpc.getchaintxstats(2016)
                secs_per_block = stats.get("window_interval", 600 * 2016) / stats.get("window_block_count", 2016)
            except Exception:
                secs_per_block = 600  # fallback to 10 min
    
            est_seconds = blocks_remaining * secs_per_block
            est_days = round(est_seconds / 86400)
    
            return json.dumps({
                "current_height": height,
                "next_halving_height": next_halving_height,
                "blocks_remaining": blocks_remaining,
                "est_days_remaining": est_days,
                "current_subsidy_btc": current_subsidy,
                "next_subsidy_btc": next_subsidy,
                "subsidy_reduction_pct": 50.0,
            })
        except Exception as e:
            hint = _connection_hint(e)
            return json.dumps({"error": str(e), "hint": hint})
    
    
    @mcp.tool()
    def get_market_sentiment() -> str:
        """Get Bitcoin Fear & Greed Index: current value (0-100), classification (Extreme Fear/Fear/Neutral/Greed/Extreme Greed), and 7-day history. Use this to gauge market sentiment alongside price data."""
        try:
            url = "https://api.alternative.me/fng/?limit=7"

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