Skip to content

initiateMNTWithdrawal

Initiates a MNT withdrawal on an L2 to the L1.

Internally performs a contract write to the withdraw function on the Mantle L2StandardBridge predeploy contract.

Usage

example.ts
import { mantle } from '@mantleio/viem'
import { account, walletClientL2 } from './config'
 
const hash = await walletClientL2.initiateMNTWithdrawal({
  account,
  request: {
    amount: parseEther('1'),
  },
})

Returns

Hash

The L2 Transaction hash.

Parameters

account

  • Type: Account | Address

The Account to send the transaction from.

Accepts a JSON-RPC Account or Local Account (Private Key, etc).

const hash = await client.initiateMNTWithdrawal({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', 
  request: {
    amount: parseEther('1'),
  },
  targetChain: mantle,
})

args.amount

  • Type: bigint

Amount in wei to MNT withdrawal from the L2 to the L1. Debited from the caller's L2 balance.

const hash = await client.initiateMNTWithdrawal({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  request: {
    amount: parseEther('1'), 
  },
})

args.to (optional)

  • Type: Address

L1 Transaction recipient.

const hash = await client.initiateMNTWithdrawal({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  request: {
    amount: parseEther('1'),
    to: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', 
  },
  targetChain: mantle,
})

chain (optional)

  • Type: Chain
  • Default: client.chain

The L2 chain. If there is a mismatch between the wallet's current chain & this chain, an error will be thrown.

import { mantle } from '@mantleio/viem/chains'
 
const hash = await client.initiateMNTWithdrawal({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  request: {
    amount: parseEther('1'),
  },
  chain: mantle, 
})

maxFeePerGas (optional)

  • Type: bigint

Total fee per gas (in wei), inclusive of maxPriorityFeePerGas.

const hash = await client.initiateMNTWithdrawal({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  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 hash = await client.initiateMNTWithdrawal({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  request: {
    amount: parseEther('1'),
  },
  maxFeePerGas: parseGwei('20'),
  maxPriorityFeePerGas: parseGwei('2'), 
})

nonce (optional)

  • Type: number

Unique number identifying this transaction.

const hash = await client.initiateMNTWithdrawal({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  request: {
    amount: parseEther('1'),
  },
  nonce: 69, 
})