You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43-37Lines changed: 43 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@
8
8
9
9
## About
10
10
11
-
Event Scanner is a Rust library for monitoring EVM-based smart contract events. It is built on top of the [`alloy`](https://github.com/alloy-rs/alloy) ecosystem and focuses on in-memory scanning without a backing database. Applications provide event filters and callback implementations; the scanner takes care of subscribing to historical ranges, bridging into live mode, and delivering events with retry-aware execution strategies.
11
+
Event Scanner is a Rust library for monitoring EVM-based smart contract events. It is built on top of the [`alloy`](https://github.com/alloy-rs/alloy) ecosystem and focuses on in-memory scanning without a backing database. Applications provide event filters; the scanner takes care of subscribing to historical ranges, bridging into live mode, all whilst delivering the events as streams.
12
12
13
13
---
14
14
@@ -31,7 +31,7 @@ Event Scanner is a Rust library for monitoring EVM-based smart contract events.
31
31
-**Historical replay** – scan block ranges.
32
32
-**Live subscriptions** – stay up to date with latest blocks via WebSocket or IPC transports.
33
33
-**Hybrid flow** – automatically transition from historical catch-up into streaming mode.
34
-
-**Composable filters** – register one or many contract + event signature pairs with their own callbacks.
34
+
-**Composable filters** – register one or many contract + event signature pairs with their own event streams.
35
35
-**No database** – processing happens in-memory; persistence is left to the host application.
36
36
37
37
---
@@ -55,37 +55,43 @@ Add `event-scanner` to your `Cargo.toml`:
@@ -100,12 +106,12 @@ async fn run_scanner(ws_url: alloy::transports::http::reqwest::Url, contract: al
100
106
-`with_reorg_rewind_depth` - how many blocks to rewind when a reorg is detected
101
107
-`with_block_confirmations` - how many confirmations to wait for before considering a block final
102
108
103
-
Once configured, connect using either `connect_ws::<Ethereum>(ws_url)` or `connect_ipc::<Ethereum>(path)`. This will `build` the `EventScanner` and allow you to call run to start in various [modes](#scanning-Modes).
109
+
Once configured, connect using either `connect_ws::<Ethereum>(ws_url)` or `connect_ipc::<Ethereum>(path)`. This will build the `EventScanner` and allow you to create event streams and start scanning in various [modes](#scanning-modes).
104
110
105
111
106
112
### Defining Event Filters
107
113
108
-
Create an `EventFilter` for each contract/event pair you want to track. The filter bundles the contract address, the event signature (from `SolEvent::SIGNATURE`).
114
+
Create an `EventFilter` for each contract/event pair you want to track. The filter specifies the contract address and the event signature (from `SolEvent::SIGNATURE`).
109
115
110
116
Both `contract_address` and `event` fields are optional, allowing for flexible event tracking.
111
117
@@ -169,7 +175,7 @@ This flexibility allows you to build sophisticated event monitoring systems that
169
175
-**Historical mode** – `start(BlockNumberOrTag::Number(start, Some(BlockNumberOrTag::Number(end)))`, scanner fetches events from a historical block range.
170
176
-**Historical → Live** – `start(BlockNumberOrTag::Number(start, None)` replays from `start` to current head, then streams future blocks.
171
177
172
-
For now modes are deduced from the `start` and `end` parameters. In the future, we might add explicit commands to select the mode.
178
+
For now modes are deduced from the `start` and `end` parameters. In the future, we might add explicit commands to select the mode. Use `create_event_stream` to obtain a stream of events for processing.
173
179
174
180
See the integration tests under `tests/live_mode`, `tests/historic_mode`, and `tests/historic_to_live` for concrete examples.
175
181
@@ -188,7 +194,7 @@ RUST_LOG=info cargo run -p simple_counter
188
194
RUST_LOG=info cargo run -p historical_scanning
189
195
```
190
196
191
-
Both examples spin up a local `anvil` instance and deploy a demo counter contract before starting the scanner.
197
+
Both examples spin up a local `anvil` instance, deploy a demo counter contract, and demonstrate using event streams to process events.
0 commit comments