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

event.watch

Watches one name's ENS events as new blocks arrive. Parameters, return value, errors and examples for event.watch in @ensforge/sdk.

Readstable
Since v1.0.0View source

Watches one name's ENS events as new blocks arrive. Resolves to a function that stops watching.

When to use

Use to update a name's page live, or to react when another account changes the name.

Details

  • Every new block range is read like event.get, so resolver and registry changes during the watch are followed.
  • Polls at the public client's pollingInterval unless pollingInterval is given.

Signature

function watch(client: Like, options: watch.Options): Promise<watch.ReturnType>

Call it as ens.event.watch(options) on a client, or Actions.event.watch(client, options).

Parameters

OptionTypeDefaultDescription
name (required)stringENS name. Normalized automatically.
typesreadonly EventType[]Only these event types.
pollingIntervalnumberMilliseconds between polls.
onEvents (required)(events: readonly Event[]) => voidCalled with each new batch of events.
onError((error: AnyError) => void)Called when a poll fails; watching continues.

Returns

Resolves to () => void. Stops watching.

Errors

ErrorCodesWhen
InvalidInputErrorINVALID_NAMEinvalid names.

It can also fail with the errors every read can (Errors.CommonError: ConfigError, ContractRevertError, InternalError, NetworkError).

See How errors work.

Examples

Watching a name
const unwatch = await ens.event.watch({ name: "nick.eth", onEvents: (events) => console.log(events) })

See also

Was this page helpful?