59 releases (36 major breaking)

new 38.0.2 Dec 20, 2024
38.0.0 Sep 26, 2024
37.0.1 Dec 12, 2024
37.0.0 Jul 18, 2024
2.0.0-alpha.5 Mar 24, 2020

#869 in Magic Beans

Download history 2493/week @ 2024-08-30 2913/week @ 2024-09-06 3264/week @ 2024-09-13 3953/week @ 2024-09-20 4110/week @ 2024-09-27 2828/week @ 2024-10-04 3206/week @ 2024-10-11 4642/week @ 2024-10-18 4191/week @ 2024-10-25 5199/week @ 2024-11-01 18408/week @ 2024-11-08 29711/week @ 2024-11-15 29549/week @ 2024-11-22 28508/week @ 2024-11-29 31074/week @ 2024-12-06 25488/week @ 2024-12-13

120,140 downloads per month
Used in 138 crates (47 directly)

Apache-2.0

3MB
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
~513K SLoC