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

Links an ENS name to the records of another name on the same PermissionedResolver. Options, result, errors and examples for resolver.link.

Writestable
Since v1.0.0View source

Links an ENS name to the records of another name on the same PermissionedResolver. Resolves once the transaction is submitted.

When to use

Use to make several names share one set of records, such as aliases of a main name. Use linkSync to wait for the receipt.

Details

  • to is a name whose records the name will read and write, or a record ID from resolver.getLink.
  • Both names must use the same PermissionedResolver, and the target must already have records.
  • Needs the link role on the resolver.

Signature

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

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

Parameters

OptionTypeDefaultDescription
name (required)stringENS name. Normalized automatically.
to (required)string | { recordId: bigint }Name or record ID to link to.

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_RECORD_VALUEinvalid input or a target without records.
NameStateErrorNAME_EXPIRED, NAME_RESERVED, NAME_NOT_REGISTEREDthe name is not registered.
NameStateErrorNAME_UNREACHABLEENSv2 resolution no longer reaches the name.
NotFoundErrorRESOLVER_NOT_FOUNDthe name has no resolver of its own.
UnsupportedErrorRESOLVER_PROFILE_UNSUPPORTEDthe resolver is not a PermissionedResolver.
UnauthorizedErrorMISSING_ROLESwithout the link role.
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

Sharing records with another name
const { hash } = await ens.resolver.link({ name: "alice.eth", to: "alice-main.eth" })

Plan methods

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

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

Wait for the receipt with linkSync

Links an ENS name to the records of another name on the same PermissionedResolver. Resolves once the receipt is in.

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

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

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

Sharing records with another name and waiting
const { receipt } = await ens.resolver.linkSync({ name: "alice.eth", to: "alice-main.eth" })

See also

Was this page helpful?