executeTransaction method

Future<SuiTransactionBlockResponse> executeTransaction(
  1. Transaction transaction, {
  2. SuiTransactionBlockResponseOptions? responseOptions,
  3. List<String> additionalSignatures = const [],
})

Builds, signs, and executes transaction, caching the resulting gas coin for the next transaction. On failure the cache is cleared so the next build re-selects gas from the client.

Implementation

Future<SuiTransactionBlockResponse> executeTransaction(
  Transaction transaction, {
  SuiTransactionBlockResponseOptions? responseOptions,
  List<String> additionalSignatures = const [],
}) {
  return _queue.run(() async {
    final bytes = await _build(transaction);
    final signed = signer.keyPair.signTransactionBlock(bytes);

    final options = responseOptions ?? SuiTransactionBlockResponseOptions();
    options.showEffects = true;

    try {
      final response = await client.executeTransactionBlock(signed.bytes, [
        signed.signature,
        ...additionalSignatures,
      ], options: options);
      _cachedGasCoin = gasCoinFromEffects(response);
      return response;
    } catch (_) {
      resetCache();
      rethrow;
    }
  });
}