1

I created a new frontier node template with frontier. During each interaction I pay a gas fee, my question is where this gas fee is deposited and can it be collected by the validator ?

2 Answers 2

1

The Transaction Payment Pallet is the pallet that provides the basic logic needed to pay the fees.

In the Config of the pallet you can configure how the fees are paid via Config::OnChargeTransaction. Take a look about it configuration of this pallet in the frontier node template here:

type OnChargeTransaction = CurrencyAdapter<Balances, ()>;

You have to implement yourself how you want to deal with the fees. A good idea is take a look of some implementations, a couple interesting I'd suggest you to look at are:

  • Polkadot. It has a configuration for fees that splits 80% to treasury and 20% to author. Check here how is the configuration of the Transaction Payment Pallet:
    type OnChargeTransaction = CurrencyAdapter<Balances, DealWithFees<Runtime>>;

And the implementation of DealWithFees that defines how to deal with the fees.

  • Rococo (Polkadot testnet), sends the fees to the author of the block. Check here how is its configuration of the Transaction Payment Pallet.
    type OnChargeTransaction = CurrencyAdapter<Balances, ToAuthor<Runtime>>;

And the implementation of ToAuthor that sends the fees to the author of the block.

1

When using frontier, you are mostly dealing with configurations of the various pallets, in this case, pallet-evm and maybe pallet-base-fee.

In addition to Alex's answer, the following may help provide you clarity:

pub struct EVMTransactionChargeHandler<OU>(PhantomData<OU>);
impl<OU> pallet_evm::OnChargeEVMTransaction for EVMTransactionChargeHandler<OU> {
  ...
}

This would be the currency adapter mentioned previously, as stated in the document for the trait: https://paritytech.github.io/frontier/rustdocs/pallet_evm/trait.OnChargeEVMTransaction.html

In the trait implementation you can put custom logic, for instance, what to do on_unbalanced. You can use https://paritytech.github.io/frontier/rustdocs/pallet_evm/struct.EVMCurrencyAdapter.html as a reference.

Note the generic arg <OU> which stands for the Imbalance handler. This is something that knows what to do with the NegativeImbalance that's generated on fee withdrawal. By providing an implementation for OnUnbalanced<NegativeImbalance<_>> you can determine what will ultimately be done with the fees collected. (i.e. whether it will go to a validator, be burned, or something else entirely)

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.