Skip to content

Class BSV::Network::Protocols::Ordinals

Inherits: BSV::Network::Protocol

Ordinals implements the GorillaPool Ordinals API as a Protocol subclass.

Provides raw transaction lookup, Merkle path (proof) retrieval, UTXO queries, balance lookups, spend status, and chain tip via the GorillaPool Ordinals REST API.

get_tx vs get_tx_details

get_tx returns the raw transaction as a hex string (escape hatch converts binary response body to hex). get_tx_details returns the full parsed transaction metadata as a JSON object.

get_balance

The API returns the balance as a quoted integer string (e.g. +"1000000"+), not a bare JSON number. The lambda handler parses this to an Integer.

get_spend

The API returns an empty quoted string +""+ for unspent outputs and a quoted txid string for spent outputs. The escape hatch normalises these to +{ spent: false }+ or +{ spent: true, spending_txid: "..." }+. The outpoint must be passed as +"txid_vout"+ (underscore-separated).

Usage

ord = BSV::Network::Protocols::Ordinals.new(base_url: 'https://ordinals.gorillapool.io')
result = ord.call(:get_tx, 'abc123...')
result.data  # => "01000000..."  (hex string)

result = ord.call(:get_merkle_path, 'abc123...')
result.data  # => binary TSC proof bytes

result = ord.call(:get_spend, 'txid_0')
result.data  # => { spent: false } or { spent: true, spending_txid: "..." }
  • @see https://ordinals.gorillapool.io/api/docs/ Ordinals API documentation

Public Instance Methods

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

  • @param base_url [String] base URL for the Ordinals API
  • @param api_key [String, nil] legacy Bearer API key shorthand — use +auth:+ for new code
  • @param auth [Hash, Symbol, nil] auth config; takes precedence over +api_key:+
  • @param http_client [Object, nil] injectable HTTP client for testing
  • @return [Ordinals] a new instance of Ordinals