#tetcoin #framework #blockchain #crypto

no-std noble-transaction-payment

FABRIC noble to manage transaction payments

Show the crate…

1 stable release

2.0.0 Apr 4, 2021

#76 in #tetcoin

Download history 41/week @ 2024-03-15 52/week @ 2024-03-22 78/week @ 2024-03-29 40/week @ 2024-04-05 41/week @ 2024-04-12 45/week @ 2024-04-19 47/week @ 2024-04-26 39/week @ 2024-05-03 43/week @ 2024-05-10 39/week @ 2024-05-17 32/week @ 2024-05-24 29/week @ 2024-05-31 25/week @ 2024-06-07 36/week @ 2024-06-14 43/week @ 2024-06-21 17/week @ 2024-06-28

123 downloads per month
Used in 13 crates (7 directly)

Apache-2.0

1MB
25K SLoC

Transaction Payment Module

This module 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 module 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 Module

This module 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 module allows one to configure:

Dependencies

~3–12MB
~134K SLoC