Event filter
eventFilter() — chainable builder for filtering Qubic log events by identity, contract, log type, and tick range.
eventFilter() returns a chainable builder for constructing EventFilter objects. Pass the result to subscription helpers or archive queries to narrow the event stream.
The builder is immutable: each method call returns the same builder instance after mutating internal state, so you can chain calls freely.
eventFilter()
import { eventFilter, LOG_TYPE } from "@qubic.org/events"
import { toIdentity } from "@qubic.org/types"
const identity = toIdentity("CFBMEMZOIDEXQAUXYYSZIURADQLAPWPMNJXQSNVQZAHYVOPYUKKJBJUCTVJL")
const filter = eventFilter()
.forIdentity(identity)
.ofTypes(LOG_TYPE.QU_TRANSFER, LOG_TYPE.BURNING)
.fromTick(25_000_000)
.build()Returns EventFilterBuilder — see builder methods below.
Builder methods
.forIdentity(identity)
Restricts events to those involving the given identity (as source, destination, or owner, depending on the log type).
eventFilter().forIdentity(identity)Parameters
| Name | Type | Description |
|---|---|---|
identity | Identity | Qubic identity to filter by |
.forContract(contractIndex)
Restricts events to those emitted by the given contract.
eventFilter().forContract(9) // Qearn contractParameters
| Name | Type | Description |
|---|---|---|
contractIndex | number | Contract index on the Qubic network |
.ofTypes(...logTypes)
Restricts events to the specified log types. Pass multiple types to match any of them.
import { LOG_TYPE } from "@qubic.org/events"
eventFilter().ofTypes(LOG_TYPE.QU_TRANSFER, LOG_TYPE.BURNING)When building a Bob subscription filter with .toBobFilter(), only the first log type is forwarded (Bob's WebSocket API supports one type per subscription). Use subscribeAllEvents with a broader filter when you need multiple types in a single stream.
Parameters
| Name | Type | Description |
|---|---|---|
...logTypes | LogType[] | One or more LOG_TYPE values |
.fromTick(tick)
Restricts to events at or after the given tick.
eventFilter().fromTick(25_000_000).toTick(tick)
Restricts to events up to and including the given tick.
eventFilter().toTick(26_000_000).build()
Returns the EventFilter object. Use this with subscription helpers from @qubic.org/events.
const filter = eventFilter().forIdentity(identity).build()
for await (const event of subscribeAllEvents(bob.subscription, filter)) {
// ...
}Returns EventFilter
| Field | Type | Description |
|---|---|---|
identity | Identity | Set by .forIdentity() |
contractIndex | number | Set by .forContract() |
logTypes | LogType[] | Set by .ofTypes() |
fromTick | number | Set by .fromTick() |
toTick | number | Set by .toTick() |
.toBobFilter()
Returns a BobLogFilter for direct use with bob.subscription.subscribeLogs. Only the first logType from .ofTypes() is included, since Bob's WebSocket API supports one log type per subscription filter.
const bobFilter = eventFilter()
.forIdentity(identity)
.ofTypes(LOG_TYPE.QU_TRANSFER)
.toBobFilter()
for await (const event of bob.subscription.subscribeLogs(bobFilter)) {
// raw BobLogEvent — call decodeEvent if you need typed data
}Returns BobLogFilter
Composing a filter
import { eventFilter, LOG_TYPE, subscribeAllEvents } from "@qubic.org/events"
import { createBobClient } from "@qubic.org/bob"
import { toIdentity } from "@qubic.org/types"
const bob = createBobClient({ baseUrl: "http://localhost:40420" })
const identity = toIdentity("CFBMEMZOIDEXQAUXYYSZIURADQLAPWPMNJXQSNVQZAHYVOPYUKKJBJUCTVJL")
// Watch all transfers and burns for an identity, starting from a specific tick
const filter = eventFilter()
.forIdentity(identity)
.ofTypes(LOG_TYPE.QU_TRANSFER, LOG_TYPE.BURNING)
.fromTick(25_000_000)
.build()
for await (const event of subscribeAllEvents(bob.subscription, filter)) {
if (event.isCatchUp) continue
const typed = event.data
if (typed.logType === LOG_TYPE.QU_TRANSFER) {
console.log("Transfer:", typed.data.amount)
} else if (typed.logType === LOG_TYPE.BURNING) {
console.log("Burn:", typed.data.amount, "from", typed.data.source)
}
}