Class: BSV::Network::Providers::TAAL

Inherits:
Object
  • Object
show all
Defined in:
lib/bsv/network/providers/taal.rb

Overview

TAAL returns pre-configured Provider instances using the TAAL infrastructure.

Mainnet composes two protocols:

  • ARC at https://arc.taal.com for standard ARC operations

  • TAALBinary at https://api.taal.com for binary broadcast

ARC is registered first, so :broadcast is served by ARC (first-registered wins). TAALBinary registers its own :broadcast command but will not win the index. To use TAALBinary directly, call provider.protocol_for(:broadcast) on the TAALBinary instance via provider.protocols.last, or build a custom Provider.

TAAL requires an API key for production use. The default rate limit is nil (unconstrained) because the effective limit depends on the subscription tier.

There is no TAAL testnet default — TAAL does not publish a supported testnet ARC URL.

Example

provider = BSV::Network::Providers::TAAL.mainnet(auth: { bearer: 'mainnet_...' })
provider.call(:broadcast, tx)

# Legacy api_key: shorthand — still supported
provider = BSV::Network::Providers::TAAL.mainnet(api_key: 'mainnet_...')

Constant Summary collapse

DEFAULT_RATE_LIMIT =

Default requests-per-second limit. nil because the effective limit depends on the TAAL subscription tier.

nil

Class Method Summary collapse

Class Method Details

.default(testnet: false, auth: nil, rate_limit: DEFAULT_RATE_LIMIT, **opts) ⇒ Provider

Returns a mainnet or testnet Provider depending on the testnet: flag.

Parameters:

  • testnet (Boolean) (defaults to: false)

    when true, returns the testnet Provider

  • auth (Hash, Symbol, nil) (defaults to: nil)

    auth config forwarded to Provider and all protocols

  • rate_limit (Numeric, nil) (defaults to: DEFAULT_RATE_LIMIT)

    requests per second; defaults to DEFAULT_RATE_LIMIT (nil)

  • opts (Hash)

    keyword arguments forwarded to each protocol constructor

Returns:



73
74
75
76
# File 'lib/bsv/network/providers/taal.rb', line 73

def self.default(testnet: false, auth: nil, rate_limit: DEFAULT_RATE_LIMIT, **opts)
  kwargs = { auth: auth, rate_limit: rate_limit, **opts }
  testnet ? testnet(**kwargs) : mainnet(**kwargs)
end

.mainnet(auth: nil, rate_limit: DEFAULT_RATE_LIMIT, **opts) ⇒ Provider

Returns a mainnet Provider configured with ARC and TAALBinary.

Auth is forwarded to both protocols. ARC uses Bearer tokens; TAALBinary uses raw API keys. Each protocol’s constructor handles the translation appropriate to its endpoint.

Parameters:

  • auth (Hash, Symbol, nil) (defaults to: nil)

    auth config forwarded to Provider and all protocols

  • rate_limit (Numeric, nil) (defaults to: DEFAULT_RATE_LIMIT)

    requests per second; defaults to DEFAULT_RATE_LIMIT (nil)

  • opts (Hash)

    keyword arguments forwarded to each protocol constructor

Returns:



44
45
46
47
48
49
50
51
# File 'lib/bsv/network/providers/taal.rb', line 44

def self.mainnet(auth: nil, rate_limit: DEFAULT_RATE_LIMIT, **opts)
  resolved_auth = auth || (opts[:api_key] ? { bearer: opts[:api_key] } : :none)
  common = opts.slice(:api_key, :http_client).merge(auth: auth)
  Provider.new('TAAL', auth: resolved_auth, rate_limit: rate_limit) do |p|
    p.protocol Protocols::ARC,        base_url: 'https://arc.taal.com',  auth: auth, **opts
    p.protocol Protocols::TAALBinary, base_url: 'https://api.taal.com',  **common
  end
end

.testnet(auth: nil, rate_limit: DEFAULT_RATE_LIMIT, **opts) ⇒ Provider

Returns a testnet Provider configured with ARC only.

Parameters:

  • auth (Hash, Symbol, nil) (defaults to: nil)

    auth config forwarded to Provider and ARC protocol

  • rate_limit (Numeric, nil) (defaults to: DEFAULT_RATE_LIMIT)

    requests per second; defaults to DEFAULT_RATE_LIMIT (nil)

  • opts (Hash)

    keyword arguments forwarded to the ARC protocol constructor

Returns:



59
60
61
62
63
64
# File 'lib/bsv/network/providers/taal.rb', line 59

def self.testnet(auth: nil, rate_limit: DEFAULT_RATE_LIMIT, **opts)
  resolved_auth = auth || (opts[:api_key] ? { bearer: opts[:api_key] } : :none)
  Provider.new('TAAL', auth: resolved_auth, rate_limit: rate_limit) do |p|
    p.protocol Protocols::ARC, base_url: 'https://arc-test.taal.com', auth: auth, **opts
  end
end