LogoLogo
English
English
  • ⚡Introduction
    • What is Tokamak Network?
    • Vision
    • Whitepaper
  • ⚙️Service Guide
    • Tokamak L2
      • Thanos Stack
        • Introduction
        • Differences Between Ethereum and Thanos Stack
        • Transaction Fee
        • L2 Native Token Bridge
          • Overview
          • Contracts Modifications
          • Deposit & Withdraw Flow
          • Security Considerations
        • Testnet Information
    • Staking & DAO
      • Simple staking
        • Stake
        • Withdraw
        • Staking reward
        • Contract addresses
        • Contract addresses (testnet)
      • Tokamak Network DAO
        • DAO candidates
          • DAO candidate registration
        • Propose
        • Agenda
        • Contract addresses
        • Contract addresses (testnet)
    • Rollup Hub
      • Devnet
        • Parameter Definitions
        • Creating your own rollup Devnet
      • Mainnet Beta
        • Deployment Configuration Parameters
        • Deploy with AWS
          • Introduction
          • Prerequisites
          • Deploy contracts
          • Building AWS infra with terraform
          • Deploy Thanos chain
        • Operation Guide
          • Chain Operators
            • Architecture
            • Node Operations
            • Chain Configurations
          • Developer Tools
            • SDK
              • Bridge ERC-20 tokens with the Thanos SDK
              • Bridge the Native Token with the Thanos SDK
              • Bridge ETH with the Thanos SDK
            • Contracts
            • About USDCBridge
        • Additional Features
          • Mini Bridge
            • Deployment Guide
            • How to use the Mini Bridge?
          • Seigniorage Rewards (Coming Soon)
      • Troubleshooting
    • Faucet (testnet)
  • 📖Information
    • Get TON
    • TON ↔ WTON
    • Glossary
    • Link
  • 😀Get Involved
    • Global Telegram
    • Community Discord
Powered by GitBook
On this page
  • Execution Gas Fee
  • L1 Data Fee
  1. Service Guide
  2. Tokamak L2
  3. Thanos Stack

Transaction Fee

PreviousDifferences Between Ethereum and Thanos StackNextL2 Native Token Bridge

Last updated 4 months ago

It is important to correctly calculate transaction costs before submitting them to the layer 2 based on Thanos Stack. This section explains how to calculate the Execution Gas Fee and L1 Data Fee, two components that make up the total cost of a Thanos Network transaction.

Transaction fees in Thanos are determined by adding the following two components:

  • Execution Gas Fee

  • L1 Data Fee

Tip. The calculation of transaction fees in Thanos Stack is exactly the same as on OP Mainnet. For more information, see the section in the Optimism docs.

Execution Gas Fee

The Execution Gas Fee is exactly the same as the fee paid for the same transaction on Ethereum. This fee is calculated as the amount of gas used by the transaction multiplied by the gas price. Like Ethereum, the Thanos uses EIP-1559. In EIP-1559, the price paid per unit of gas in a transaction is base_fee. If a priority_fee is added, the price per unit of gas becomes base_fee + priority_fee.

The amount of gas used for a transaction in Thanos is exactly the same as the amount of gas used for the same transaction in Ethereum. If a transaction costs 100,000 gas on Ethereum, it also costs 100,000 gas on Thanos.

So you can use the same tools that estimate transaction costs on Ethereum to estimate the total cost of the transaction. You can read more about how gas fees work on Ethereum at .

The Base Fee on OP Mainnet is the minimum gas price required for a transaction to be included in a block, operating like Ethereum's base fee but with slight parameter adjustments for shorter block times. Transactions must set a maximum base fee higher than the block's base fee, but only the block base fee is charged. Priority Fee, an optional additional fee on top of the base fee, allows transactions with higher fees to be prioritized and processed faster by the sequencer. While not mandatory, setting a higher priority fee can improve transaction speed, making it ideal for time-sensitive applications.

L1 Data Fee

The L1 Data Fee is a key difference of the transaction fee compared to the Ethereum transaction fee. This fee is derived from the fact that data for all transactions is submitted on Ethereum. This allows individual nodes to download and execute the transaction data. The L1 Data Fee is determined by the current gas fees on Ethereum, and if Blob support is enabled, it will be based on the current Ethereum Blob data gas price.

Mechanism

The L1 Data Fee is automatically charged for all transactions included in a block. This fee is directly deducted from the address sending the transaction. The exact amount paid depends on the estimated size of the transaction in bytes after compression, the current Ethereum gas price and/or blob gas price, and several other parameters.

The L1 Data Fee is most affected by the Ethereum base fee, which is continuously and trustlessly relayed to layer 2 based on Thanos from Ethereum. The Ethereum blob base fee also influences the fee when the chain is configured to use blobs instead of tx.data. The base fee and blob base fee are updated in Thanos for each Ethereum block and can vary by up to 12.5% between updates. As a result, short-term variations in the L1 Data Fee are typically very small and do not significantly affect average transactions.

Formula

It is the FastLZ compressed size of the signed transaction. This calculation considers the current Ethereum base fee and/or blob base fee (relayed trustlessly from Ethereum). The calculation of the L1 Data Fee begins by estimating the transaction size using a linear model based on the size of the transaction compressed with FastLZ.

estimatedSizeScaled = max(minTransactionSize * 1e6, intercept + fastlzCoef * fastlzSize)

Next, two chain parameters, baseFeeScalar and blobFeeScalar, are used to calculate l1FeeScaled:

l1FeeScaled = baseFeeScalar * l1BaseFee * 16 + blobFeeScalar * l1BlobBaseFee

Both scalars are scaled by 1e6. The final L1 Data Fee is then:

l1Cost = estimatedSizeScaled * l1FeeScaled / 1e12

The model parameters, intercept and fastlzCoef, were determined through a linear regression analysis on previous L2 transaction datasets to minimize the root mean square error of batch size changes when compressed with Brotli. These parameters are fixed. ()

⚙️
Transaction fees on OP Mainnet
Ethereum.org
link