calculateFeePerByte static method

Future<int> calculateFeePerByte(
  1. RawTransaction transaction,
  2. int suggestedFeePerByte
)

Calculate the total fee for a transaction. This value is multiplied by the estimated size of the transaction in bytes to determine the total transaction fee.

If the result is less than the minimum fee, the minimum fee is used instead.

Implementation

static Future<int> calculateFeePerByte(
    RawTransaction transaction, int suggestedFeePerByte) async {
  final transactionSize = await estimateTransactionSize(transaction);
  var transactionFee = suggestedFeePerByte * transactionSize;

  // Check min fee
  if (transactionFee < RawTransaction.MIN_TX_FEE_UALGOS) {
    transactionFee = RawTransaction.MIN_TX_FEE_UALGOS;
  }

  return transactionFee;
}