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

Deploys an ENSv2 PermissionedResolver, optionally with records, and points a name at it. Options, result, errors and examples for resolver.create.

Writestable
Since v1.0.0View source

Deploys an ENSv2 PermissionedResolver, optionally with records, and points a name at it. Resolves once the transaction is submitted.

When to use

Use to give an ENSv2 name its own resolver, or to set up a resolver shared by several names. Use createSync to wait for the receipt.

Details

  • The resolver is a verifiable proxy from the VerifiableFactory; its address is known before sending (plan.deploys) and returned as resolver.
  • owner (the signer by default) gets every role; grants add more accounts.
  • With name, records are written during initialization and the name is pointed at the new resolver in the same plan.

Gotchas

  • The address depends on the sending account and salt: send from the account the plan was prepared for. A salt already used by that account fails with SALT_TAKEN, whose context.contract is the existing resolver; point the name at it with resolver.set.

Signature

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

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

Parameters

OptionTypeDefaultDescription
namestringName to point at the new resolver; required for records. Normalized automatically.
recordsOmit<recordSet.Options, "name" | "resolver" | "clear" | "pubkey">Records for name, written while the resolver is initialized.
ownerstringthe signing accountAccount that gets every resolver role.
grantsreadonly { account: string; roles: readonly Role.Name[] | bigint }[]Extra role grants, by role name or bitmap.
saltbiginta random saltCREATE2 salt; together with the account it decides the address.

Also takes the write options.

Returns

Resolves to Write.Result & { readonly resolver: Address }. Submitted transaction hashes, the plan and the new resolver's address.

Errors

ErrorCodesWhen
InvalidInputErrorINVALID_NAME, INVALID_ADDRESS, INVALID_ROLES, INVALID_RECORD_VALUE, SALT_TAKENinvalid input, or a salt whose resolver already exists.
NameStateErrorNAME_EXPIRED, NAME_RESERVED, NAME_NOT_REGISTEREDthe name is not registered.
NameStateErrorNAME_UNREACHABLEENSv2 resolution no longer reaches the name.
ConfigErrorWALLET_NOT_CONFIGUREDno account is known to predict the address.
UnsupportedErrorUNSUPPORTED_ON_DEPLOYMENT, RESOLVER_PROFILE_UNSUPPORTEDwithout ENSv2, or for records a PermissionedResolver cannot store.
UnauthorizedErrorNOT_OWNER, MISSING_ROLESthe account may not point the name at 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

Creating a resolver with records
const { resolver } = await ens.resolver.create({ name: "alice.eth", records: { texts: { url: "https://alice.dev" } } })

Plan methods

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

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

Wait for the receipt with createSync

Deploys an ENSv2 PermissionedResolver, optionally with records, and points a name at it. Resolves once the receipt is in.

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

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

Resolves to Write.SyncResult & { readonly resolver: Address }. Receipts, hashes, the plan and the new resolver's address.

Creating a resolver with records and waiting
const { receipt } = await ens.resolver.createSync({ name: "alice.eth", records: { texts: { url: "https://alice.dev" } } })

See also

Was this page helpful?