57 releases (36 major breaking)

38.0.0 Sep 26, 2024
37.0.0 Jul 18, 2024
36.0.0 Jul 12, 2024
35.0.0 Jun 21, 2024
2.0.0-alpha.5 Mar 24, 2020

#1 in #fee

Download history 2915/week @ 2024-07-21 2978/week @ 2024-07-28 2786/week @ 2024-08-04 3749/week @ 2024-08-11 3672/week @ 2024-08-18 3296/week @ 2024-08-25 2555/week @ 2024-09-01 2981/week @ 2024-09-08 3253/week @ 2024-09-15 4221/week @ 2024-09-22 3866/week @ 2024-09-29 2671/week @ 2024-10-06 3476/week @ 2024-10-13 4588/week @ 2024-10-20 4352/week @ 2024-10-27 5149/week @ 2024-11-03

17,795 downloads per month
Used in 135 crates (46 directly)

Apache-2.0

2.5MB
44K SLoC

Transaction Payment Pallet

This pallet provides the basic logic needed to pay the absolute minimum amount needed for a transaction to be included. This includes:

  • weight fee: A fee proportional to amount of weight a transaction consumes.
  • length fee: A fee proportional to the encoded length of the transaction.
  • tip: An optional tip. Tip increases the priority of the transaction, giving it a higher chance to be included by the transaction queue.

Additionally, this pallet allows one to configure:

  • The mapping between one unit of weight to one unit of fee via Config::WeightToFee.
  • A means of updating the fee for the next block, via defining a multiplier, based on the final state of the chain at the end of the previous block. This can be configured via Config::FeeMultiplierUpdate

License: Apache-2.0

Release

Polkadot SDK stable2409


lib.rs:

Transaction Payment Pallet

This pallet provides the basic logic needed to pay the absolute minimum amount needed for a transaction to be included. This includes:

  • base fee: This is the minimum amount a user pays for a transaction. It is declared as a base weight in the runtime and converted to a fee using WeightToFee.
  • weight fee: A fee proportional to amount of weight a transaction consumes.
  • length fee: A fee proportional to the encoded length of the transaction.
  • tip: An optional tip. Tip increases the priority of the transaction, giving it a higher chance to be included by the transaction queue.

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 + [targeted_fee_adjustment * weight_fee];
final_fee = inclusion_fee + tip;
  • targeted_fee_adjustment: This is a multiplier that can tune the final fee based on the congestion of the network.

Additionally, this pallet allows one to configure:

Dependencies

~17–31MB
~514K SLoC