waitForTransaction

suspend fun waitForTransaction(config: SuiConfig, digest: String, options: TransactionBlockResponseOptions, timeout: Long = 10000, pollInterval: Long): Result<GetTransactionBlockQuery.Data?, SuiError>

Waits for a transaction block to be processed and available on the network by polling the getTransactionBlock API.

This is a crucial utility to use after signAndExecuteTransactionBlock to ensure a transaction's effects are finalized and available for querying before proceeding. This implementation uses idiomatic Kotlin coroutines for robust handling of timeouts, polling, and cancellation.

Return

A Result.Ok containing the transaction block response once it's found, or a Result.Err if the operation times out or encounters an unrecoverable error.

Parameters

digest

The digest of the transaction to wait for.

options

The options object specifying which fields to return (e.g., effects, object changes).

timeout

The total time in milliseconds to wait for the transaction before failing. Defaults to 60 seconds.

pollInterval

The time in milliseconds to wait between each polling attempt. Defaults to 2 seconds.