Skip to main content
Glama

get_halving_countdown

Calculate the remaining time until the next Bitcoin halving event, showing blocks left, estimated date, and subsidy changes.

Instructions

Get a focused countdown to the next Bitcoin halving: blocks remaining, estimated date, and subsidy change.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The 'get_halving_countdown' tool calculates the blocks remaining until the next Bitcoin halving, the estimated time remaining in days, and the change in subsidy. It retrieves the current block count via RPC and estimates the time using recent block statistics.
    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})

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