Class: BSV::Network::Protocols::Chaintracks

Inherits:
BSV::Network::Protocol show all
Defined in:
lib/bsv/network/protocols/chaintracks.rb

Overview

Chaintracks implements the GorillaPool Chaintracks API as a Protocol subclass.

Provides block header lookup and current chain tip height via the GorillaPool Chaintracks v2 REST API. Pure DSL — no escape hatches needed.

Chaintracks does not use a {network} placeholder in the URL. Mainnet and testnet are served from separate base URLs; the provider defaults supply the correct URL for each network.

Usage

ct = BSV::Network::Protocols::Chaintracks.new(base_url: 'https://arcade.gorillapool.io')
result = ct.call(:current_height)
result.data  # => 800000

result = ct.call(:get_block_header, 800_000)
result.data  # => { 'hash' => '...', 'height' => 800000, 'merkleRoot' => '...' }

Instance Attribute Summary

Attributes inherited from BSV::Network::Protocol

#api_key, #base_url, #http_client, #network

Instance Method Summary collapse

Methods inherited from BSV::Network::Protocol

#call, commands, #default_call, endpoint, endpoints, inherited, subscription, subscriptions

Constructor Details

#initialize(base_url:, api_key: nil, http_client: nil) ⇒ Chaintracks

Returns a new instance of Chaintracks.

Parameters:

  • base_url (String)

    base URL for the Chaintracks API

  • api_key (String, nil) (defaults to: nil)

    optional Bearer API key

  • http_client (Object, nil) (defaults to: nil)

    injectable HTTP client for testing



33
34
35
# File 'lib/bsv/network/protocols/chaintracks.rb', line 33

def initialize(base_url:, api_key: nil, http_client: nil)
  super
end