Skip to content

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

Log[]

If the filter was created with createContractEventFilter or createEventFilter, it returns a list of logs.

OR

"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

A created filter.

const filter = await publicClient.createPendingTransactionFilter();
const logs = await publicClient.getFilterChanges({
  filter, 
});

JSON-RPC Method

cfx_getFilterChanges