pallet_transaction_payment
Branch/Release: release-polkadot-v1.10.0
Purpose
pallet-transaction-payment
implements transaction fee logic.
In substrate, every transaction has an associated call
, and each call
has its own weight function. The weight function estimates the time it takes to execute the call
.
Config::WeightToFee
is a mapping between the smallest unit of compute (Weight) and smallest unit of fee.
This pallet also exposes
- how to update fees for the next block based on past fees (Config::FeeMultiplierUpdate
)
- how fees are paid (Config::OnChargeTransaction
)
The base fee and adjusted weight and length fees constitute the inclusion fee, which is the minimum fee for a transaction to be included in a block. The formula of final fee:
inclusion_fee = base_fee + length_fee + [fee_multiplier_update * weight_fee];
final_fee = inclusion_fee + tip;
The inputs are defined below in the glossary and config sections.
Config
-
Pallet-specific handlers:
-
OnChargeTransaction
— Handler for withdrawing, refunding and depositing the transaction fee. Type must implement the traitOnChargeTransaction<Self>
. -
FeeMultiplierUpdate
— Handler to define how base fees change over time (over blocks). Type must implement the traitMultiplierUpdate
. Possible assignments includeConstantFee
,SlowAdjustingFee
, andFastAdjustingFee
.
-
-
Pallet-specific converters:
-
WeightToFee
— Mapping between the smallest unit of weight and smallest unit of fee. Type must implement the traitWeightToFee<Balance = BalanceOf<Self>>
. -
LengthToFee
— Convert a length value into a deductible fee based on the currency type. Type must implement the traitWeightToFee<Balance = BalanceOf<Self>>
.
-
-
Pallet-specific constants:
-
OperationalFeeMultiplier
— A fee multiplier forOperational
extrinsics to compute "virtual tip" to boost theirpriority
. Type must implement the traitGet<u32>
.
-
-
Common configs:
-
RuntimeEvent
-
Dispatchables
There are no dispatchables (and no errors) in this pallet. This pallet is only intended to configure the transaction fee logic for a chain.
Events:
-
TransactionFeePaid(who, actual_fee, tip)
— a transaction fee was paid by accountwho
with total amount ofactual_fee + tip
.