> For the complete documentation index, see [llms.txt](https://docs.zircuit.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zircuit.com/info/architecture/gas-pricing-and-transaction-fees/l1-data-fee-calculation-fjord.md). Agents can also search and read this documentation through its [MCP server](https://docs.zircuit.com/~gitbook/mcp).

# L1 Data Fee Calculation (Fjord)

This page describes how to calculate the L1 data fee for a specific transaction on a Zircuit network post Fjord upgrade.

#### Retrieve the parameters

To perform the calculation the following parameters are needed:

* L1 base fee
* L1 base fee scalar
* L1 blob base fee
* L1 blob base fee scalar

They are available by calling the Gas Price Oracle smart contract predeployed on every Zircuit network on this address: `0x420000000000000000000000000000000000000F`

To retrieve them we can use Foundry's cast. You will need the block number in which the transaction was included to retrieve the parameters from the right point in time. You will also need a valid RPC url. For example you'll find the RPC urls on this page:

{% content-ref url="/pages/fEv1Wrfl0hPzbT380Xlr" %}
[RPCs](https://docs.zircuit.com/infra/rpcs.md)
{% endcontent-ref %}

L1 base fee:

```sh
cast call 0x420000000000000000000000000000000000000F "l1BaseFee()(uint256)" --rpc-url $RPC_URL --block $BLOCK_NUMBER
```

L1 base fee scalar:

```sh
cast call 0x420000000000000000000000000000000000000F "baseFeeScalar()(uint256)" --rpc-url $RPC_URL --block $BLOCK_NUMBER
```

L1 blob base fee:

```sh
cast call 0x420000000000000000000000000000000000000F "blobBaseFee()(uint256)" --rpc-url $RPC_URL --block $BLOCK_NUMBER
```

L1 blob base fee scalar:

```sh
cast call 0x420000000000000000000000000000000000000F "blobBaseFeeScalar()(uint256)" --rpc-url $RPC_URL --block $BLOCK_NUMBER
```

Get the raw RLP-encoded signed transaction:

```sh
cast tx $TX_HASH --rpc-url $RPC_URL --raw
```

| intercept          | -42\_585\_600 | Linear regression intercept (scaled by 1e6)   |
| ------------------ | ------------- | --------------------------------------------- |
| fastlzCoef         | 836\_500      | Linear regression coefficient (scaled by 1e6) |
| minTransactionSize | 100           | Minimum transaction size in bytes             |

[fastLzSize](https://github.com/zircuit-labs/l2-geth-public/blob/main/core/types/rollup_cost.go#L684-L760) can be calculated using the bytes represented by the raw RLP-encoded signed transaction as the parameter.

Now that you have all the info you need, you can just apply the following formula:

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

<pre><code><strong>1FeeScaled = baseFeeScalar * l1BaseFee * 16 + blobFeeScalar * l1BlobBaseFee
</strong></code></pre>

```
l1Cost = estimatedSizeScaled * l1FeeScaled / 1e12
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.zircuit.com/info/architecture/gas-pricing-and-transaction-fees/l1-data-fee-calculation-fjord.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
