Function getExecutionCost

  • Calculates the cost of transaction execution Provides an upper cost of contract-call-related transactions because of gasLimit. Also assumes that oracle query fee is 0 unless it is provided in options.

    The idea is that if you need to show transaction details with some accuracy you can define expense fields that you want to show separately. And to show getExecutionCost result as a fee, subtracting all fields shown separately.

    Parameters

    • transaction: `tx_${string}`

      Transaction to calculate the cost of

    • options: {
          gasUsed?: number;
          innerTx?: "fee-payer" | "freeloader";
          isInitiator?: boolean;
          queryFee?: string;
      } = {}

      Options

      • Optional gasUsed?: number

        Amount of gas actually used to make calculation more accurate

      • Optional innerTx?: "fee-payer" | "freeloader"

        Should be provided if transaction wrapped with Tag.PayingForTx

      • Optional isInitiator?: boolean

        Is transaction signer an initiator of state channel

      • Optional queryFee?: string

        Oracle query fee

    Returns bigint

    Example

    <template>
    Amount: {{ txUnpacked.amount }}
    Name fee: {{ txUnpacked.nameFee }}
    Other fees: {{ getExecutionCost(txEncoded) - txUnpacked.amount - txUnpacked.nameFee }}
    </template>

    Doing this way you won't worry to show wrong fee for a transaction you may not support. Because the SDK calculates the overall price of any transaction on its side.

Generated using TypeDoc