How gas fees work on FlowEVM?
Revisiting Transaction Fee on Flow​
Transaction fees on Flow are described here in detail, but essentially, the fee is broken down into three components -
Inclusion Fee
- The fee that accounts for the resources required to process a transaction due to the transaction’s core properties (byte size, number of signatures)Execution Fee
- The fee that accounts for the operational cost of running the transaction script, processing the results, sending results for verification, generating verification receipts, etc.Surge'Â factor
- A multiplicative factor to dynamically account for network pressure and market conditions.
Transaction fee = [inclusion fee + (execution effort * unit cost)] x surge
where,
-
Inclusion fee = 1E-6 FLOW This is currently constant.
-
Execution fee is comprised of two components:
- Execution Effort (computation) is a variable based on transaction type and functions/operations that are called during the execution of a transaction. The weights allocated to each function type are based on how “costly” (time consuming) they are. The following specification is used to calculate the execution effort units for a transaction on Flow.
_10Execution effort (computation) =_100.0239 * function_or_loop_call +_100.0123 * GetValue +_100.0117 * SetValue +_1043.2994 * CreateAccount- Unit cost
_10Execution Effort Unit Cost = 4.99E-08Â FLOW (currently constant) -
Surge = 1.0 (currently constant)
Transaction fee on FlowEVM​
With EVM on Flow, EVM operations can now be called within Flow Cadence transactions. EVM operations also have an associated effort measured in gas which needs to be factored into the execution effort calculation in addition to the Flow computation for any FlowEVM transaction.
The revised execution effort formula is,
_10Execution Effort =_10 0.0239 * function_or_loop_call +_10 0.0123 * GetValue +_10 0.0117 * SetValue +_10 43.2994 * CreateAccount +_10 EVMGasUsageCost * EVMGasUsage
where,
EVMGasUsage
is reported by EVM as the cost in gas for executing the transaction within the EVM, for instance, 21K gas for a simple send transaction.EVMGasUsageCost
- To price EVM operations within Flow Cadence, a conversion factor between EVM gas and Flow computation (i.e., execution effort) needs to be defined.EVMGasUsageCost
is that ratio.
We want to avoid changing the weights of the original model, so that we do not change the cost of transactions that do not use the new EVM features. Additionally, no other changes are made to the way the execution effort unit cost, inclusion fee, or surge fee is used to calculate the final transaction fee.
EVMGasUsageCost​
Looking through past EVM contract deployments, a robust estimate is that one Flow Cadence transaction should be able to fit up to 10M gas. For Cresendo Previewnet launch therefore, given the current computation limit on Flow being 9999, we would use the conversion ratio of 1000 gas/computation. Thus EVMGasUsageCost will initially be fixed at 1/1000, but will be open for revision prior to the Mainnet launch and in future.
Example​
Assume a simple hypothetical transaction that makes 2 cadence loop calls, reads 20 bytes from the storage register, saves 20 bytes to the storage register, and is called to create an account
-
function_or_loop_call = 2
-
GetValue = 20
-
SetValue = 20
-
CreateAccount = 1
On Flow Cadence
_10Execution Effort = 0.0239 * (2) + 0.0123 * (20) + 0.0117 * (20) + 43.2994 * 1 + EVMGasUsageCost * EVMGasUsage
But since EVMGasUsage is 0 for a cadence (Flow) transaction,
_10Execution Effort = 43.8272
since
_10Transaction fee = [inclusion fee + (execution effort * unit cost)] x surge
thus
_10Transaction fee = [1E-6 FLOW + (43.8272 * 4.99E-08Â FLOW)] x 1 = 3.19E-06 FLOW
On FlowEVM
If the EVMGasUsage can be assumed to be 21,000 (typical for a simple transfer),
_10Execution Effort = 0.0239 * (2) + 0.0123 * (20) + 0.0117 * (20) + 43.2994 * 1 + 1/1000 * 21000 = 64.8272
thus
_10Transaction fee = [1E-6 FLOW + (64.8272 * 4.99E-08Â FLOW)] x 1 = 4.23E-06 FLOW