# registerName

Runs the resumable commitment and registration workflow for one name.

## Import

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

## Usage

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

const result = await registerName(config, {
  name: "example.eth",
  owner: "0x0000000000000000000000000000000000000001",
  duration: 365n * 24n * 60n * 60n,
  secret: "0x0000000000000000000000000000000000000000000000000000000000000001",
});
```

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

## Parameters

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

### name

`string`

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

### owner

`EthereumAddress`

Address that should own the resulting name or resource.

### resolver

`EthereumAddress | undefined`

Resolver address used by the operation.

### duration

`bigint`

Duration in seconds.

### subregistry

`EthereumAddress | undefined`

ENSv2 subregistry assigned during registration.

### secret

`Bytes32`

32-byte secret used to construct a registration commitment.

### reverseRecord

`0 | 1 | 2 | undefined`

Reverse-record behavior requested during registration.

### referrer

`Bytes32 | undefined`

Optional protocol-specific referral identifier.

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

### paymentToken

`EthereumAddress | undefined`

ERC-20 token used when the registrar supports token payments.

### maxPrice

`bigint | undefined`

Maximum price accepted by the caller.

### records

`ReadonlyArray<SetRecordInput> | undefined`

Records selected, read, or written by the operation.

### resume

`RegisterNameResult | undefined`

Previously returned progress used to continue an incomplete workflow.

## Return Type

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

| Property                  | Type                                                                                                                                                                                                                                                                                                          | Description                                                      |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| `status`                  | `"completed" \| "waiting" \| "partial" \| "submitted"`                                                                                                                                                                                                                                                        | Current query, transaction, batch, or workflow status.           |
| `name`                    | `string & Brand<"NormalizedName">`                                                                                                                                                                                                                                                                            | Normalized ENS name.                                             |
| `protocol`                | `"v1" \| "v2"`                                                                                                                                                                                                                                                                                                | ENS protocol route used for the result.                          |
| `commitment`              | `&#96;0x${string}&#96;`                                                                                                                                                                                                                                                                                       | The commitment value returned by the operation.                  |
| `committedByWorkflow`     | `boolean`                                                                                                                                                                                                                                                                                                     | The committedByWorkflow value returned by the operation.         |
| `paymentApprovalIncluded` | `boolean`                                                                                                                                                                                                                                                                                                     | The paymentApprovalIncluded value returned by the operation.     |
| `readyAt`                 | `bigint \| null`                                                                                                                                                                                                                                                                                              | The readyAt value returned by the operation.                     |
| `expiresAt`               | `bigint \| null`                                                                                                                                                                                                                                                                                              | The expiresAt value returned by the operation.                   |
| `nextActionAt`            | `bigint \| null`                                                                                                                                                                                                                                                                                              | The nextActionAt value returned by the operation.                |
| `price`                   | `{ readonly status: "available"; readonly name: string & Brand<"NormalizedName">; readonly protocol: "v1" \| "v2"; readonly registrar: &#96;0x${string}&#96;; readonly duration: bigint; readonly base: bigint; readonly premium: bigint; readonly total: bigint; readonly currency: { ...; } \| { ...; }; }` | The price value returned by the operation.                       |
| `write`                   | `WritePlanProgress`                                                                                                                                                                                                                                                                                           | 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`   | Name state observed after the workflow finishes, when available. |

## 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 = registerName.effect(config, parameters);

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

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

## 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.registration.registerName`](/sdk/api/registration/register-name)
