1

I'm writing a hook for a pallet, this hook pop Call out of storage and execute them on behalf of a specified user through call.dispatch(origin).

My question is:
Will dispatch will make origin pay the fees associated with this Call?
If yes is that true both in a the context of a hook and in the context of a regular user triggered call causing a call.dispatch to be issued? Who pay for what if the origin of the dispatched call is different from the origin of the original call?

1 Answer 1

3

Will dispatch will make origin pay the fees associated with this Call?

No, only the signer of a transaction will pay fees for it (although there are some PRs in Substrate to make that a bit more flexible, so this answer may change).

When executing a transaction, it goes through a few phases: pre-dispatch, dispatch, and post-dispatch. The fee for the given length/weight is taken in the pre-dispatch phase, and it won't even dispatch if the account cannot pay the fees. Then dispatch happens, and any fee refund/change, if there is some, would happen in post-dispatch. So, dispatch assumes that whatever conditions for dispatch (e.g. a fee, or scheduling by referendum) have already taken place.

5
  • Can you link the PRs that may change this in the future please ? Commented Jun 12, 2022 at 14:20
  • So I have a problem here ! How can I make so that origin pay for the call dispatched in it's name in a hook ? Commented Jun 12, 2022 at 14:34
  • Or in another signed transaction ? Using the pre_dispatch function from the SignedExtension trait maybe ? Commented Jun 12, 2022 at 14:54
  • Seems like yes, by adding type OnChargeTransaction = CurrencyAdapter<Balances, DealWithFees<Runtime>>; to my pallet config ! Commented Jun 12, 2022 at 15:13
  • For example: github.com/paritytech/substrate/pull/11524 Commented Jun 13, 2022 at 15:02

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.