Working of gas fees on Arbitrum
Arbitrum is one of the most used Layer 2 solution in the market. We have been diving deeper into the gas fees model for Arbitrum. To understand the gas fees for Arbitrum, we have to do a small deep dive into the working of Layer 2s, and specifically Arbitrum in this case.
Before diving into this, we have to understand a few terms -
Gas - Gas is a unit of measurement for EVM chains that roughly measures the amount of compute resources required on Ethereum. Each basic function on Ethereum has a defined gas requirement, for example sending ETH requires 21,000 gas units. The gas required by an Ethereum transaction is computed by adding the gas required for the different actions during a transaction
Arbitrum transaction cost components
Layer 2s are scaling solutions for Ethereum. And while there are hundreds of definitions of what constitutes a Layer 2 flying around, we define it simply here as a chain that uses the Ethereum consensus to decide the finality of transactions on the chain. This results in fees on Arbitrum being driven by two major components -
Data posting to Ethereum
Arbitrum posts data to Ethereum after every few blocks. The data posted to Ethereum is of two types -
Arbitrum block state - Block state must be included in an Ethereum block which is used as the definition of transaction confirmation by rollups
Transaction data - Transaction data from blocks must be published to be independently verified by any external party. Earlier, Arbitrum used the Ethereum blocks to also publish transaction data, which was costly. The recently implemented EIP-4844 has allowed rollups to post transactions to blobs (a temporary storage) finalised along with Ethereum blocks, which has reduced the cost of publishing transaction data to Ethereum substantially.
Cost component of Arbitrum
The transaction cost of Arbitrum is the net revenue made by the chain. Transaction cost depends on the gas requirement for the transaction as well as the cost per unit gas. Arbitrum sets a minimum cost per unit of gas which increases at times when the demand on Arbitrum is high
Cost per unit gas on Arbitrum (min gas fee limit)
Arbitrum has a target gas amount that is defined by the execution capacity of the chain based on its current configuration. Right now, the target gas for Arbitrum is 7 M gas/sec. Arbitrum has a min base gas fee of 0.01 gwei (1 gwei = 10^-9 ETH) if the gas requirement is below target.
In case the transactions coming on Arbitrum require more than 7 M gas, demand for gas overtakes supply resulting in congestion. In such cases, the rollup increases the base fee exponentially to match supply and demand
baseFee=F0eb
$F_0$ = 0.01 gwei, fixed base fee
b = Size of backlog created due to an increase in transaction demand
Arbitrum fee model
Arbitrum has simplified its fee model by combining the two types of cost for a transaction highlighted in the last section -
Cost of data posting to Ethereum is determined by the size of data posted to the L1, either as calldata to Ethereum blocks or temporary storage in blobs multiplied by the effective cost of data per unit
Cost of data posting = L1 data size * L1 data cost
This cost is amortised over the total number of transactions in the posted data. The cost is then used as an input for determining the cost of data posting for future blocks. Thus, the cost of data posting for the current block is determined by the congestion for data posting to Ethereum in the previous few blocks
Transaction cost of Arbitrum is determined by the running gas price
Cost component of Arbitrum = L2 gas cost * L2 gas used
Thus, Cost of transaction on Arbitrum = L1 data size * L1 data cost + L2 gas cost * L2 gas used
Arbitrum converts it into a simple (cost = price * quantity) formula by converting the L1 data cost to a factor of L2 data cost. This makes the transaction cost of Arbitrum -
<aside> 👉 Transaction cost = L2 gas cost * (L2 gas used + (L1 data size*L1 data cost)/ L2 gas cost))
</aside>
Here, L1 data size is the size of data applicable to the current transaction.
The formula can be broken down into -
Gas price, P = L2 gas cost
Gas used, G = L2 gas used + (L1 data size*L1 data cost)/ L2 gas cost)
Example: Estimating cost of a sample Arbitrum transaction
Sample transaction - Transfer transaction on Arbitrum
Transaction cost = L2 gas cost * (L2 gas used + (L1 data size*L1 data cost)/ L2 gas cost))
= 4.2 * 10^(-7) ETH = USD 0.00108
Some observations
The transaction cost is driven by the min gas limit set by Arbitrum (99%)
With the availability of blobs, transaction costs on L2s have already reached the sub-cent range in case there is no congestion
Many rollups are considering ways to increase the computation power of the rollup sequencer to reduce congestion so that the transaction cost on rollups stays low even during the periods of high demand
Hopefully, this article simplifies the understanding of transaction cost estimation on Arbitrum