QubicTypeScript

subscribeLogs

Emits raw log events matching a filter as an AsyncIterable; the base subscription used by all event helpers in @qubic.org/events.

Signature

bob.subscribeLogs(
  filter?: BobLogFilter,
  options?: SubscribeLogsOptions,
): AsyncIterable<SubscriptionEvent<BobLogEvent>>

Purpose

Emits log events matching the given filter. Resumes from startLogId or startEpoch if provided. This is the base subscription that all helpers in @qubic.org/events (subscribeQuTransfers, subscribeAssetEvents, etc.) use under the hood.

import { toIdentity } from "@qubic.org/types"

const identity = toIdentity("CFBMEMZOIDEXQAUXYYSZIURADQLAPWPMNJXQSNVQZAHYVOPYUKKJBJUCTVJL")

for await (const event of bob.subscription.subscribeLogs(
  { identity, logType: 0 },  // logType 0 = QU_TRANSFER
  { startEpoch: 150 },
)) {
  if (event.isCatchUp) continue  // skip historical events

  const { logType, tick, data } = event.data
  console.log("Log type:", logType, "at tick:", tick)
  // Decode data with decodeEvent from @qubic.org/events
}

Parameters

Filter (BobLogFilter)

NameTypeDescription
contractIndexnumberFilter by contract
logTypenumberFilter by log type
identityIdentityFilter by identity
fromTicknumberStart tick (inclusive)
toTicknumberEnd tick (inclusive)

Options

NameTypeDescription
startLogIdbigintResume from this log ID
startEpochnumberStart from the beginning of this epoch
signalAbortSignalStops the iteration when aborted

Returns

AsyncIterable<SubscriptionEvent<BobLogEvent>>

BobLogEvent fields

FieldTypeDescription
data.ticknumberTick the event occurred in
data.logIdbigintUnique log ID
data.contractIndexnumberEmitting contract
data.logTypenumberLog type identifier
data.dataBase64Raw payload — decode with decodeEvent from @qubic.org/events

Catch-up behavior

When a subscription starts or reconnects after a gap, Bob delivers buffered historical events before switching to live. These have isCatchUp: true. The subscription client tracks the last received logId across reconnects, so the replay resumes from where it left off.

for await (const event of bob.subscription.subscribeLogs(filter)) {
  if (event.isCatchUp) {
    // Historical events filling the gap — process or skip
    processHistoricalEvent(event.data)
    continue
  }
  // Live event
  processLiveEvent(event.data)
}

On this page