> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://v3.viem.sh/api/mcp` to find what you need.

# `l1.estimateDepositTransactionGas`

Estimates the L1 gas required to deposit a transaction onto an OP Stack L2.

## Usage

Estimate the gas for submitting a prepared deposit request through the Optimism Portal.

:::code-group
```ts twoslash [example.ts]
import { optimism } from 'viem/chains'
import { Value } from 'viem/utils'
import { client } from './viem.config'

const gas = await client.deposit.estimateDepositTransactionGas({ // [!code focus]
  account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
  request: { // [!code focus]
    gas: 21_000n, // [!code focus]
    mint: Value.fromEther('1'), // [!code focus]
    to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', // [!code focus]
  }, // [!code focus]
  targetChain: optimism, // [!code focus]
}) // [!code focus]
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
// [!include ~/snippets/op-stack/l1.config.ts:setup]
```
:::

### Standalone Action

Call `Actions.l1.estimateDepositTransactionGas` directly by passing the [Client](/docs/clients) as the first argument.

:::code-group
```ts twoslash [example.ts]
import { optimism } from 'viem/chains'
import { Actions } from 'viem/op-stack'
import { Value } from 'viem/utils'
import { client } from './viem.config'

const gas = await Actions.l1.estimateDepositTransactionGas(client, { // [!code focus]
  account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
  request: { // [!code focus]
    gas: 21_000n, // [!code focus]
    mint: Value.fromEther('1'), // [!code focus]
    to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', // [!code focus]
  }, // [!code focus]
  targetChain: optimism, // [!code focus]
}) // [!code focus]
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
// [!include ~/snippets/op-stack/l1.config.ts:setup]
```
:::

## Return Value

`bigint`

The estimated L1 gas.

## Parameters

### account

* **Type:** `Account | Address`

The [Account](/docs/accounts) used for gas estimation.

### chain

* **Type:** `Chain`
* **Default:** `client.chain`

The L1 chain used for gas estimation.

### gas

* **Type:** `bigint`

The gas limit included in the estimate request.

### maxFeePerGas

* **Type:** `bigint`

The maximum total fee per gas, in wei.

### maxPriorityFeePerGas

* **Type:** `bigint`

The maximum priority fee per gas, in wei.

### nonce

* **Type:** `number`

The transaction nonce included in the estimate request.

### portalAddress

* **Type:** `Address`

An explicit Optimism Portal address. When supplied, `targetChain` is optional.

### request

* **Type:** `Deposit.Request`

The L2 transaction request.

#### request.data

* **Type:** `Hex`

Encoded contract method and arguments, or contract deployment bytecode.

#### request.gas

* **Type:** `bigint`

The gas limit for transaction execution on L2.

#### request.isCreation

* **Type:** `boolean`
* **Default:** `false`

Whether the transaction deploys a contract. Contract deployments require `data` and cannot specify `to`.

#### request.mint

* **Type:** `bigint`

The value minted on L2 and supplied by the L1 transaction, in wei.

#### request.to

* **Type:** `Address`

The L2 transaction recipient.

#### request.value

* **Type:** `bigint`

The value sent by the deposited transaction on L2, in wei.

### targetChain

* **Type:** `Chain`

The OP Stack L2 [Chain](/docs/chains) whose portal contract is used.
