# setSubnameRecord

Sets subname record for subname management.

## Import

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

## Usage

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

const result = await setSubnameRecord(config, {
  owner: "0x0000000000000000000000000000000000000001",
  name: "example.eth",
});
```

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

## Parameters

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

### records

`ReadonlyArray<SetRecordInput> | undefined`

Records selected, read, or written by the operation.

### owner

`string`

Address that should own the resulting name or resource.

### resolver

`string | undefined`

Resolver address used by the operation.

### ttl

`bigint | undefined`

Registry time-to-live in seconds.

### expiry

`bigint | undefined`

Unix timestamp for the requested expiry.

### fuses

`number | undefined`

Value used for `fuses` by this action.

### roles

`bigint | undefined`

Role bitmask to read, grant, or revoke.

### salt

`bigint | undefined`

Deterministic deployment salt.

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

### resume

`CreateSubnameResult | 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.

## Return Type

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

| Property        | Type                                                                                                                                                                                                                                                                                                            | Description                                                      |
| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| `name`          | `string`                                                                                                                                                                                                                                                                                                        | Normalized ENS name.                                             |
| `protocol`      | `"v1" \| "v2"`                                                                                                                                                                                                                                                                                                  | ENS protocol route used for the result.                          |
| `created`       | `boolean`                                                                                                                                                                                                                                                                                                       | The created value returned by the operation.                     |
| `registry`      | `&#96;0x${string}&#96;`                                                                                                                                                                                                                                                                                         | The registry value returned by the operation.                    |
| `resolver`      | `&#96;0x${string}&#96; \| null`                                                                                                                                                                                                                                                                                 | The resolver value returned by the operation.                    |
| `resolverWrite` | `SetResolverAndRecordsProgress \| null`                                                                                                                                                                                                                                                                         | The resolverWrite value returned by the operation.               |
| `create`        | `CreateSubnameResult \| null`                                                                                                                                                                                                                                                                                   | The create value returned by the operation.                      |
| `mutations`     | `readonly CallExecutionResult[]`                                                                                                                                                                                                                                                                                | The mutations value returned by the operation.                   |
| `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; } \| ... 4 more ... \| { ...; }` | 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 = setSubnameRecord.effect(config, parameters);

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

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

## Error

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

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.subnames.setSubnameRecord`](/sdk/api/subnames/set-subname-record)
