Class: BSV::Network::Providers::WhatsOnChain
- Inherits:
-
Object
- Object
- BSV::Network::Providers::WhatsOnChain
- Defined in:
- lib/bsv/network/providers/whats_on_chain.rb
Overview
WhatsOnChain returns pre-configured Provider instances using the WhatsOnChain REST API (WoCREST protocol).
The base URL is fully resolved per network — no {network} template is used in provider defaults. The WoCREST protocol’s network: param is omitted since the URL already encodes the network segment.
Example
provider = BSV::Network::Providers::WhatsOnChain.mainnet
provider.call(:get_tx, 'abc123...')
provider = BSV::Network::Providers::WhatsOnChain.testnet(api_key: 'my-key')
provider.call(:broadcast, tx)
Class Method Summary collapse
-
.default(testnet: false, network: nil, **opts) ⇒ Provider
Returns a Provider for the given network.
-
.mainnet(**opts) ⇒ Provider
Returns a mainnet Provider configured with WoCREST.
-
.stn(**opts) ⇒ Provider
Returns a Provider for the BSV Scaling Test Network (STN).
-
.testnet(**opts) ⇒ Provider
Returns a testnet Provider configured with WoCREST.
Class Method Details
.default(testnet: false, network: nil, **opts) ⇒ Provider
Returns a Provider for the given network.
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/bsv/network/providers/whats_on_chain.rb', line 57 def self.default(testnet: false, network: nil, **opts) if network case network.to_sym when :main, :mainnet then mainnet(**opts) when :test, :testnet then testnet(**opts) when :stn then stn(**opts) else raise ArgumentError, "unknown network: #{network}" end else testnet ? testnet(**opts) : mainnet(**opts) end end |
.mainnet(**opts) ⇒ Provider
Returns a mainnet Provider configured with WoCREST.
25 26 27 28 29 |
# File 'lib/bsv/network/providers/whats_on_chain.rb', line 25 def self.mainnet(**opts) Provider.new('WhatsOnChain') do |p| p.protocol Protocols::WoCREST, base_url: 'https://api.whatsonchain.com/v1/bsv/main', **opts end end |
.stn(**opts) ⇒ Provider
Returns a Provider for the BSV Scaling Test Network (STN).
45 46 47 48 49 |
# File 'lib/bsv/network/providers/whats_on_chain.rb', line 45 def self.stn(**opts) Provider.new('WhatsOnChain') do |p| p.protocol Protocols::WoCREST, base_url: 'https://api.whatsonchain.com/v1/bsv/stn', **opts end end |
.testnet(**opts) ⇒ Provider
Returns a testnet Provider configured with WoCREST.
35 36 37 38 39 |
# File 'lib/bsv/network/providers/whats_on_chain.rb', line 35 def self.testnet(**opts) Provider.new('WhatsOnChain') do |p| p.protocol Protocols::WoCREST, base_url: 'https://api.whatsonchain.com/v1/bsv/test', **opts end end |