# event.watch

> For the complete documentation index, see [llms.txt](https://ensforge.com/llms.txt).

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

Source: https://ensforge.com/docs/reference/sdk/event/watch

<ApiMeta kind="Read" stability="stable" since="1.0.0" source="packages/sdk/src/actions/event/watch/index.ts#L50" />

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

## When to use [#when-to-use]

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

## Details [#details]

- Every new block range is read like [`event.get`](/docs/reference/sdk/event/get), so resolver and registry
  changes during the watch are followed.
- Polls at the public client's `pollingInterval` unless `pollingInterval` is given.

## Signature [#signature]

```ts
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 [#parameters]

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `name` (required) | `string` |  | ENS name. Normalized automatically. |
| `types` | `readonly EventType[]` |  | Only these event types. |
| `pollingInterval` | `number` |  | Milliseconds between polls. |
| `onEvents` (required) | `(events: readonly Event[]) => void` |  | Called with each new batch of events. |
| `onError` | `((error: AnyError) => void)` |  | Called when a poll fails; watching continues. |

## Returns [#returns]

Resolves to `() => void`. Stops watching.

## Errors [#errors]

| Error | Codes | When |
| --- | --- | --- |
| [`InvalidInputError`](/docs/reference/errors/invalid-input-error) | [`INVALID_NAME`](/docs/reference/errors/INVALID_NAME) | invalid names. |

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

See [How errors work](/docs/sdk/errors-explained).

## Examples [#examples]

<Tabs groupId="api" items={["Client","Standalone","Effect"]} persist>
<Tab>
```ts title="Watching a name"
const unwatch = await ens.event.watch({ name: "nick.eth", onEvents: (events) => console.log(events) })
```
</Tab>

<Tab>
```ts title="Watching with a standalone call"
import { Actions } from "@ensforge/sdk"

const unwatch = await Actions.event.watch(publicClient, { name: "nick.eth", onEvents })
```
</Tab>

<Tab>
```ts title="Watching in an Effect program"
import { Actions } from "@ensforge/sdk/effect"

const unwatch = yield* Actions.event.watch(ens, { name: "nick.eth", onEvents })
```
</Tab>
</Tabs>

## See also [#see-also]

- [`event.get`](/docs/reference/sdk/event/get) to read past events