Documentation for agents: an index at /llms.txt, every docs page in one file at /llms-full.txt, and Markdown for any docs page by adding .md to its URL.

Skip to Content
ensforgeSDK

registration.commit

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

Writestable
Since v1.0.0View source

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

When to use

Use when registration is split across sessions or devices; register alone does both halves. Use commitSync to wait for the receipt.

Details

Gotchas

  • .prepare and .simulate without secret use a throwaway secret.

Signature

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

OptionTypeDefaultDescription
names (required)string | readonly string[]One or more .eth second-level names; several share one plan. Normalized automatically.
duration (required)bigintRegistration length in seconds, e.g. Duration.years(1).
ownerstringthe signing accountOwner of the names.
resolverstring | null"owned" for names the signer owns, otherwise "new"Resolver for the names. "owned" uses the sender's shared PermissionedResolver (the ENS app's address for the wallet or its HCA), deployed once and reused; its roles cover every name on it. "new" deploys a PermissionedResolver per name, with records written at creation. An address uses that resolver; null registers without one.
recordsOmit<recordSet.Options, "name" | "resolver" | "clear" | "pubkey">Records for every name, written when its resolver is created (or right after registering).
primaryNamebooleanSet the (single) name as the signer's primary name; adds its eth address record.
paymentTokenPaymentToken"usdc"Token to pay with.
subregistrystringENSv2 registry for the names' subnames.
referrerHexReferrer recorded by the registrar: up to 32 bytes of hex, left-padded (an address works).
secretHexSecret from an earlier commit or register, to finish that registration.

Also takes the write options.

Returns

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

Errors

ErrorCodesWhen
InvalidInputErrorINVALID_NAME, INVALID_ADDRESS, INVALID_DURATION, DURATION_TOO_SHORT, INVALID_RECORD_VALUEinvalid input, including a zero owner or a duration over 100 years.
NameStateErrorNAME_NOT_AVAILABLEa name is taken or in its grace period.
NotFoundErrorRESOLVER_NOT_DEPLOYED, REGISTRY_NOT_FOUNDno contract is deployed at the given resolver or subregistry.
CommitmentErrorCOMMITMENT_EXISTSevery name already has a commitment that has not expired.
UnsupportedErrorPAYMENT_TOKEN_UNSUPPORTED, UNSUPPORTED_ON_DEPLOYMENTan unaccepted token or without ENSv2.
ConfigErrorWALLET_NOT_CONFIGUREDno signing account is known.
UserRejectedErrorUSER_REJECTEDthe user rejects the request.
WalletErrorCHAIN_MISMATCH, ACCOUNT_NOT_FOUNDthe wallet is on another chain or has no account to sign with.
UnsupportedErrorWALLET_BATCH_UNSUPPORTEDwith 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.

Examples

Committing to a name
const { secret, commitments } = await ens.registration.commit({ names: "alice.eth", duration: 31536000n })

Plan methods

Each method takes the same options as registration.commit and sends nothing. See Preview before sending.

MethodDescription
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

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.

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

Committing to a name and waiting
const { receipt } = await ens.registration.commitSync({ names: "alice.eth", duration: 31536000n })

See also

Was this page helpful?