estimateOperatorFee
Estimates the operator fee to execute an L2 transaction.
The operator fee is part of the Isthmus upgrade and allows OP Stack operators to recover costs related to Alt-DA, ZK proving, or custom gas tokens. Returns 0 for pre-Isthmus chains or when operator fee functions don't exist.
The fee is calculated using the formula: operatorFee = operatorFeeConstant + operatorFeeScalar * gasUsed / 1e6
Usage
import { account, publicClient } from './config'
const fee = await publicClient.estimateOperatorFee({
account,
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1')
})Returns
bigint
The operator fee (in wei).
Parameters
account
- Type:
Account | Address
The Account to estimate fee from.
Accepts a JSON-RPC Account or Local Account (Private Key, etc).
const fee = await publicClient.estimateOperatorFee({
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1')
})data (optional)
- Type:
0x${string}
Contract code or a hashed method call with encoded args.
const fee = await publicClient.estimateOperatorFee({
data: '0x...',
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1')
})l1BlockAddress (optional)
- Type:
Address
Address of the L1Block predeploy contract.
const fee = await publicClient.estimateOperatorFee({
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
l1BlockAddress: '0x4200000000000000000000000000000000000015',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1')
})maxFeePerGas (optional)
- Type:
bigint
Total fee per gas (in wei), inclusive of maxPriorityFeePerGas.
const fee = await publicClient.estimateOperatorFee({
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
maxFeePerGas: parseGwei('20'),
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1')
})maxPriorityFeePerGas (optional)
- Type:
bigint
Max priority fee per gas (in wei).
const fee = await publicClient.estimateOperatorFee({
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
maxFeePerGas: parseGwei('20'),
maxPriorityFeePerGas: parseGwei('2'),
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1')
})nonce (optional)
- Type:
number
Unique number identifying this transaction.
const fee = await publicClient.estimateOperatorFee({
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
maxFeePerGas: parseGwei('20'),
maxPriorityFeePerGas: parseGwei('2'),
nonce: 69,
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1')
})to (optional)
- Type:
Address
Transaction recipient.
const fee = await publicClient.estimateOperatorFee({
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1')
})value (optional)
- Type:
bigint
Value (in wei) sent with this transaction.
const fee = await publicClient.estimateOperatorFee({
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1')
})