32 releases (18 major breaking)

new 20.0.0 Mar 26, 2023
19.0.0 Mar 5, 2023
18.0.0 Feb 26, 2023
17.0.0 Feb 19, 2023
2.0.0-alpha.5 Mar 24, 2020

#957 in Magic Beans

Download history 1178/week @ 2022-12-06 938/week @ 2022-12-13 881/week @ 2022-12-20 486/week @ 2022-12-27 270/week @ 2023-01-03 797/week @ 2023-01-10 837/week @ 2023-01-17 1282/week @ 2023-01-24 1164/week @ 2023-01-31 369/week @ 2023-02-07 787/week @ 2023-02-14 808/week @ 2023-02-21 608/week @ 2023-02-28 863/week @ 2023-03-07 752/week @ 2023-03-14 572/week @ 2023-03-21

2,960 downloads per month
Used in 10 crates (8 directly)

Apache-2.0

2MB
35K 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:

  • 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]
  • How the fees are paid via [Config::OnChargeTransaction].

Dependencies

~8–43MB
~736K SLoC