Skip to main content

Astar zkEVM Fee Calculation

How do network fees on Astar zkEVM work?

In Astar zkEVM the gas fee is calculated by applying a fixed factor over L1 gas fee. That price factor is a fixed value and doesn't change often and it's value is based the rollup's cost to publish tx to L1. To Simply put, gas prices in L2 will linearly follow gas prices in L1.

L2{gas_fee}=L1{gas_fee}FactorL2_\{gas\_fee\} = L1_\{gas\_fee\} * Factor

The L1 fee will vary depending on the amount of transactions on the L1. If the timing of your transaction is flexible, you can save costs by submitting transactions during periods of lower gas on the L1 (for example, over the weekend)

The support for congestion mechanism based EIP-1559 here is planned for future and will make the L2 gas fee dynamic.

Fetch gas price from RPC node

The gas price can be fetched from the Astar zkEVM Sequencer using the following RPC call:

curl https://rpc.startale.com/zkyoto \
-X POST \
-H "Content-Type: application/json" \
--data '{"method":"eth_gasPrice","params":[],"id":1,"jsonrpc":"2.0"}'

The result is the hex value of the gas price in wei.

Use Blockscout Price Oracle

Blockscout Price Oracle calculates the gas price from the average of previous blocks. It doesn't call eth_gasPrice.

Send a GET request to the Blockscout Price Oracle endpoint to get a gas price recommendation from this oracle.

cURL

curl https://astar-zkevm.explorer.startale.com/api/v1/gas-price-oracle

JavaScript

fetch('https://astar-zkevm.explorer.startale.com/api/v1/gas-price-oracle')
.then(response => response.json())
.then(json => console.log(json))

Python

import requests
requests.get('https://astar-zkevm.explorer.startale.com/api/v1/gas-price-oracle').json()

The Price Oracle Response

An example JSON response from Blockscout Price Oracle will look like this:

{
"average":3.02,
"fast":3.02,
"slow":3.02,
}
  • slow are gas prices in Gwei, you can use these prices before sending the transaction off to Astar zkEVM.