# registration.commit

> For the complete documentation index, see [llms.txt](https://ensforge.com/llms.txt).

Commits to registering .eth names, the first half of a registration. Parameters, return value, errors and examples for registration.commit in @ensforge/sdk.

Source: https://ensforge.com/docs/reference/sdk/registration/commit

<ApiMeta kind="Write" stability="stable" since="1.0.0" source="packages/sdk/src/actions/registration/commit/index.ts#L64" />

Commits to registering `.eth` names, the first half of a registration. Resolves once the transaction is submitted.

## When to use [#when-to-use]

Use when registration is split across sessions or devices; `register` alone does both halves. Use [`commitSync`](/docs/reference/sdk/registration/commit#wait-for-the-receipt-with-commitsync) to wait for the receipt.

## Details [#details]

- Takes the same options as [`registration.register`](/docs/reference/sdk/registration/register); they are hashed into the commitment.
- Keep the returned `secret`, then call `register` with the same options and `secret` once the
  commitment is ready (see [`registration.getCommitmentStatus`](/docs/reference/sdk/registration/get-commitment-status)).

<Callout type="warn" title="Gotchas">
- `.prepare` and `.simulate` without `secret` use a throwaway secret.
</Callout>

## Signature [#signature]

```ts
function commit(
  client: Like,
  options: commit.Options & Write.Options,
): Promise<commit.ReturnType>
```

Call it as `ens.registration.commit(options)` on a client, or `Actions.registration.commit(client, options)`.

## Parameters [#parameters]

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `names` (required) | `string \| readonly string[]` |  | One or more `.eth` second-level names; several share one plan. Normalized automatically. |
| `duration` (required) | `bigint` |  | Registration length in seconds, e.g. `Duration.years(1)`. |
| `owner` | `string` | the signing account | Owner of the names. |
| `resolver` | `string \| null` |  | Resolver for the names. By default each name gets its own PermissionedResolver, deployed in the same plan with `records` written at creation. `"owned"` uses the signer's shared PermissionedResolver (the ENS app's address), deployed once and reused; its roles cover every name on it. `null` registers without a resolver. |
| `records` | `Omit<recordSet.Options, "name" \| "resolver" \| "clear" \| "pubkey">` |  | Records for every name, written when its resolver is created (or right after registering). |
| `primaryName` | `boolean` |  | Set the (single) name as the signer's primary name; adds its `eth` address record. |
| `paymentToken` | `PaymentToken` | `"usdc"` | Token to pay with. |
| `subregistry` | `string` |  | ENSv2 registry for the names' subnames. |
| `referrer` | `Hex` |  | Referrer recorded by the registrar: 32 bytes, or an address (left-padded). |
| `secret` | `Hex` |  | Secret from an earlier `commit` or `register`, to finish that registration. |

Also takes the [write options](/docs/reference/sdk/client#write-options).

## Returns [#returns]

Resolves to `Write.Result & { readonly secret: Hex; readonly commitments: readonly Hex[] }`. Submitted hashes, the plan, the secret and the commitments.

## Errors [#errors]

| Error | Codes | When |
| --- | --- | --- |
| [`InvalidInputError`](/docs/reference/errors/invalid-input-error) | [`INVALID_NAME`](/docs/reference/errors/INVALID_NAME), [`INVALID_ADDRESS`](/docs/reference/errors/INVALID_ADDRESS), [`DURATION_TOO_SHORT`](/docs/reference/errors/DURATION_TOO_SHORT), [`INVALID_RECORD_VALUE`](/docs/reference/errors/INVALID_RECORD_VALUE) | invalid input. |
| [`NameStateError`](/docs/reference/errors/name-state-error) | [`NAME_NOT_AVAILABLE`](/docs/reference/errors/NAME_NOT_AVAILABLE) | a name is taken or in its grace period. |
| [`CommitmentError`](/docs/reference/errors/commitment-error) | [`COMMITMENT_TOO_NEW`](/docs/reference/errors/COMMITMENT_TOO_NEW), [`COMMITMENT_TOO_OLD`](/docs/reference/errors/COMMITMENT_TOO_OLD), [`COMMITMENT_EXISTS`](/docs/reference/errors/COMMITMENT_EXISTS) | a resumed commitment outside its window. |
| [`UnsupportedError`](/docs/reference/errors/unsupported-error) | [`PAYMENT_TOKEN_UNSUPPORTED`](/docs/reference/errors/PAYMENT_TOKEN_UNSUPPORTED), [`UNSUPPORTED_ON_DEPLOYMENT`](/docs/reference/errors/UNSUPPORTED_ON_DEPLOYMENT) | an unaccepted token or without ENSv2. |
| [`ConfigError`](/docs/reference/errors/config-error) | [`WALLET_NOT_CONFIGURED`](/docs/reference/errors/WALLET_NOT_CONFIGURED) | no signing account is known. |
| [`UserRejectedError`](/docs/reference/errors/user-rejected-error) | [`USER_REJECTED`](/docs/reference/errors/USER_REJECTED) | the user rejects the request. |
| [`WalletError`](/docs/reference/errors/wallet-error) | [`CHAIN_MISMATCH`](/docs/reference/errors/CHAIN_MISMATCH), [`ACCOUNT_NOT_FOUND`](/docs/reference/errors/ACCOUNT_NOT_FOUND) | the wallet is on another chain or has no account to sign with. |
| [`UnsupportedError`](/docs/reference/errors/unsupported-error) | [`WALLET_BATCH_UNSUPPORTED`](/docs/reference/errors/WALLET_BATCH_UNSUPPORTED) | with `mode: "batch"` or a paymaster when the wallet cannot send calls as one batch. |

It can also fail with the errors every write can (`Errors.WriteError`: the common errors plus `InsufficientFundsError`, `TransactionError`, `UnsupportedError`, `UserRejectedError`, `WalletError`).

See [How errors work](/docs/sdk/errors-explained).

## Examples [#examples]

<Tabs groupId="api" items={["Client","Standalone","Effect"]} persist>
<Tab>
```ts title="Committing to a name"
const { secret, commitments } = await ens.registration.commit({ names: "alice.eth", duration: 31536000n })
```
</Tab>

<Tab>
```ts title="Committing to a name with a standalone call"
import { Actions } from "@ensforge/sdk"

await Actions.registration.commit(ens, { names: "alice.eth", duration: 31536000n })
```
</Tab>

<Tab>
```ts title="Committing to a name in an Effect program"
import { Actions } from "@ensforge/sdk/effect"

yield* Actions.registration.commit(ens, { names: "alice.eth", duration: 31536000n })
```
</Tab>
</Tabs>

## Plan methods [#plan-methods]

Each method takes the same options as `registration.commit` and sends nothing. See [Preview before sending](/docs/sdk/preview-before-sending).

| Method | Description |
| --- | --- |
| `registration.commit.prepare(options)` | Builds the plan without sending anything. |
| `registration.commit.simulate(options)` | Simulates the plan with `eth_call`, reporting each step. |
| `registration.commit.estimateGas(options)` | Estimates the gas and ETH the plan needs. |

## Wait for the receipt with `commitSync` [#wait-for-the-receipt-with-commitsync]

Commits to registering `.eth` names, the first half of a registration. Resolves once the receipt is in.

Use when the next step depends on the change being on-chain.

`registration.commitSync` takes the same options plus [`confirmations` and `timeout`](/docs/reference/sdk/client#sync-options).

Resolves to `commitSync.ReturnType`. Receipts, the secret, the commitments and when they can be used.

<Tabs groupId="api" items={["Client","Standalone","Effect"]} persist>
<Tab>
```ts title="Committing to a name and waiting"
const { receipt } = await ens.registration.commitSync({ names: "alice.eth", duration: 31536000n })
```
</Tab>

<Tab>
```ts title="Waiting with a standalone call"
import { Actions } from "@ensforge/sdk"

await Actions.registration.commitSync(ens, { names: "alice.eth", duration: 31536000n })
```
</Tab>

<Tab>
```ts title="Waiting in an Effect program"
import { Actions } from "@ensforge/sdk/effect"

yield* Actions.registration.commitSync(ens, { names: "alice.eth", duration: 31536000n })
```
</Tab>
</Tabs>

## See also [#see-also]

- [`registration.register`](/docs/reference/sdk/registration/register) to finish