#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

#32 in #tetcore

Download history 20/week @ 2023-12-07 27/week @ 2023-12-14 21/week @ 2023-12-21 10/week @ 2023-12-28 16/week @ 2024-01-04 37/week @ 2024-01-11 15/week @ 2024-01-18 9/week @ 2024-01-25 5/week @ 2024-02-01 21/week @ 2024-02-08 35/week @ 2024-02-15 39/week @ 2024-02-22 49/week @ 2024-02-29 74/week @ 2024-03-07 35/week @ 2024-03-14 33/week @ 2024-03-21

198 downloads per month
Used in 14 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–13MB
~133K SLoC