QubicTypeScript

waitForTick

Polls the live API until the network tick reaches or exceeds a target tick.

waitForTick(live, targetTick, options?)

Polls live.getTickInfo() at a regular interval until the network tick reaches or exceeds targetTick. Returns when the condition is met or the timeout expires.

import { createQubicClient, waitForTick } from "@qubic.org/rpc"

const { live } = createQubicClient()

const tickResult = await live.getTickInfo()
if (!tickResult.ok) throw tickResult.error

const target = tickResult.value.tick + 5

const confirmation = await waitForTick(live, target, { timeoutMs: 90_000 })
if (confirmation.ok) {
  console.log("Tick reached:", confirmation.value)
}

Parameters

NameTypeDescription
liveLiveClientLive client to poll
targetTicknumberTick number to wait for
intervalMsnumberPoll interval in milliseconds. Default: 1000
timeoutMsnumberMaximum wait in milliseconds. Default: 60000
signalAbortSignalCancels polling when aborted

Returns Promise<Result<number, QubicRpcError>>ok(targetTick) when reached, err on timeout or cancellation.

On this page