2

My understanding is that there is a configurable base fee which is the minimum amount that a user pays for ANY transaction.

Is there a way to add an additional base fee per extrinsic? This fee should be unrelated to the weight fee of the extrinsic.

1 Answer 1

2

The easiest way to achieve this would be to modify your WeightToFee implementation.

Note, you will probably depend on this PR being merged before you can easily do this.

But in general, there is a function which we expect the user to implement which describes how we convert some Weight of an extrinsic into a "free" which is some Balance.

In this case, you can create a custom WeightToFee function which always adds an additional amount of fee on top of any inputted Weight.

So something like:

/// Implementor of `WeightToFee` that maps one unit of weight
/// to one unit of fee, and always adds an extra `E` fee on top.
pub struct IdentityFeeWithConstantExtra<T, E>(sp_std::marker::PhantomData<(T, E)>);

impl<T, E> WeightToFee for IdentityFeeWithConstantExtra<T, E>
where
    T: BaseArithmetic + From<u32> + Copy + Unsigned,
    E: Get<T>,
{
    type Balance = T;

    fn weight_to_fee(weight: &Weight) -> Self::Balance {
        let base = Self::Balance::saturated_from(*weight);
        base.saturating_add(E::get())
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.