Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

eventsSubscription

Subscribe to a filtered live event stream. WebSocket only.

Signature

function eventsSubscription(
  client: Client,
  parameters: SubscriptionCallbacks<{
    events: SubscriptionEvent[]
  }> & {
    sinceBlockHeight?: number
    filter?: EventFilter[]
  },
): () => void

Example

import { createPublicClient, createTransport, testnet } from "@left-curve/sdk"
 
const client = createPublicClient({ chain: testnet, transport: createTransport() })
const unsubscribe = client.eventsSubscription({
  filter: [
    {
      type: "transfer",
      data: [{ path: ["sender"], checkMode: "EQUAL", value: ["0xabc..."] }],
    },
  ],
  next: ({ events }) => events.forEach((e) => console.log(e.type, e.data)),
})

Parameters

sinceBlockHeightnumber, optional. Replay from this height.

filterEventFilter[], optional. Each filter specifies an event type and one or more path-value matches.

next, error, complete — callbacks.

Returns

() => void — unsubscribe.

See also