Transaction fees act as a reward for the miner. The fees are enforced by the consensus model. The transaction fee can be voted up or down through fee voting.
For every transaction, 50% of the fee isn't awarded and thus effectively taken out of circulation (aka burned). The remaining fee is split up among the current leader, and the next elected node at a ratio of 2:3.
The fee is distributed 20% to the leader, 30% to the next one, and 50% is burned. For more information, read about the NG consensus algorithm.
Normally the fee is automatically deducted from the sender's address. With sponsored accounts, it's possible for a third party to pay for all transaction fees of an account.
If the sponsor has insufficient funds, the fee is deducted from the sender's account. This prevents a third party to disable an account through a dummy sponsorship.
If an account has multiple sponsors, it works as last in first out. If the most recently added sponsor has insufficient funds, the next sponsor is tried, this continues until the sender's account is charged for the fee.
By default the account that signs the transaction also pays the transaction fees. It's possible for a different account to pay the fee instead this account needs to co-sign the transaction and add it as proof.
This is a zero-anchor transaction to register
did:lto:3Jq8mnhRquuXCiFUwTLZFVSzmQt3Fu6F7HQ. The transaction fee is paid by account
The account that sponsors a transaction, can be a sponsored account. In that case, the fee will be paid by the account's sponsor.
Sponsoring transactions is intended for accounts that don't hold any tokens. Beware that the sponsor isn't part of the binary message that's signed. This means that a malicious node could remove the signature of the sponsor, forcing the transaction to be paid by the sender.