> **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.

# Fill Request \[transaction.fill]

Fills a transaction request with the fields required to be signed over, via `eth_fillTransaction`.

## Usage

This example fills a transaction request with the fields required to be signed over, via `eth_fillTransaction`.

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

const { raw, transaction } = await client.transaction.fill({
  account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  value: 1n,
})
// @log: {
// @log:   raw: '0x02f8...',
// @log:   transaction: {
// @log:     from: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
// @log:     gas: 21000n,
// @log:     maxFeePerGas: 16026200000n,
// @log:     maxPriorityFeePerGas: 1000000000n,
// @log:     nonce: 0n,
// @log:     to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
// @log:     type: 'eip1559',
// @log:     value: 1n,
// @log:     ...
// @log:   },
// @log: }
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
import { Client, http, publicActions } from 'viem'
import { mainnet } from 'viem/chains'

export const client = Client.create({
  chain: mainnet,
  transport: http(),
}).extend(publicActions())
```
:::

### Standalone Action

Call `Actions.transaction.fill` directly by passing the Client as the first argument.

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

const { raw, transaction } = await Actions.transaction.fill(client, {
  account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  value: 1n,
})
// @log: {
// @log:   raw: '0x02f8...',
// @log:   transaction: {
// @log:     from: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
// @log:     gas: 21000n,
// @log:     maxFeePerGas: 16026200000n,
// @log:     maxPriorityFeePerGas: 1000000000n,
// @log:     nonce: 0n,
// @log:     to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
// @log:     type: 'eip1559',
// @log:     value: 1n,
// @log:     ...
// @log:   },
// @log: }
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
import { Client, http } from 'viem'
import { mainnet } from 'viem/chains'

export const client = Client.create({
  chain: mainnet,
  transport: http(),
})
```
:::

## Recipes

### Fill an Authorized Transaction

Pass `authorizationList` when the transaction applies an EIP-7702 authorization.

```ts twoslash
import { Client, http, publicActions } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({
  chain: mainnet,
  transport: http(),
}).extend(publicActions())

const { transaction } = await client.transaction.fill({
  account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
  authorizationList: [ // [!code focus]
    { // [!code focus]
      address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', // [!code focus]
      chainId: 1, // [!code focus]
      nonce: 0n, // [!code focus]
      r: '0x...', // [!code focus]
      s: '0x...', // [!code focus]
      yParity: 0, // [!code focus]
    }, // [!code focus]
  ], // [!code focus]
  to: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
})
```

### Preserve Known Transaction Fields

Provide known gas, fee, and nonce values when the node should fill only the remaining fields.

```ts twoslash
import { Client, http, publicActions } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({
  chain: mainnet,
  transport: http(),
}).extend(publicActions())

const { transaction } = await client.transaction.fill({
  account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
  gas: 21_000n, // [!code focus]
  maxFeePerGas: 20_000_000_000n, // [!code focus]
  maxPriorityFeePerGas: 1_000_000_000n, // [!code focus]
  nonce: 69, // [!code focus]
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  value: 1n,
})
```

## Return Value

`{ capabilities?: object; raw: Hex; transaction: Transaction & { from: Address } }`

The raw signed-over transaction (`raw`), the filled `transaction`, and any node `capabilities` returned alongside it.

## Parameters

### accessList

* **Type:** `AccessList`

The EIP-2930 access list to attach to the transaction.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const { transaction } = await Actions.transaction.fill(client, {
  accessList: [ // [!code focus]
    { // [!code focus]
      address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', // [!code focus]
      storageKeys: [ // [!code focus]
        '0x0000000000000000000000000000000000000000000000000000000000000001', // [!code focus]
      ], // [!code focus]
    }, // [!code focus]
  ], // [!code focus]
  to: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
})
```

### account

* **Type:** `Account | Address`
* **Default:** `client.account`

The Account object or address that sends the transaction. This option takes precedence over [`from`](#from).

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const { transaction } = await Actions.transaction.fill(client, {
  account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', // [!code focus]
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  value: 1n,
})
```

### authorizationList

* **Type:** `AuthorizationList`

The EIP-7702 (signed) authorization list to attach to the transaction.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const { transaction } = await Actions.transaction.fill(client, {
  account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
  authorizationList: [ // [!code focus]
    { // [!code focus]
      address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', // [!code focus]
      chainId: 1, // [!code focus]
      nonce: 0n, // [!code focus]
      r: '0x...', // [!code focus]
      s: '0x...', // [!code focus]
      yParity: 0, // [!code focus]
    }, // [!code focus]
  ], // [!code focus]
})
```

### blobs

* **Type:** `readonly Hex[]`

The blobs to attach to the transaction (EIP-4844).

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const blobData = '0x1234' as const
const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const { transaction } = await Actions.transaction.fill(client, {
  blobs: [blobData], // [!code focus]
  to: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
})
```

### blobVersionedHashes

* **Type:** `readonly Hex[]`

