56 releases (35 major breaking)

new 37.0.0 Jul 18, 2024
36.0.0 Jul 12, 2024
35.0.0 Jun 21, 2024
34.0.0 May 23, 2024
2.0.0-alpha.5 Mar 24, 2020

#1337 in Magic Beans

Download history 3350/week @ 2024-03-28 3974/week @ 2024-04-04 3822/week @ 2024-04-11 3281/week @ 2024-04-18 3747/week @ 2024-04-25 3069/week @ 2024-05-02 2784/week @ 2024-05-09 3092/week @ 2024-05-16 3522/week @ 2024-05-23 3636/week @ 2024-05-30 3050/week @ 2024-06-06 2553/week @ 2024-06-13 3766/week @ 2024-06-20 2786/week @ 2024-06-27 1276/week @ 2024-07-04 2876/week @ 2024-07-11

10,986 downloads per month
Used in 120 crates (43 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


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

~18–32MB
~539K SLoC