Class: BSV::Network::Protocols::Ordinals

Inherits:
BSV::Network::Protocol show all
Defined in:
lib/bsv/network/protocols/ordinals.rb

Overview

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: "..." }

Instance Attribute Summary

Attributes inherited from BSV::Network::Protocol

#api_key, #auth, #base_url, #http_client, #network

Instance Method Summary collapse

Methods inherited from BSV::Network::Protocol

#call, commands, #default_call, endpoint, endpoints, inherited, subscription, subscriptions

Constructor Details

#initialize(base_url:, api_key: nil, auth: nil, http_client: nil) ⇒ Ordinals

Returns a new instance of Ordinals.

Parameters:

  • base_url (String)

    base URL for the Ordinals API

  • api_key (String, nil) (defaults to: nil)

    legacy Bearer API key shorthand — use auth: for new code

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

    auth config; takes precedence over api_key:

  • http_client (Object, nil) (defaults to: nil)

    injectable HTTP client for testing



75
76
77
# File 'lib/bsv/network/protocols/ordinals.rb', line 75

def initialize(base_url:, api_key: nil, auth: nil, http_client: nil)
  super
end