@@ -225,11 +225,56 @@ func NewRPCTransaction(
225
225
} else {
226
226
result .GasPrice = (* hexutil .Big )(tx .GasFeeCap ())
227
227
}
228
+
229
+ case ethtypes .BlobTxType :
230
+ al := tx .AccessList ()
231
+ yparity := hexutil .Uint64 (v .Sign ())
232
+ result .Accesses = & al
233
+ result .ChainID = (* hexutil .Big )(tx .ChainId ())
234
+ result .YParity = & yparity
235
+ result .GasFeeCap = (* hexutil .Big )(tx .GasFeeCap ())
236
+ result .GasTipCap = (* hexutil .Big )(tx .GasTipCap ())
237
+ // if the transaction has been mined, compute the effective gas price
238
+ if baseFee != nil && blockHash != (common.Hash {}) {
239
+ result .GasPrice = (* hexutil .Big )(effectiveGasPrice (tx , baseFee ))
240
+ } else {
241
+ result .GasPrice = (* hexutil .Big )(tx .GasFeeCap ())
242
+ }
243
+ result .MaxFeePerBlobGas = (* hexutil .Big )(tx .BlobGasFeeCap ())
244
+ result .BlobVersionedHashes = tx .BlobHashes ()
245
+
246
+ case ethtypes .SetCodeTxType :
247
+ al := tx .AccessList ()
248
+ yparity := hexutil .Uint64 (v .Sign ())
249
+ result .Accesses = & al
250
+ result .ChainID = (* hexutil .Big )(tx .ChainId ())
251
+ result .YParity = & yparity
252
+ result .GasFeeCap = (* hexutil .Big )(tx .GasFeeCap ())
253
+ result .GasTipCap = (* hexutil .Big )(tx .GasTipCap ())
254
+ // if the transaction has been mined, compute the effective gas price
255
+ if baseFee != nil && blockHash != (common.Hash {}) {
256
+ result .GasPrice = (* hexutil .Big )(effectiveGasPrice (tx , baseFee ))
257
+ } else {
258
+ result .GasPrice = (* hexutil .Big )(tx .GasFeeCap ())
259
+ }
260
+ result .AuthorizationList = tx .SetCodeAuthorizations ()
228
261
}
229
262
230
263
return result , nil
231
264
}
232
265
266
+ // effectiveGasPrice computes the transaction gas fee, based on the given basefee value.
267
+ //
268
+ // price = min(gasTipCap + baseFee, gasFeeCap)
269
+ func effectiveGasPrice (tx * ethtypes.Transaction , baseFee * big.Int ) * big.Int {
270
+ fee := tx .GasTipCap ()
271
+ fee = fee .Add (fee , baseFee )
272
+ if tx .GasFeeCapIntCmp (fee ) < 0 {
273
+ return tx .GasFeeCap ()
274
+ }
275
+ return fee
276
+ }
277
+
233
278
// BaseFeeFromEvents parses the feemarket basefee from cosmos events
234
279
func BaseFeeFromEvents (events []abci.Event ) * big.Int {
235
280
for _ , event := range events {
0 commit comments