Transaction Fees on L2

How transaction fees are calculated on Mantle Network

Mantle v2 Tectonic has been released, please move to the new documentation!

Understanding Fee Basics

Transaction fees on Mantle Network work similar to fees on Ethereum. As Mantle network is a Layer 2 (L2) blockchain, there are new paradigms in the fee structure that cause it to differ from Ethereum's fee.

Since Mantle Network is constantly perfecting EVM compatibility, dApps can conveniently handle any changes with minor modifications. Let's take a look at the two sources of transaction costs on Mantle.

  1. The L2 transaction fee for Layer-2 execution

  2. The L1 rollup fee to cover the cost of publishing rollup state roots to L1 (divided equally among users whose transactions were included in the rollup batch)

The estimateGas API currently only returns L2 gas cost. The L1 gas estimate needs to be calculated separately. We will support fetching the total L1+L2 gas estimate through the estimateGas interface in a future network update.

The L2 Transaction Fee

Just like Ethereum, transactions on Mantle network have to pay gas for the amount of computation and storage that they use. Every L2 transaction will pay some execution fee, equal to the amount of gas used by the transaction multiplied by the gas price attached to the transaction.

Here's the (simple) math:

L2ExecutionFee = L2GasPrice * L2GasUsed

The amount of L2 gas used depends on the particular transaction that you're trying to send. Thanks to EVM compatibility, transactions typically use approximately the same amount of gas on Mantle Network as they do on Ethereum. Gas prices fluctuate with time and congestion, but you can always check the current estimated L2 gas price on the public Mantle dashboard. Also, since gas fees on L2 Mantle Network are charged in $MNT, it means at the same gas price the transaction cost incurred will still be significantly lower than other L2 networks that use $ETH as the gas token.

The L1 Rollup Fee

All the state roots that are generated on L2 as result of transaction execution are published to Ethereum. This step is crucial to the security properties of Mantle because it means that all of the most up-to-date block data from L2 Mantle Network that you need to sync a node is always publicly available on L1 Ethereum.

With the EigenDA-powered Mantle DA module online with Mantle Mainnet, only state roots and a limited amount of necessary transaction data are sent to L1, while the transaction batch data is posted to the DA network. For dApps with high gas consumption, they can be executed at the same cost as an ordinary transaction (like a transfer), and the L1 fee will not increase with the complexity of L2 transaction execution. As a result, for transactions with high complexity, this can even save upto ~70% of the cost compared to the original L1 rollup fee.

Mantle publishes rollup states and some necessary transaction data to Ethereum by packaging transactions into batches, and the amount of $ETH spent during this process will be divided among the users whose transactions were included in the batch. The cost-per-user is significantly cheaper than it would be if the transactions were executed on L1. The L1 rollup fee is calculated from the following sub-factors:

  1. The current gas price on Ethereum.

  2. A fixed overhead (auto-adjusted and set into gas oracle)

  3. The scaling factor (currently set to 1)

  4. The $ETH to $MNT conversion ratio

Here's the math:

L1RollupFee = L1GasPrice * Overhead * Ratio

The transaction fees incurred by users is calculated and deducted as described below:

  1. A connection is made to the RPC and the EstimateGas method is called to calculate the gas cost on L2 (if you use a wallet, such as MetaMask, this step will be executed automatically). This is the L2 Transaction Fee.

  2. A transaction is signed and submitted

  3. Mantle node receives the transaction and checks if the account balance is sufficient, including the L2 Transaction Fee and L1 Rollup Fee*.

  4. The transaction is executed successfully, recording your interaction with Mantle Network.

*Note that there is currently no RPC interface that provides accurate estimates of L1 Rollup Fee, please ensure that wallets have sufficient balance, even though the amount needed is generally very small.

Keep in Mind

Sending Transactions

Since Mantle supports Ethereum's JSON RPC interface, you can use the eth_gasPrice method to obtain recommended L2 gas price values. Similarly, you can use eth_estimateGas to estimate your L2 gas usage.

Gas Price Updates

Gas prices on L2 are set to 0.05 Gwei by default, it will be updated every once in a while with reference to the recent blocks on Ethereum.

EIP-1559 Support

Currently, Mantle Network does NOT support EIP-1559, so we recommend using legacy structuring for your transactions. The order of transactions is FIFO, and it will be executed based on the sequence (time of receiving) they are received in.

Displaying Fees to Users

You can use the RPC method eth_getTransactionReceipt to obtain the fees for a particular transaction, where the L1 Rollup Fee portion is listed as the field l1fee.

Estimating the Total Fee

You can estimate the total fee by combining your estimates for the L2 execution fee and L1 data fee.

Common RPC Errors

Insufficient Funds

Error code: -32000

Error message: invalid transaction: insufficient funds for l1Fee + l2Fee + value

You'll get this error when the account's $MNT balance is not enough to cover the transaction fee and the transfer amount. Check the account balance to ensure that the minimum amount requirements are met.

Gas Price Too Low

Error code: -32000

Error message: gas price too low: X wei, use at least tx.gasPrice = Y wei

This is a custom RPC error that Mantle network returns when a transaction is rejected because the set gas price is too low. Currently, at least 0.05 Gwei is required, which can be obtained from the GasOracle contract 0x420000000000000000000000000000000000000F

Gas Price Too High

Error code: -32000

Error message: gas price too high: X wei, use at most tx.gasPrice = Y wei

This is a custom RPC error that Mantle network returns when a transaction is rejected because the set gas price is too high. Currently limit is set at 200 Gwei.

Last updated