solana_kit_transaction_confirmation 0.10.0
solana_kit_transaction_confirmation: ^0.10.0 copied to clipboard
Confirmation tracking for the Solana Kit Dart SDK.
solana_kit_transaction_confirmation #
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 #
- Package page: https://pub.dev/packages/solana_kit_transaction_confirmation
- API reference: https://pub.dev/documentation/solana_kit_transaction_confirmation/latest/
- Workspace docs: https://openbudgetfun.github.io/solana_kit/
- Package catalog entry: https://openbudgetfun.github.io/solana_kit/reference/package-catalog#solana_kit_transaction_confirmation
- Source code: https://github.com/openbudgetfun/solana_kit/tree/main/packages/solana_kit_transaction_confirmation
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:
createBlockHeightExceedencePromiseFactorydetects block-height expiry.createNonceInvalidationPromiseFactorydetects durable nonce invalidation.createRecentSignatureConfirmationPromiseFactorycombines signature notifications with an initial status lookup.getTimeoutPromiseadds a wall-clock deadline.raceStrategiescombines 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
mdtto keep package guidance aligned. - After updating shared docs templates, run
docs:updatefrom 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.