53 releases (33 major breaking)

new 35.0.0 Jun 21, 2024
34.0.0 May 23, 2024
33.0.0 Apr 30, 2024
32.0.0 Apr 8, 2024
2.0.0-alpha.5 Mar 24, 2020

#1310 in Magic Beans

Download history 2886/week @ 2024-03-04 2480/week @ 2024-03-11 3521/week @ 2024-03-18 3195/week @ 2024-03-25 3471/week @ 2024-04-01 4014/week @ 2024-04-08 4037/week @ 2024-04-15 3281/week @ 2024-04-22 3265/week @ 2024-04-29 2978/week @ 2024-05-06 3063/week @ 2024-05-13 3304/week @ 2024-05-20 3644/week @ 2024-05-27 3601/week @ 2024-06-03 2552/week @ 2024-06-10 2606/week @ 2024-06-17

12,521 downloads per month
Used in 119 crates (42 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

~17–32MB
~541K SLoC