@@ -160,6 +160,58 @@ type TransactionCall struct {
160160 * gethTypes.Transaction
161161}
162162
163+ func (tc TransactionCall ) GasPrice () * big.Int {
164+ // EIP-1559 introduced a new fee model in Ethereum that replaces the
165+ // legacy `GasPrice` with `MaxFeePerGas` and `MaxPriorityFeePerGas`.
166+ // However, many Ethereum tools and wallets (such as MetaMask, Hardhat, etc.)
167+ // still rely on reading `GasPrice`, even if it’s not explicitly set.
168+ //
169+ // When a user submits an EIP-1559 transaction type, `GasPrice` is not
170+ // specified, Ethereum nodes typically return the current `BaseFeePerGas`
171+ // as the effective `GasPrice` for compatibility reasons.
172+ //
173+ // This behavior is mirrored here in Flow EVM Gateway: if `GasPrice` is zero,
174+ // we return the configured `BaseFeePerGas` to satisfy the expectations of
175+ // these tools.
176+ //
177+ // This does NOT affect Flow’s actual transaction fee calculation,
178+ // this is purely for compatibility.
179+ if tc .Transaction .GasPrice ().Sign () == 0 {
180+ return BaseFeePerGas
181+ }
182+ return tc .Transaction .GasPrice ()
183+ }
184+
185+ func (tc TransactionCall ) GasFeeCap () * big.Int {
186+ // `GasFeeCap` represents the `MaxFeePerGas` in EIP-1559, the maximum fee
187+ // a user is willing to pay. Ethereum clients expect a non-zero value when
188+ // calculating effective gas prices for compatibility.
189+ //
190+ // If the user does not provide a value (zero), this method returns the
191+ // configured `BaseFeePerGas` to avoid confusion and comply with expected
192+ // EVM behavior. This ensures Ethereum tooling can still function correctly
193+ // when interacting with Flow EVM.
194+ if tc .Transaction .GasFeeCap ().Sign () == 0 {
195+ return BaseFeePerGas
196+ }
197+ return tc .Transaction .GasFeeCap ()
198+ }
199+
200+ func (tc TransactionCall ) GasTipCap () * big.Int {
201+ // `GasTipCap` represents the `MaxPriorityFeePerGas` in EIP-1559, the optional
202+ // "tip" to incentivize block inclusion. Ethereum expects this value to be
203+ // explicitly defined or it defaults to something reasonable like the base fee.
204+ //
205+ // To satisfy Ethereum clients and maintain expected behavior, when this value
206+ // is zero, Flow EVM returns the configured `BaseFeePerGas` as a safe default.
207+ // This ensures Ethereum tools can continue to compute `EffectiveGasPrice`
208+ // without errors.
209+ if tc .Transaction .GasTipCap ().Sign () == 0 {
210+ return BaseFeePerGas
211+ }
212+ return tc .Transaction .GasTipCap ()
213+ }
214+
163215func (tc TransactionCall ) Hash () common.Hash {
164216 return tc .Transaction .Hash ()
165217}
@@ -246,7 +298,11 @@ func decodeTransactionEvent(event cadence.Event) (
246298 err ,
247299 )
248300 }
249- receipt .EffectiveGasPrice = gethTx .EffectiveGasTipValue (nil )
301+ if gethTx .GasPrice ().Sign () == 0 {
302+ receipt .EffectiveGasPrice = BaseFeePerGas
303+ } else {
304+ receipt .EffectiveGasPrice = gethTx .EffectiveGasTipValue (nil )
305+ }
250306 tx = TransactionCall {Transaction : gethTx }
251307 }
252308
0 commit comments