# migrateName

Runs the resumable workflow that migrates one name to ENSv2.

## Import

```ts
import { migrateName } from "@ensforge/core";
```

## Usage

:::code-group
```ts [index.ts]
import { migrateName } from "@ensforge/core";
import { config } from "./config";

const result = await migrateName(config, {
  name: "example.eth",
});
```

```ts [config.ts]
// [!include ~/snippets/core/config.ts]
```
:::

## Parameters

```ts
import type { MigrateNameParameters } from "@ensforge/core";
```

### migrateParent

`boolean | undefined`

Value used for `migrateParent` by this action.

### resume

`MigrationNameProgress | undefined`

Previously returned progress used to continue an incomplete workflow.

### name

`string`

ENS name to operate on. ensforge normalizes it before hashing or contract interaction.

### owner

`EthereumAddress | undefined`

Address that should own the resulting name or resource.

### resolver

`EthereumAddress | undefined`

Resolver address used by the operation.

### subregistry

`EthereumAddress | undefined`

ENSv2 subregistry assigned during registration.

### walletClient

`WalletClient | undefined`

Viem wallet client override for this operation. Defaults to the wallet resolved from the config.

### account

`Account | Address | undefined`

Account used to authorize this operation. Defaults to the account exposed by the resolved wallet client.

### mode

`WriteMode | undefined`

Write execution strategy. `auto` uses wallet capabilities and falls back to sequential transactions.

### confirmation

`ConfirmationPolicy | undefined`

Controls whether the action returns after submission or waits for one or more confirmations.

## Return Type

```ts
import type { MigrateNameResult } from "@ensforge/core";
```

| Property     | Type                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | Description                                                      |
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| `status`     | `"completed" \| "partial" \| "not-required"`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | Current query, transaction, batch, or workflow status.           |
| `name`       | `string`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | Normalized ENS name.                                             |
| `route`      | `"unwrapped" \| "wrapped-unlocked" \| "wrapped-locked" \| "locked-child" \| undefined`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | The route value returned by the operation.                       |
| `steps`      | `readonly { readonly name: string; readonly route: Extract<MigrationTarget, { readonly supported: true; }>["route"]; }[] \| undefined`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | The steps value returned by the operation.                       |
| `write`      | `WritePlanProgress \| null`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | Progress for the write plan used by the workflow.                |
| `finalState` | `{ readonly kind: "available"; readonly protocol: "v1" \| "v2"; readonly wrapped: false; readonly migrated: false; readonly name: string & Brand<"NormalizedName">; readonly status: "available" \| ... 3 more ... \| "expired"; ... 10 more ...; readonly renewable: boolean; } \| ... 5 more ... \| null \| { readonly kind: "available"; readonly protocol: "v1" \| "v2"; readonly wrapped: false; readonly migrated: false; readonly name: string & Brand<"NormalizedName">; readonly status: "available" \| ... 3 more ... \| "expired"; ... 10 more ...; readonly renewable: boolean; } \| ... 4 more ... \| { ...; }` | Name state observed after the workflow finishes, when available. |
| `reason`     | `"V2_NATIVE" \| "AVAILABLE" \| "ALREADY_MIGRATED" \| undefined`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | The reason value returned by the operation.                      |

## Effect

Use `.effect` when composing the action in an Effect program. The success and error channels remain
fully typed.

```ts
import { Effect } from "effect";

const program = migrateName.effect(config, parameters);

type Success = Effect.Effect.Success<typeof program>;
type Failure = Effect.Effect.Error<typeof program>;

const result = await Effect.runPromise(program);
```

## Call

Use `.call` to prepare this write for simulation, wallet batching, or a custom execution policy.

```ts
const call = migrateName.call(parameters);
```

## Error

The Promise API rejects with the same typed failures exposed by the Effect error channel. Errors
have a stable `_tag`, `code`, and `message`; boundary errors retain their original `cause`.

See [Error Handling](/core/guides/error-handling).

## Related

* [`sdk.migration.migrateName`](/sdk/api/migration/migrate-name)
