> For the complete documentation index, see [llms.txt](https://docs.seismic.systems/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.seismic.systems/clients/python/src20/event-watching/src20-event-watcher.md).

# SRC20EventWatcher

Synchronous SRC20 event watcher class

Polling-based SRC20 event watcher that runs in a background daemon thread.

Typically created via [`watch_src20_events()`](https://docs.seismic.systems/clients/python/src20/event-watching/watch-src20-events.md) or [`watch_src20_events_with_key()`](https://docs.seismic.systems/clients/python/src20/intelligence-providers/watch-src20-events-with-key.md) rather than instantiated directly.

## Constructor

```python
class SRC20EventWatcher:
    def __init__(
        self,
        w3: Web3,
        aes_key: Bytes32,
        *,
        token_address: ChecksumAddress | None = None,
        on_transfer: TransferCallback | None = None,
        on_approval: ApprovalCallback | None = None,
        on_error: ErrorCallback | None = None,
        poll_interval: float = 2.0,
        from_block: int | str = "latest",
    ) -> None
```

## Parameters

| Parameter       | Type                                                                                    | Default    | Description                                    |
| --------------- | --------------------------------------------------------------------------------------- | ---------- | ---------------------------------------------- |
| `w3`            | `Web3`                                                                                  |            | Web3 instance                                  |
| `aes_key`       | [`Bytes32`](https://docs.seismic.systems/clients/python/api-reference/types/bytes32.md) |            | 32-byte AES-256 viewing key                    |
| `token_address` | `ChecksumAddress \| None`                                                               | `None`     | SRC20 contract to filter (`None` = all tokens) |
| `on_transfer`   | `TransferCallback \| None`                                                              | `None`     | Callback for Transfer events                   |
| `on_approval`   | `ApprovalCallback \| None`                                                              | `None`     | Callback for Approval events                   |
| `on_error`      | `ErrorCallback \| None`                                                                 | `None`     | Callback for errors                            |
| `poll_interval` | `float`                                                                                 | `2.0`      | Seconds between polls                          |
| `from_block`    | `int \| "latest"`                                                                       | `"latest"` | Starting block                                 |

## Methods

| Method       | Description                          |
| ------------ | ------------------------------------ |
| `start()`    | Start the background polling thread  |
| `stop()`     | Signal stop and wait for thread exit |
| `is_running` | Property — `True` if thread is alive |

## Context Manager

```python
with watch_src20_events_with_key(w3, viewing_key=key, on_transfer=cb) as watcher:
    time.sleep(60)
# Automatically stopped
```

## Notes

* Runs as a daemon thread named `"src20-watcher"` — exits when main thread exits
* Block tracking is automatic; the watcher remembers the last processed block
* If `on_error` is not provided, errors are logged at DEBUG level
* Computes `keccak256(aes_key)` once at initialization for event filtering

## See Also

* [AsyncSRC20EventWatcher](https://docs.seismic.systems/clients/python/src20/event-watching/async-src20-event-watcher.md) — Async variant
* [watch\_src20\_events](https://docs.seismic.systems/clients/python/src20/event-watching/watch-src20-events.md) — Factory with auto key fetch
* [watch\_src20\_events\_with\_key](https://docs.seismic.systems/clients/python/src20/intelligence-providers/watch-src20-events-with-key.md) — Factory with explicit key
* [DecryptedTransferLog](https://docs.seismic.systems/clients/python/src20/types/decrypted-transfer-log.md) — Transfer callback data
* [DecryptedApprovalLog](https://docs.seismic.systems/clients/python/src20/types/decrypted-approval-log.md) — Approval callback data


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.seismic.systems/clients/python/src20/event-watching/src20-event-watcher.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
