sendTransactionRaw method

Future<JsonRpcSuccessResponse<TransactionSignature>> sendTransactionRaw(
  1. Transaction transaction, {
  2. SendTransactionConfig? config,
})

Send a Transaction to the cluster for processing.

Implementation

Future<JsonRpcSuccessResponse<TransactionSignature>> sendTransactionRaw(
  Transaction transaction, {
  final SendTransactionConfig? config,
}) async {
  // if (nonceInfo != null) {
  //   transaction.sign(signers);
  // } else {
  //   bool disableCache = false;
  //   for (;;) {
  //     final latestBlockhash = await _blockhashCache.get(this, disabled: disableCache);
  //     transaction = transaction.copyWith(
  //       recentBlockhash: latestBlockhash.blockhash,
  //       lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
  //     );

  //     transaction.sign(signers);
  //     final Uint8List? payerSignature = transaction.signature;
  //     if (payerSignature == null) {
  //       throw const TransactionException('No signature.'); // should never happen
  //     }

  //     final String signature = base64.encode(payerSignature);
  //     if (!_blockhashCache.transactionSignatures.contains(signature)) {
  //       // The signature of this transaction has not been seen before with the current
  //       // [latestBlockhash.blockhash], all done. Let's break
  //       _blockhashCache.transactionSignatures.add(signature);
  //       break;
  //     } else {
  //       // This transaction would be treated as duplicate (its derived signature matched to one of
  //       // the already recorded signatures). So, we must fetch a new blockhash for a different
  //       // signature by disabling our cache not to wait for the cache expiration
  //       // [BlockhashCache.timeout].
  //       disableCache = true;
  //     }
  //   }
  // }

  final defaultConfig =
      config ?? SendTransactionConfig(preflightCommitment: commitment);
  final BufferEncoding bufferEncoding =
      BufferEncoding.fromJson(defaultConfig.encoding.name);
  final String signedTransaction =
      transaction.serialize().getString(bufferEncoding);
  return sendSignedTransactionRaw(signedTransaction, config: config);
}