# resolver.create

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

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

Source: https://ensforge.com/docs/reference/sdk/resolver/create

<ApiMeta kind="Write" stability="stable" since="1.0.0" source="packages/sdk/src/actions/resolver/create/index.ts#L70" />

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

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

Use to give an ENSv2 name its own resolver, or to set up a resolver shared by several names. Use [`createSync`](/docs/reference/sdk/resolver/create#wait-for-the-receipt-with-createsync) to wait for the receipt.

## Details [#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.

<Callout type="warn" title="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`](/docs/reference/errors/SALT_TAKEN), whose
  `context.contract` is the existing resolver; point the name at it with `resolver.set`.
</Callout>

## Signature [#signature]

```ts
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 [#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](/docs/reference/sdk/client#write-options).

## Returns [#returns]

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

## 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), [`INVALID_ROLES`](/docs/reference/errors/INVALID_ROLES), [`INVALID_RECORD_VALUE`](/docs/reference/errors/INVALID_RECORD_VALUE), [`SALT_TAKEN`](/docs/reference/errors/SALT_TAKEN) | invalid input, or a `salt` whose resolver already exists. |
| [`NameStateError`](/docs/reference/errors/name-state-error) | [`NAME_EXPIRED`](/docs/reference/errors/NAME_EXPIRED), [`NAME_RESERVED`](/docs/reference/errors/NAME_RESERVED), [`NAME_NOT_REGISTERED`](/docs/reference/errors/NAME_NOT_REGISTERED) | the name is not registered. |
| [`NameStateError`](/docs/reference/errors/name-state-error) | [`NAME_UNREACHABLE`](/docs/reference/errors/NAME_UNREACHABLE) | ENSv2 resolution no longer reaches the name. |
| [`ConfigError`](/docs/reference/errors/config-error) | [`WALLET_NOT_CONFIGURED`](/docs/reference/errors/WALLET_NOT_CONFIGURED) | no account is known to predict the address. |
| [`UnsupportedError`](/docs/reference/errors/unsupported-error) | [`UNSUPPORTED_ON_DEPLOYMENT`](/docs/reference/errors/UNSUPPORTED_ON_DEPLOYMENT), [`RESOLVER_PROFILE_UNSUPPORTED`](/docs/reference/errors/RESOLVER_PROFILE_UNSUPPORTED) | without ENSv2, or for records a PermissionedResolver cannot store. |
| [`UnauthorizedError`](/docs/reference/errors/unauthorized-error) | [`NOT_OWNER`](/docs/reference/errors/NOT_OWNER), [`MISSING_ROLES`](/docs/reference/errors/MISSING_ROLES) | the account may not point the name at it. |
| [`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="Creating a resolver with records"
const { resolver } = await ens.resolver.create({ name: "alice.eth", records: { texts: { url: "https://alice.dev" } } })
```
</Tab>

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

await Actions.resolver.create(ens, { name: "alice.eth", records: { texts: { url: "https://alice.dev" } } })
```
</Tab>

<Tab>
```ts title="Creating a resolver with records in an Effect program"
import { Actions } from "@ensforge/sdk/effect"

yield* Actions.resolver.create(ens, { name: "alice.eth", records: { texts: { url: "https://alice.dev" } } })
```
</Tab>
</Tabs>

## Plan methods [#plan-methods]

Each method takes the same options as `resolver.create` and sends nothing. See [Preview before sending](/docs/sdk/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` [#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`](/docs/reference/sdk/client#sync-options).

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

<Tabs groupId="api" items={["Client","Standalone","Effect"]} persist>
<Tab>
```ts title="Creating a resolver with records and waiting"
const { receipt } = await ens.resolver.createSync({ name: "alice.eth", records: { texts: { url: "https://alice.dev" } } })
```
</Tab>

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

await Actions.resolver.createSync(ens, { name: "alice.eth", records: { texts: { url: "https://alice.dev" } } })
```
</Tab>

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

yield* Actions.resolver.createSync(ens, { name: "alice.eth", records: { texts: { url: "https://alice.dev" } } })
```
</Tab>
</Tabs>

## See also [#see-also]

- [`resolver.get`](/docs/reference/sdk/resolver/get) to inspect it