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

# Prepare Authorization \[wallet.prepareAuthorization]

Prepares an [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) Authorization object for signing.
Fills required fields such as `nonce` and `chainId` when you omit them.

With the prepared Authorization object, you can use [`Actions.wallet.signAuthorization`](/docs/actions/wallet/signAuthorization) to sign over it.

## Usage

This example prepares an [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) Authorization object for signing.

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

const authorization = await client.wallet.prepareAuthorization({
  address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
})
// @log: { address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', chainId: 1, nonce: 664n }
```

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

export const client = Client.create({
  account: Account.fromPrivateKey('0x…'),
  chain: mainnet,
  transport: http(),
}).extend(walletActions())
```
:::

### Standalone Action

Call `Actions.wallet.prepareAuthorization` 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 authorization = await Actions.wallet.prepareAuthorization(client, {
  address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
})
// @log: { address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', chainId: 1, nonce: 664n }
```

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

export const client = Client.create({
  account: Account.fromPrivateKey('0x…'),
  chain: mainnet,
  transport: http(),
})
```
:::

## Recipes

### Prepare for Self-Execution

Pass `executor: 'self'` when the signing account will also submit the EIP-7702 transaction. Viem
increments the pending account nonce for the execution transaction.

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

const authorization = await client.wallet.prepareAuthorization({
  address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
  executor: 'self', // [!code focus]
})
```

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

export const client = Client.create({
  account: Account.fromPrivateKey('0x…'),
  chain: mainnet,
  transport: http(),
}).extend(walletActions())
```
:::

### Prepare for a Known Nonce

Pass the signing account and nonce when another workflow has already reserved the Authorization
nonce. Viem then skips the nonce lookup.

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

export function prepareAtNonce(
  account: Address.Address,
  nonce: bigint,
) {
  return client.wallet.prepareAuthorization({
    account, // [!code focus]
    address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
    nonce, // [!code focus]
  })
}
```

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

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

## Return Value

`Authorization`

The prepared (unsigned) Authorization object.

## Parameters

### account

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

Account (or address) signing the Authorization.

```ts twoslash
import { Account, Actions } from 'viem'
// [!include ~/snippets/docs/reference-client.ts:setup]
// ---cut---
const authorization = await Actions.wallet.prepareAuthorization(client, {
  account: Account.fromPrivateKey('0x…'), // [!code focus]
  address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
})
```

### address

* **Type:** `Address`

Address of the contract to delegate to.

```ts twoslash
import { Actions } from 'viem'
// [!include ~/snippets/docs/reference-client.ts:setup]
// ---cut---
const authorization = await Actions.wallet.prepareAuthorization(client, {
  address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', // [!code focus]
})
```

### chainId

* **Type:** `number`
* **Default:** `client.chain.id`

Chain ID to scope the Authorization to.

```ts twoslash
import { Actions } from 'viem'
// [!include ~/snippets/docs/reference-client.ts:setup]
// ---cut---
const authorization = await Actions.wallet.prepareAuthorization(client, {
  address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
  chainId: 1, // [!code focus]
})
```

### executor

* **Type:** `'self' | Account | Address`

Whether the signing EOA or another Account will execute the EIP-7702 transaction.

Pass `'self'` when the signing EOA also submits the transaction.
Viem then increments the nonce for the execution transaction.

```ts twoslash
import { Actions } from 'viem'
// [!include ~/snippets/docs/reference-client.ts:setup]
// ---cut---
const authorization = await Actions.wallet.prepareAuthorization(client, {
  address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
  executor: 'self', // [!code focus]
})
```

### nonce

* **Type:** `bigint`
* **Default:** account nonce

Nonce of the Authorization.

```ts twoslash
import { Actions } from 'viem'
// [!include ~/snippets/docs/reference-client.ts:setup]
// ---cut---
const authorization = await Actions.wallet.prepareAuthorization(client, {
  address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
  nonce: 69n, // [!code focus]
})
```

## Errors

| Error | Description |
| --- | --- |
| `Account.NotFoundError` | No `account` was provided and the client has no account. |
