Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add watch on useScaffoldEventHistory #38

Merged
merged 4 commits into from
Nov 20, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions docs/hooks/useScaffoldEventHistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sidebar_position: 4

# useScaffoldEventHistory

Use this hook to retrieve historical event logs for your smart contract, providing past activity data.
Use this hook to retrieve historical event logs for your smart contract, providing past activity data, with the option to watch for new events.

```ts
const {
Expand All @@ -16,14 +16,17 @@ const {
eventName: "GreetingChange",
// Specify the starting block number from which to read events, this is a bigint.
fromBlock: 31231n,
blockData: true,
// If set to true, the events will be updated every pollingInterval milliseconds set at scaffoldConfig (default: false)
watch: true,
// Apply filters to the event based on parameter names and values { [parameterName]: value },
filters: { premium: true },
// If set to true it will return the block data for each event (default: false)
blockData: true,
// If set to true it will return the transaction data for each event (default: false),
transactionData: true,
// If set to true it will return the receipt data for each event (default: false),
receiptData: true,
});
```

This example retrieves the historical event logs for the `GreetingChange` event of the `YourContract` smart contract, starting from block number 31231 and filtering events where the premium parameter is true. The data property of the returned object contains an array of event objects, each containing the event parameters and (optionally) the block, transaction, and receipt data. The `isLoading` property indicates whether the event logs are currently being fetched, and the `error` property contains any error that occurred during the fetching process (if applicable).
This example retrieves the historical event logs for the `GreetingChange` event of the `YourContract` smart contract, starting from block number 31231 and filtering events where the premium parameter is true. The data property of the returned object contains an array of event objects, each containing the event parameters and (optionally) the block, transaction, and receipt data. The `isLoading` property indicates whether the event logs are currently being fetched, and the `error` property contains any error that occurred during the fetching process (if applicable). Since `watch` is set to true, the event logs will be refetched every `pollingInterval` milliseconds (set at scaffoldConfig.config.ts).
carletex marked this conversation as resolved.
Show resolved Hide resolved