getFilterChanges
Returns a list of logs or hashes based on a Filter since the last time it was called.
A Filter can be created from the following actions:
Usage
Blocks
example.ts
import { publicClient } from "./client";
const filter = await publicClient.createBlockFilter();
const hashes = await publicClient.getFilterChanges({ filter });
Output: ["0x...", ...]
Raw Events
example.ts
import { parseAbiItem } from "cive";
import { publicClient } from "./client";
const filter = await publicClient.createEventFilter({
address: "cfx:...",
event: parseAbiItem(
"event Transfer(address indexed, address indexed, uint256)"
),
});
const logs = await publicClient.getFilterChanges({ filter });
Output: [{ ... }, { ... }, { ... }]
Transactions
example.ts
import { publicClient } from "./client";
const filter = await publicClient.createPendingTransactionFilter();
const hashes = await publicClient.getFilterChanges({ filter });
Output: ["0x..", ...]
Returns
If the filter was created with createContractEventFilter
or createEventFilter
, it returns a list of logs.
"0x${string}"[]
If the filter was created with createPendingTransactionFilter
, it returns a list of transaction hashes.
"0x${string}"[]
If the filter was created with createBlockFilter
, it returns a list of block hashes.
Parameters
filter
- Type:
Filter
A created filter.
const filter = await publicClient.createPendingTransactionFilter();
const logs = await publicClient.getFilterChanges({
filter,
});