# Class BSV::Transaction::ChainTrackers::WhatsOnChain <a id="class-BSV-Transaction-ChainTrackers-WhatsOnChain"></a>

**Inherits:** `BSV::Transaction::ChainTracker`

Chain tracker that verifies merkle roots using the WhatsOnChain API.

Delegates all HTTP communication to {BSV::Network::Protocols::WoCREST}. The
constructor signature and {ChainTracker} contract are preserved.

Note: the WoC API key is sent as a raw `Authorization` header value (not
Bearer-prefixed) to match the existing WoC API convention.

**@example**
```ruby
tracker = BSV::Transaction::ChainTrackers::WhatsOnChain.new
tracker.valid_root_for_height?('abcd...', 800_000)
```

## Public Class Methods
### `default(testnet: = false)` <a id="method-c-default"></a> <a id="default-class_method"></a>
Returns a WhatsOnChain chain tracker using the provider default.
- **@param** `testnet` [Boolean] when true, uses the testnet endpoint
- **@param** `**` [Hash] forwarded to the underlying protocol (e.g. +api_key:+, +http_client:+)
- **@return** [WhatsOnChain]

## Public Instance Methods
### `current_height()` <a id="method-i-current_height"></a> <a id="current_height-instance_method"></a>
Return the current blockchain height.
- **@raise** [StandardError] on network or API error
- **@return** [Integer]

### `initialize(network: = :main, api_key: = nil, http_client: = nil, protocol: = nil)` <a id="method-i-initialize"></a> <a id="initialize-instance_method"></a>
- **@param** `network` [Symbol] :main, :mainnet, :test, :testnet (legacy compat)
- **@param** `api_key` [String, nil] optional WoC API key
- **@param** `http_client` [#request, nil] injectable HTTP client for testing
- **@param** `protocol` [BSV::Network::Protocols::WoCREST, nil] pre-configured protocol
- **@return** [WhatsOnChain] a new instance of WhatsOnChain

### `valid_root_for_height?(root, height)` <a id="method-i-valid_root_for_height-3F"></a> <a id="valid_root_for_height?-instance_method"></a>
Verify that a merkle root is valid for the given block height.
- **@param** `root` [String] merkle root as a hex string
- **@param** `height` [Integer] block height
- **@raise** [StandardError] on network or API error
- **@return** [Boolean]
