resolver.create
Deploys an ENSv2 PermissionedResolver, optionally with records, and points a name at it. Options, result, errors and examples for resolver.create.
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 asresolver. owner(the signer by default) gets every role;grantsadd more accounts.- With
name,recordsare 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. Asaltalready used by that account fails withSALT_TAKEN, whosecontext.contractis the existing resolver; point the name at it withresolver.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
| Option | Type | Default | Description |
|---|---|---|---|
name | string | Name to point at the new resolver; required for records. Normalized automatically. | |
records | Omit<recordSet.Options, "name" | "resolver" | "clear" | "pubkey"> | Records for name, written while the resolver is initialized. | |
owner | string | the signing account | Account that gets every resolver role. |
grants | readonly { account: string; roles: readonly Role.Name[] | bigint }[] | Extra role grants, by role name or bitmap. | |
salt | bigint | a random salt | CREATE2 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
| Error | Codes | When |
|---|---|---|
InvalidInputError | INVALID_NAME, INVALID_ADDRESS, INVALID_ROLES, INVALID_RECORD_VALUE, SALT_TAKEN | invalid input, or a salt whose resolver already exists. |
NameStateError | NAME_EXPIRED, NAME_RESERVED, NAME_NOT_REGISTERED | the name is not registered. |
NameStateError | NAME_UNREACHABLE | ENSv2 resolution no longer reaches the name. |
ConfigError | WALLET_NOT_CONFIGURED | no account is known to predict the address. |
UnsupportedError | UNSUPPORTED_ON_DEPLOYMENT, RESOLVER_PROFILE_UNSUPPORTED | without ENSv2, or for records a PermissionedResolver cannot store. |
UnauthorizedError | NOT_OWNER, MISSING_ROLES | the account may not point the name at it. |
UserRejectedError | USER_REJECTED | the user rejects the request. |
WalletError | CHAIN_MISMATCH, ACCOUNT_NOT_FOUND | the wallet is on another chain or has no account to sign with. |
UnsupportedError | 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.
Examples
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.
| Method | Description |
|---|---|
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.
const { receipt } = await ens.resolver.createSync({ name: "alice.eth", records: { texts: { url: "https://alice.dev" } } })See also
resolver.getto inspect it
Was this page helpful?