Hooks
The fees module implements one transaction hook from the x/evm
module in order to distribute fees between developers and validators.
EVM Hook
A PostTxProcessing
EVM hook executes custom logic after each successful EVM transaction. All fees paid by a user for transaction execution are sent to the FeeCollector
module account during the AnteHandler
execution before being distributed to developers and validators.
If the x/feesplit
module is disabled or the EVM transaction targets an unregistered contract, the EVM hook returns nil
, without performing any actions. In this case, 100% of the transaction fees remain in the FeeCollector
module, to be distributed to the block proposer.
If the x/feesplit
module is enabled and a EVM transaction targets a registered contract, the EVM hook sends a percentage of the transaction fees (paid by the user) to the withdraw address set for that contract, or to the contract deployer.
User submits EVM transaction (
MsgEthereumTx
) to a smart contract and transaction is executed successfullyCheck if
fees module is enabled
smart contract is registered to receive fees
Calculate developer fees according to the
DeveloperShares
parameter. The initial transaction message includes the gas price paid by the user and the transaction receipt, which includes the gas used by the transaction.
4. Transfer developer fee from the FeeCollector
(Cosmos SDK auth
module account) to the registered withdraw address for that contract. If there is no withdraw address, fees are sent to contract deployer's address.
5. Distribute the remaining amount in the FeeCollector
to validators according to the SDK Distribution Scheme.