The versioned hashes of the EIP-4844 blobs in the transaction request.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const { transaction } = await Actions.transaction.fill(client, {
  blobVersionedHashes: ['0x...'], // [!code focus]
  to: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
})
```

### chain

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

The chain the transaction targets. Used to derive the chain ID (for the nonce manager) and to apply chain-specific transaction codecs and fee multipliers.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet, optimism } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const { transaction } = await Actions.transaction.fill(client, {
  account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
  chain: optimism, // [!code focus]
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  value: 1n,
})
```

### chainId

* **Type:** `number | Hex`

The chain ID to include in the transaction request.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const { transaction } = await Actions.transaction.fill(client, {
  chainId: 1, // [!code focus]
  to: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
})
```

### data

* **Type:** `Hex`

The calldata to send with the transaction.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const { transaction } = await Actions.transaction.fill(client, {
  data: '0x06fdde03', // [!code focus]
  to: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
})
```

### from

* **Type:** `Address`

The raw sender address. Viem uses this field only when neither [`account`](#account) nor a Client Account is available.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const { transaction } = await Actions.transaction.fill(client, {
  from: '0xd2135CfB216b74109775236E36d4b433F1DF507B', // [!code focus]
  to: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
})
```

### gas

* **Type:** `number | bigint | Hex`

The gas limit for the transaction. When provided, it is preferred over the node-derived value.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const { transaction } = await Actions.transaction.fill(client, {
  gas: 21_000n, // [!code focus]
  to: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
})
```

### gasPrice

* **Type:** `number | bigint | Hex`

The legacy gas price (in wei). Mutually exclusive with `maxFeePerGas`/`maxPriorityFeePerGas`.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const { transaction } = await Actions.transaction.fill(client, {
  gasPrice: 20_000_000_000n, // [!code focus]
  to: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
})
```

### maxFeePerBlobGas

* **Type:** `number | bigint | Hex`

The max fee per blob gas (in wei) the sender is willing to pay (EIP-4844).

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const { transaction } = await Actions.transaction.fill(client, {
  maxFeePerBlobGas: 1_000_000_000n, // [!code focus]
  to: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
})
```

### maxFeePerGas

* **Type:** `number | bigint | Hex`

The total fee per gas (in wei) the sender is willing to pay (EIP-1559). When provided, it is preferred over the node-derived value.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const { transaction } = await Actions.transaction.fill(client, {
  maxFeePerGas: 20_000_000_000n, // [!code focus]
  to: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
})
```

### maxPriorityFeePerGas

* **Type:** `number | bigint | Hex`

The max priority fee per gas (in wei) to pay to the block producer (EIP-1559).

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const { transaction } = await Actions.transaction.fill(client, {
  maxPriorityFeePerGas: 1_000_000_000n, // [!code focus]
  to: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
})
```

### nonce

* **Type:** `number | bigint | Hex`

The nonce to use for the transaction. When provided, it takes precedence over the [`nonceManager`](#noncemanager).

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const { transaction } = await Actions.transaction.fill(client, {
  nonce: 69, // [!code focus]
  to: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
})
```

### nonceManager

* **Type:** `NonceManager`

A nonce manager used to derive the transaction nonce when [`nonce`](#nonce) is not provided.

```ts twoslash
import { Actions, Client, http, NonceManager } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const { transaction } = await Actions.transaction.fill(client, {
  account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
  nonceManager: NonceManager.jsonRpc(), // [!code focus]
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  value: 1n,
})
```

### requestOptions

* **Type:** `{ dedupe?: boolean; signal?: AbortSignal; ... }`

Per-request transport options (for example, an `AbortSignal` to cancel the request).

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const controller = new AbortController()
const { transaction } = await Actions.transaction.fill(client, {
  requestOptions: { signal: controller.signal }, // [!code focus]
  to: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
})
```

### to

* **Type:** `Address | null`

The transaction recipient. Pass `null` for a contract creation request.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const { transaction } = await Actions.transaction.fill(client, {
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', // [!code focus]
  value: 1n,
})
```

### type

* **Type:** `string`

Forces the transaction request to a specific type (for example, `'eip1559'`, `'eip2930'`, `'legacy'`).

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const { transaction } = await Actions.transaction.fill(client, {
  to: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  type: 'eip1559', // [!code focus]
})
```

### value

* **Type:** `number | bigint | Hex`

The value (in wei) sent with the transaction.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const { transaction } = await Actions.transaction.fill(client, {
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  value: 1000000000000000000n, // [!code focus]
})
```

## Errors

| Error | Description |
| --- | --- |
| `Actions.fee.Errors.BaseFeeScalarError` | The chain's `baseFeeMultiplier` resolved to a value less than `1`. |
| `RpcError.ExecutionError` | The node could not execute the `eth_fillTransaction` request. |
| `RpcError.FeeCapTooHighError` | `maxFeePerGas` exceeds the maximum allowed value. |
| `RpcError.TipAboveFeeCapError` | `maxPriorityFeePerGas` is greater than `maxFeePerGas`. |
