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

Sets the metadata URI of an ENSv2 registry. Parameters, return value, errors and examples for registry.setUri in @ensforge/sdk.

Writestable
Since v1.0.0View source

Sets the metadata URI of an ENSv2 registry. Resolves once the transaction is submitted.

When to use

Use to point a registry's token metadata at your own service. Use setUriSync to wait for the receipt.

Details

  • Keeps the current URI renderer unless renderer is given; null removes it.
  • Needs the setUri root role.

Signature

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

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

Parameters

With name and uri:

OptionTypeDefaultDescription
name (required)string
uri (required)stringMetadata URI.
rendererstring | nullURI renderer contract, or null for none.

With registry and uri:

OptionTypeDefaultDescription
registry (required)string
uri (required)stringMetadata URI.
rendererstring | nullURI renderer contract, or null for none.

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_ADDRESSinvalid input.
NotFoundErrorREGISTRY_NOT_FOUNDthe name has no subregistry.
UnauthorizedErrorMISSING_ROLESwithout the setUri root 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

Setting a registry URI
const { hash } = await ens.registry.setUri({ name: "alice.eth", uri: "https://alice.dev/names/{id}.json" })

Plan methods

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

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

Wait for the receipt with setUriSync

Sets the metadata URI of an ENSv2 registry. Resolves once the receipt is in.

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

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

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

Setting a registry URI and waiting
const { receipt } = await ens.registry.setUriSync({ name: "alice.eth", uri: "https://alice.dev/names/{id}.json" })

See also

Was this page helpful?