50 releases (31 major breaking)

33.0.0 Apr 30, 2024
32.0.0 Apr 8, 2024
31.0.0 Mar 18, 2024
30.0.0 Feb 26, 2024
2.0.0-alpha.5 Mar 24, 2020

#1287 in Magic Beans

Download history 1441/week @ 2024-01-24 1060/week @ 2024-01-31 2331/week @ 2024-02-07 3097/week @ 2024-02-14 3982/week @ 2024-02-21 2951/week @ 2024-02-28 2659/week @ 2024-03-06 2955/week @ 2024-03-13 3589/week @ 2024-03-20 3268/week @ 2024-03-27 3667/week @ 2024-04-03 3908/week @ 2024-04-10 3504/week @ 2024-04-17 3551/week @ 2024-04-24 3134/week @ 2024-05-01 2128/week @ 2024-05-08

13,068 downloads per month
Used in 121 crates (41 directly)

Apache-2.0

2.5MB
43K 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


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

~16–31MB
~516K SLoC