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

approval.setOperator

Approves or revokes an operator for everything the signer holds on an ENS contract (setApprovalForAll). Options, errors and examples for approval.setOperator.

Writestable
Since v1.0.0View source

Approves or revokes an operator for everything the signer holds on an ENS contract (setApprovalForAll). Resolves once the transaction is submitted.

When to use

Use to let a marketplace or manager act on all your names in one contract. Use setOperatorSync to wait for the receipt.

Details

  • contract: the ENSv1 "registry", "registrar" or "wrapper", or any ENSv2 registry or resolver by address.
  • On ENSv2 registries an operator can transfer names; other changes need roles.

Signature

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

Call it as ens.approval.setOperator(options) on a client, or Actions.approval.setOperator(client, options).

Parameters

OptionTypeDefaultDescription
operator (required)stringAccount to approve or revoke.
approved (required)booleantrue to approve the operator, false to revoke it.
contract (required)ApprovalContract"registry", "registrar", "wrapper", or a registry or resolver address.

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_ADDRESSinvalid addresses.
UnsupportedErrorUNSUPPORTED_ON_DEPLOYMENTENSv1 contracts without ENSv1.
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

Approving a manager
const { hash } = await ens.approval.setOperator({ operator: "0xB0b0000000000000000000000000000000000000", approved: true, contract: "wrapper" })

Plan methods

Each method takes the same options as approval.setOperator and sends nothing. See Preview before sending.

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

Wait for the receipt with setOperatorSync

Approves or revokes an operator for everything the signer holds on an ENS contract (setApprovalForAll). Resolves once the receipt is in.

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

approval.setOperatorSync takes the same options plus confirmations and timeout.

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

Approving a manager and waiting
const { receipt } = await ens.approval.setOperatorSync({ operator: "0xB0b0000000000000000000000000000000000000", approved: true, contract: "wrapper" })

See also

Was this page helpful?