2

Is there a way to send tx fees of a pallet to an account? Like transactions fees of pallet X is send to an account. We can split the global tx fees between treasury and other but we want to do it as a per pallet basis.

1 Answer 1

4

This is definitely possible, but will require some of your own design and elbow grease to make work.

Specifically, you should look at the trait OnChargeTransaction: https://paritytech.github.io/substrate/master/pallet_transaction_payment/trait.OnChargeTransaction.html

You can see that withdraw_fee has a call input:

fn withdraw_fee(
    who: &T::AccountId,
    call: &T::RuntimeCall,
    dispatch_info: &DispatchInfoOf<T::RuntimeCall>,
    fee: Self::Balance,
    tip: Self::Balance
) -> Result<Self::LiquidityInfo, TransactionValidityError>;

With this, you should be able to see what call is triggering a fee payment to occur. When implementing this trait, you can have a match statement which detects which call is being executed, and then have special logic to handle the fees of that call.

Beyond this, you could also just design a specific fee system for specific pallets, since each pallet has full access to manipulate the balance of a user. There would be no need to touch the transaction fee pallet in this case, however these "extra" fees may be opaque to a user who is not aware of this.

1
  • Thank you Shawn.
    – Dubs
    Nov 15, 2022 at 9:31

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.