#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

#78 in #tetcoin

Download history 24/week @ 2024-01-06 34/week @ 2024-01-13 15/week @ 2024-01-20 4/week @ 2024-01-27 11/week @ 2024-02-03 25/week @ 2024-02-10 38/week @ 2024-02-17 45/week @ 2024-02-24 36/week @ 2024-03-02 73/week @ 2024-03-09 40/week @ 2024-03-16 56/week @ 2024-03-23 77/week @ 2024-03-30 36/week @ 2024-04-06 48/week @ 2024-04-13 40/week @ 2024-04-20

207 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–12MB
~134K SLoC