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

registry.deploy

Deploys an ENSv2 UserRegistry, optionally attaching it as a name's subregistry. Options, result, errors and examples for registry.deploy.

Writestable
Since v1.0.0View source

Deploys an ENSv2 UserRegistry, optionally attaching it as a name's subregistry. Resolves once the transaction is submitted.

When to use

Use to set up the registry for a name's children ahead of time, or with custom roles. Use deploySync to wait for the receipt.

Details

  • A verifiable proxy of the deployment's UserRegistry, at an address known before sending (plan.deploys, returned as registry).
  • owner (the signer by default) gets every root role; emancipated withholds the roles that would let owners take children back.
  • attachTo makes it that name's subregistry in the same plan.

Signature

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

Call it as ens.registry.deploy(options) on a client, or Actions.registry.deploy(client, options).

Parameters

OptionTypeDefaultDescription
ownerstringthe signing accountAccount that gets the root roles.
grantsreadonly { account: string; roles: readonly Role.Name[] | bigint }[]Extra root role grants, by role name or bitmap.
emancipatedbooleanWithhold the roles that would let the owners take children back.
attachTostringENSv2 name to attach it to as subregistry. Normalized automatically.
saltbiginta random saltCREATE2 salt; together with the account it decides the address.

Also takes the write options.

Returns

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

Errors

ErrorCodesWhen
InvalidInputErrorINVALID_NAME, INVALID_ADDRESS, INVALID_ROLESinvalid input.
UnsupportedErrorUNSUPPORTED_ON_DEPLOYMENT, UNSUPPORTED_PROTOCOLwithout ENSv2, or for an ENSv1 attachTo.
UnauthorizedErrorMISSING_ROLESthe account may not set the name's subregistry.
ConfigErrorWALLET_NOT_CONFIGUREDno signing account is known.
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

Deploying a subregistry
const { registry } = await ens.registry.deploy({ attachTo: "alice.eth" })

Plan methods

Each method takes the same options as registry.deploy and sends nothing. See Preview before sending.

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

Wait for the receipt with deploySync

Deploys an ENSv2 UserRegistry, optionally attaching it as a name's subregistry. Resolves once the receipt is in.

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

registry.deploySync takes the same options plus confirmations and timeout.

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

Deploying a subregistry and waiting
const { receipt } = await ens.registry.deploySync({ attachTo: "alice.eth" })

See also

Was this page helpful?