@@ -52,6 +52,11 @@ import {
5252 type EstimateL1GasReturnType ,
5353 estimateL1Gas ,
5454} from '../actions/estimateL1Gas.js'
55+ import {
56+ type EstimateOperatorFeeParameters ,
57+ type EstimateOperatorFeeReturnType ,
58+ estimateOperatorFee ,
59+ } from '../actions/estimateOperatorFee.js'
5560import {
5661 type EstimateTotalFeeParameters ,
5762 type EstimateTotalFeeReturnType ,
@@ -418,6 +423,34 @@ export type PublicActionsL2<
418423 estimateL1Gas : < chainOverride extends Chain | undefined = undefined > (
419424 parameters : EstimateL1GasParameters < chain , account , chainOverride > ,
420425 ) => Promise < EstimateL1GasReturnType >
426+ /**
427+ * Estimates the operator fee required to execute an L2 transaction.
428+ *
429+ * Returns 0 for pre-Isthmus chains or when operator fee functions don't exist.
430+ *
431+ * @param client - Client to use
432+ * @param parameters - {@link EstimateOperatorFeeParameters}
433+ * @returns The operator fee (in wei). {@link EstimateOperatorFeeReturnType}
434+ *
435+ * @example
436+ * import { createPublicClient, http, parseEther } from 'viem'
437+ * import { optimism } from 'viem/chains'
438+ * import { publicActionsL2 } from 'viem/op-stack'
439+ *
440+ * const client = createPublicClient({
441+ * chain: optimism,
442+ * transport: http(),
443+ * }).extend(publicActionsL2())
444+ *
445+ * const operatorFee = await client.estimateOperatorFee({
446+ * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
447+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
448+ * value: parseEther('1'),
449+ * })
450+ */
451+ estimateOperatorFee : < chainOverride extends Chain | undefined = undefined > (
452+ parameters : EstimateOperatorFeeParameters < chain , account , chainOverride > ,
453+ ) => Promise < EstimateOperatorFeeReturnType >
421454 /**
422455 * Estimates the L1 data fee + L2 fee to execute an L2 transaction.
423456 *
@@ -509,6 +542,7 @@ export function publicActionsL2() {
509542 estimateL1Fee : ( args ) => estimateL1Fee ( client , args ) ,
510543 getL1BaseFee : ( args ) => getL1BaseFee ( client , args ) ,
511544 estimateL1Gas : ( args ) => estimateL1Gas ( client , args ) ,
545+ estimateOperatorFee : ( args ) => estimateOperatorFee ( client , args ) ,
512546 estimateTotalFee : ( args ) => estimateTotalFee ( client , args ) ,
513547 estimateTotalGas : ( args ) => estimateTotalGas ( client , args ) ,
514548 }
0 commit comments