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

resolver.set

Points an ENS name at a resolver. Parameters, return value, errors and examples for resolver.set in @ensforge/sdk. Errors and examples for resolver.set.

Writestable
Since v1.0.0View source

Points an ENS name at a resolver. Resolves once the transaction is submitted.

When to use

Use to move a name to another resolver, or to remove it with resolver: null. Use setSync to wait for the receipt.

Details

  • ENSv1 names change it in the ENS registry, or through the NameWrapper when wrapped.
  • ENSv2 names change it in the registry holding them (setResolver on the token).
  • "default" is the ENSv1 public resolver, for ENSv1 names.

Gotchas

  • Records stay on the old resolver; copy them with record.set first.
  • ENSv2 names have no shared default resolver: create one with resolver.create.

Signature

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

Call it as ens.resolver.set(options) on a client, or Actions.resolver.set(client, options).

In React, use useSetResolver.

Parameters

OptionTypeDefaultDescription
name (required)stringENS name. Normalized automatically.
resolver (required)Address | "default" | nullNew resolver, "default" for the ENSv1 public resolver, or null to remove it.

Also takes the write options.

Returns

Resolves to Write.Result. Submitted transaction hashes and the plan that produced them.

FieldTypeDescription
hashHexHash of the last transaction.
hashesreadonly Hex[]Every submitted transaction, in order.
idstringEIP-5792 bundle id when the calls were sent as one batch.
planPlanThe plan the write executed: its steps, in order, as they were submitted.

Errors

ErrorCodesWhen
InvalidInputErrorINVALID_NAME, INVALID_ADDRESSinvalid input.
NameStateErrorNAME_EXPIRED, NAME_RESERVED, NAME_NOT_REGISTEREDthe name is not registered.
NameStateErrorNAME_UNREACHABLEENSv2 resolution no longer reaches the name.
UnsupportedErrorUNSUPPORTED_PROTOCOL"default" on ENSv2 names.
UnauthorizedErrorNOT_OWNER, MISSING_ROLES, FUSE_BURNEDthe account may not change it.
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

Switching to the public resolver
const { hash } = await ens.resolver.set({ name: "alice.eth", resolver: "default" })

Plan methods

Each method takes the same options as resolver.set and sends nothing. See Preview before sending.

MethodDescription
resolver.set.prepare(options)Builds the plan without sending anything.
resolver.set.simulate(options)Simulates the plan with eth_call, reporting each step.
resolver.set.estimateGas(options)Estimates the gas and ETH the plan needs.

Wait for the receipt with setSync

Points an ENS name at a resolver. Resolves once the receipt is in.

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

resolver.setSync takes the same options plus confirmations and timeout.

Resolves to Write.SyncResult. Receipts plus the submitted hashes and plan.

Switching to the public resolver and waiting
const { receipt } = await ens.resolver.setSync({ name: "alice.eth", resolver: "default" })

See also

Was this page helpful?