solana_kit_transaction_confirmation 0.10.0 copy "solana_kit_transaction_confirmation: ^0.10.0" to clipboard
solana_kit_transaction_confirmation: ^0.10.0 copied to clipboard

Confirmation tracking for the Solana Kit Dart SDK.

solana_kit_transaction_confirmation #

pub package docs website CI coverage

Confirm Solana transactions by racing signature notifications against block-height expiry, durable-nonce invalidation, or timeouts.

Installation #

Install the package directly:

dependencies:
  "solana_kit_transaction_confirmation": ^0.10.0

If your app uses several Solana Kit packages together, you can also depend on the umbrella package instead:

dart pub add solana_kit

Inside this monorepo, Dart workspace resolution uses the local package automatically.

Documentation #

For architecture notes, getting-started guides, and cross-package examples, start with the workspace docs site and then drill down into the package README and API reference.

Usage #

Send and confirm #

The additive helper sendAndConfirmTransaction sends and polls for confirmation in one call. Pass an Rpc instance and a fully signed transaction.

import 'package:solana_kit/solana_kit.dart';

Future<void> main() async {
  final rpc = createSolanaRpc(url: 'https://api.devnet.solana.com');
  // `signedTransaction` is a fully signed TransactionWithLifetime.
  // final signature = await sendAndConfirmTransaction(
  //   rpc: rpc,
  //   transaction: signedTransaction,
  // );
  // print('Confirmed signature: ${signature.value}');
  print(rpc);
}

Wait for confirmation #

If you already have a signature (for example, from a prior sendTransaction call), use waitForTransactionConfirmation to poll until the transaction reaches your target commitment level.

import 'package:solana_kit/solana_kit.dart';

Future<void> main() async {
  final rpc = createSolanaRpc(url: 'https://api.devnet.solana.com');
  // `signature` and `transaction` come from a prior sendTransaction call.
  // await waitForTransactionConfirmation(
  //   rpc: rpc,
  //   signature: mySignature,
  //   transaction: myTransaction,
  // );
  print(rpc);
}

Configuration #

Both helpers accept an optional config object:

import 'package:solana_kit/solana_kit.dart';
import 'package:solana_kit_subscribable/solana_kit_subscribable.dart';

void main() {
  final abortSource = CancellationTokenSource();
  final config = RpcTransactionConfirmationConfig(
    commitment: Commitment.confirmed,
    pollInterval: Duration(milliseconds: 400),
    searchTransactionHistory: false,
    abortSignal: abortSource.token,
  );
  print(config.commitment);
}

SendAndConfirmTransactionConfig extends RpcTransactionConfirmationConfig and adds maxRetries for the send step.

Low-level strategy factories #

For custom confirmation logic, the package exposes strategy factories you can compose yourself:

  • createBlockHeightExceedencePromiseFactory detects block-height expiry.
  • createNonceInvalidationPromiseFactory detects durable nonce invalidation.
  • createRecentSignatureConfirmationPromiseFactory combines signature notifications with an initial status lookup.
  • getTimeoutPromise adds a wall-clock deadline.
  • raceStrategies combines strategies, settling on the first success or failure and cancelling the rest.

Strategy factories reject cancelled operations with StateError, including when cancellation happens after the initial lookup. Subscription errors propagate to the caller, and a subscription that ends without a terminal notification rejects with StateError. Block-height monitoring preserves slot notifications received during its initial lookup.

Example #

Use example/main.dart as a runnable starting point for solana_kit_transaction_confirmation.

  • Import path: package:solana_kit_transaction_confirmation/solana_kit_transaction_confirmation.dart
  • This section is centrally maintained with mdt to keep package guidance aligned.
  • After updating shared docs templates, run docs:update from the repo root.

Maintenance #

  • Validate docs in CI and locally with docs:check.
  • Keep examples focused on one workflow and reference package README sections for deeper API details.