Skip to content

Class BSV::Network::Protocols::WoCREST

Inherits: BSV::Network::Protocol

WoCREST implements the WhatsOnChain REST API as a Protocol subclass.

Provides endpoints covering chain info, block headers, transactions, UTXOs, scripts, address queries, broadcast, search, stats, and health. Escape hatches handle WoC-specific body formats and field remapping.

Network resolution

WoC uses main and test in its URL paths. The constructor accepts symbolic aliases (:mainnet, :testnet, :stn) and resolves them to the correct string.

Usage

woc = BSV::Network::Protocols::WoCREST.new(network: :main)
result = woc.call(:get_tx, 'abc123...')
puts result.data if result.http_success?
  • @see https://developers.whatsonchain.com/ WhatsOnChain API documentation

Constants

NETWORKS

Not documented.

Attributes

network_name [R]

Returns the value of attribute network_name.

Public Instance Methods

initialize(base_url:, network: = :main, api_key: = nil, auth: = nil, http_client: = nil)

  • @param base_url [String] base URL for the WoC API; may contain +{network}+ which will be interpolated with the resolved network name
  • @param network [Symbol, String] :main, :mainnet, :test, :testnet, :stn
  • @param api_key [String, nil] legacy API key — sends +Authorization: key+ (no Bearer prefix, matching WoC's expected auth format)
  • @param auth [Hash, Symbol, nil] auth config hash forwarded to Protocol; when provided, takes precedence over +api_key:+
  • @param http_client [Object, nil] injectable HTTP client for testing
  • @return [WoCREST] a new instance of WoCREST