Whenever I submit an extrinsic, there's a small transaction fee applied to the sender. Where does it go to?
1 Answer
The transaction-fee pallet handles calculating and transferring the transaction fees. It supports a configurable output by implementing the OnUnbalanced
trait.
For Polkadot and Kusama, 80% of the transaction fees go to the treasury, and 20% go to the block producer. This does not include tips, which are 100% sent to the block author.
That logic can be found here: https://github.com/paritytech/polkadot/blob/master/runtime/common/src/impls.rs#L38
pub struct DealWithFees<R>(sp_std::marker::PhantomData<R>);
impl<R> OnUnbalanced<NegativeImbalance<R>> for DealWithFees<R>
where
R: pallet_balances::Config + pallet_treasury::Config + pallet_authorship::Config,
pallet_treasury::Pallet<R>: OnUnbalanced<NegativeImbalance<R>>,
<R as frame_system::Config>::AccountId: From<primitives::v1::AccountId>,
<R as frame_system::Config>::AccountId: Into<primitives::v1::AccountId>,
<R as frame_system::Config>::Event: From<pallet_balances::Event<R>>,
{
fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance<R>>) {
if let Some(fees) = fees_then_tips.next() {
// for fees, 80% to treasury, 20% to author
let mut split = fees.ration(80, 20);
if let Some(tips) = fees_then_tips.next() {
// for tips, if any, 100% to author
tips.merge_into(&mut split.1);
}
use pallet_treasury::Pallet as Treasury;
<Treasury<R> as OnUnbalanced<_>>::on_unbalanced(split.0);
<ToAuthor<R> as OnUnbalanced<_>>::on_unbalanced(split.1);
}
}
}
But, as with all things Substrate, you are welcome to configure this yourself to whatever behavior you want!