estimateInitiateMNTWithdrawalFee
Estimates the total fee (L1 data fee + L2 execution fee + operator fee) required to initiate an MNT withdrawal on the L2. The fee is computed by Mantle's eth_estimateTotalFee RPC method against the L2 bridge call.
Usage
example.ts
import { parseEther } from 'viem'
import { account, publicClientL2 } from './config'
const fee = await publicClientL2.estimateInitiateMNTWithdrawalFee({
account,
request: {
amount: parseEther('1'),
},
})Returns
bigint
The total fee (in wei) to initiate the withdrawal on the L2.
Parameters
account
- Type:
Account | Address
The Account to estimate the fee from.
Accepts a JSON-RPC Account or Local Account (Private Key, etc).
const fee = await publicClientL2.estimateInitiateMNTWithdrawalFee({
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
request: {
amount: parseEther('1'),
},
})request.amount
- Type:
bigint
The amount of MNT (in wei) to withdraw.
const fee = await publicClientL2.estimateInitiateMNTWithdrawalFee({
account,
request: {
amount: parseEther('1'),
},
})request.to (optional)
- Type:
Address - Default: the
accountaddress.
The L1 recipient of the withdrawn MNT.
const fee = await publicClientL2.estimateInitiateMNTWithdrawalFee({
account,
request: {
amount: parseEther('1'),
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
},
})gas (optional)
- Type:
bigint
Gas limit for transaction execution on the L2.
const fee = await publicClientL2.estimateInitiateMNTWithdrawalFee({
account,
request: { amount: parseEther('1') },
gas: 21000n,
})maxFeePerGas (optional)
- Type:
bigint
Total fee per gas (in wei), inclusive of maxPriorityFeePerGas.
const fee = await publicClientL2.estimateInitiateMNTWithdrawalFee({
account,
request: { amount: parseEther('1') },
maxFeePerGas: parseGwei('20'),
})maxPriorityFeePerGas (optional)
- Type:
bigint
Max priority fee per gas (in wei). Only applies to EIP-1559 Transactions.
const fee = await publicClientL2.estimateInitiateMNTWithdrawalFee({
account,
request: { amount: parseEther('1') },
maxFeePerGas: parseGwei('20'),
maxPriorityFeePerGas: parseGwei('2'),
})nonce (optional)
- Type:
number
Unique number identifying this transaction.
const fee = await publicClientL2.estimateInitiateMNTWithdrawalFee({
account,
request: { amount: parseEther('1') },
nonce: 69,
})