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

accountSubscription

Subscribe to account creation events for a single user index. WebSocket only.

Signature

function accountSubscription(
  client: Client,
  parameters: SubscriptionCallbacks<{
    accounts: IndexedAccountEvent[]
  }> & {
    userIndex: number
    sinceBlockHeight?: number
  },
): () => void

Example

import { createPublicClient, createTransport, testnet } from "@left-curve/sdk"
 
const client = createPublicClient({ chain: testnet, transport: createTransport() })
const unsubscribe = client.accountSubscription({
  userIndex: 42,
  next: ({ accounts }) => console.log("new accounts", accounts),
})

Parameters

userIndexnumber. The user whose new accounts to watch.

sinceBlockHeightnumber, optional. Replay events from this height before going live.

next(data) => void. Called with new account events.

error, complete — optional callbacks.

Returns

() => void — unsubscribe.

See also