SRC20EventWatcher
Synchronous SRC20 event watcher class
Polling-based SRC20 event watcher that runs in a background daemon thread.
Typically created via watch_src20_events() or watch_src20_events_with_key() rather than instantiated directly.
Constructor
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",
) -> NoneParameters
w3
Web3
Web3 instance
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
start()
Start the background polling thread
stop()
Signal stop and wait for thread exit
is_running
Property — True if thread is alive
Context Manager
Notes
Runs as a daemon thread named
"src20-watcher"— exits when main thread exitsBlock tracking is automatic; the watcher remembers the last processed block
If
on_erroris not provided, errors are logged at DEBUG levelComputes
keccak256(aes_key)once at initialization for event filtering
See Also
AsyncSRC20EventWatcher — Async variant
watch_src20_events — Factory with auto key fetch
watch_src20_events_with_key — Factory with explicit key
DecryptedTransferLog — Transfer callback data
DecryptedApprovalLog — Approval callback data
Last updated

