Skip to content

depositMNT

Initiates a MNT deposit transaction on an L1, which executes a transaction on an L2.

Internally performs a contract write to the depositMNT function on the Mantle L1StandardBridge contract.

Usage

example.ts
import { mantle } from '@mantleio/viem/chains'
import { mantle } from 'viem'
import { account, walletClientL1 } from './config'
 
// User might need to update allowance for first time deposit.
const approvalHash = await walletClientL1.writeContract({
  account,
  address: "0x3c3a81e81dc49a522a592e7622a7e711c06bf354", //L1 MNT
  abi:erc20Abi,
  functionName:'approve',
  args:[mantle.contracts.l1StandardBridge[1].address,parseEther('1')]
})
 
const hash = await walletClientL1.depositMNT({
  account,
  request: {
    amount: parseEther('1'),
  },
  targetChain: mantle,
})

Returns

Hash

The L1 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.depositMNT({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', 
  request: {
    amount: parseEther('1'),
  },
  targetChain: mantle,
})

args.amount

  • Type: bigint

Value in wei sent with this MNT deposit transaction on the L2. Debited from the caller's L2 balance.

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

args.to (optional)

  • Type: Address

L2 Transaction recipient.

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

targetChain

The L2 chain to execute the transaction on.

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

chain (optional)

  • Type: Chain
  • Default: client.chain

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

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

gas (optional)

  • Type: bigint

Gas limit for transaction execution on the L1.

const hash = await client.depositMNT({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  request: {
    amount: parseEther('1'),
  },
  gas: 420_000n, 
  chain: mainnet,
  targetChain: mantle,
})

maxFeePerGas (optional)

  • Type: bigint

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

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

maxPriorityFeePerGas (optional)

  • Type: bigint

Max priority fee per gas (in wei). Only applies to EIP-1559 Transactions

const hash = await client.depositMNT({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  request: {
    amount: parseEther('1'),
  },
  maxFeePerGas: parseGwei('20'),
  maxPriorityFeePerGas: parseGwei('2'), 
  targetChain: mantle,
})

nonce (optional)

  • Type: number

Unique number identifying this transaction.

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