For AI agents: a documentation index is available at /llms.txt. Markdown versions of pages are available by appending .md to any documentation URL.
Skip to main content

Filter and log methods

These methods create, poll, and remove filters, and query event logs.

eth_getFilterChanges

Polls the specified filter and returns an array of changes that have occurred since the last poll.

Parameters

  • filterId: string - Filter ID.

Returns

  • If nothing changed since the last poll, an empty list; otherwise:

    • For filters created with eth_newBlockFilter, returns block hashes.

    • For filters created with eth_newPendingTransactionFilter, returns transaction hashes.

    • For filters created with eth_newFilter, returns log objects.

      • removed: tag - true if log removed because of a chain reorganization. false if a valid log.

      • logIndex: quantity, integer - Log index position in the block. null when log is pending.

      • transactionIndex: quantity, integer - Index position of the starting transaction for the log. null when log is pending.

      • transactionHash: data, 32 bytes - Hash of the starting transaction for the log. null when log is pending.

      • blockHash: data, 32 bytes - Hash of the block that includes the log. null when log is pending.

      • blockNumber: quantity - Number of block that includes the log. null when log is pending.

      • blockTimestamp: quantity - Hex-encoded unix timestamp (in seconds) of the block that includes the log.

      • address: data, 20 bytes - Address the log originated from.

      • data: data - Non-indexed arguments of the log.

      • topics: array of data, 32 bytes each - Event signature hash and 0 to 3 indexed log arguments.

Example

curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "eth_getFilterChanges",
"params": [
"0xf8bf5598d9e04fbe84523d42640b9b0e"
],
"id": 1
}'

eth_getFilterLogs

Returns an array of logs for the specified filter.

Leave the --auto-log-bloom-caching-enabled command line option at the default value of true to improve log retrieval performance.

note

eth_getFilterLogs is only used for filters created with eth_newFilter. To specify a filter object and get logs without creating a filter, use eth_getLogs.

Parameters

  • filterId: string - Filter ID.

Returns

  • List of log objects.

    • removed: tag - true if log removed because of a chain reorganization. false if a valid log.

    • logIndex: quantity, integer - Log index position in the block. null when log is pending.

    • transactionIndex: quantity, integer - Index position of the starting transaction for the log. null when log is pending.

    • transactionHash: data, 32 bytes - Hash of the starting transaction for the log. null when log is pending.

    • blockHash: data, 32 bytes - Hash of the block that includes the log. null when log is pending.

    • blockNumber: quantity - Number of block that includes the log. null when log is pending.

    • blockTimestamp: quantity - Hex-encoded unix timestamp (in seconds) of the block that includes the log.

    • address: data, 20 bytes - Address the log originated from.

    • data: data - Non-indexed arguments of the log.

    • topics: array of data, 32 bytes each - Event signature hash and 0 to 3 indexed log arguments.

Example

curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "eth_getFilterLogs",
"params": [
"0x5ace5de3985749b6a1b2b0d3f3e1fb69"
],
"id": 1
}'

eth_getLogs

Returns an array of logs matching a specified filter object.

Leave the --auto-log-bloom-caching-enabled command line option at the default value of true to improve log retrieval performance.

caution

Using eth_getLogs to get logs from a large range of blocks, especially an entire chain from its genesis block, might cause Besu to hang for an indeterminable amount of time while generating the response. We recommend setting a range limit using the --rpc-max-logs-range option (or leaving it at its default value of 1000).

Parameters

  • filterOptions: object - Filter options object.

    • fromBlock: quantity | tag - (Optional) Integer block number or latest, pending, earliest. See block parameter. The default is latest.

    • toBlock: quantity | tag - (Optional) Integer block number or latest, pending, earliest. See block parameter. The default is latest.

    • address: data | array - (Optional) Contract address or array of addresses from which logs originate.

    • topics: array of data, 32 bytes each - (Optional) Array of topics by which to filter logs.

    • blockHash: data, 32 bytes - (Optional) Hash of block for which to return logs. If you specify blockHash, you cannot specify fromBlock and toBlock.

Returns

  • List of log objects.

    • removed: tag - true if log removed because of a chain reorganization. false if a valid log.

    • logIndex: quantity, integer - Log index position in the block. null when log is pending.

    • transactionIndex: quantity, integer - Index position of the starting transaction for the log. null when log is pending.

    • transactionHash: data, 32 bytes - Hash of the starting transaction for the log. null when log is pending.

    • blockHash: data, 32 bytes - Hash of the block that includes the log. null when log is pending.

    • blockNumber: quantity - Number of block that includes the log. null when log is pending.

    • blockTimestamp: quantity - Hex-encoded unix timestamp (in seconds) of the block that includes the log.

    • address: data, 20 bytes - Address the log originated from.

    • data: data - Non-indexed arguments of the log.

    • topics: array of data, 32 bytes each - Event signature hash and 0 to 3 indexed log arguments.

Example

curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "eth_getLogs",
"params": [
{
"fromBlock": "0x16e2a9a",
"toBlock": "0x16e2a9a",
"address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"topics": []
}
],
"id": 1
}'

eth_newBlockFilter

Creates a filter to retrieve new block hashes. To poll for new blocks, use eth_getFilterChanges.

Parameters

  • None

Returns

  • Filter ID.

Example

curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "eth_newBlockFilter",
"params": [],
"id": 1
}'

eth_newFilter

Creates a log filter. To poll for logs associated with the created filter, use eth_getFilterChanges. To get all logs associated with the filter, use eth_getFilterLogs.

Parameters

  • filterOptions: object - Filter options object.

    • fromBlock: quantity | tag - (Optional) Integer block number or latest, pending, earliest. See block parameter. The default is latest.

    • toBlock: quantity | tag - (Optional) Integer block number or latest, pending, earliest. See block parameter. The default is latest.

    • address: data | array - (Optional) Contract address or array of addresses from which logs originate.

    • topics: array of data, 32 bytes each - (Optional) Array of topics by which to filter logs.

    • blockHash: data, 32 bytes - (eth_getLogs only) (Optional) Hash of block for which to return logs. If you specify blockHash, you cannot specify fromBlock and toBlock.

Returns

  • Filter ID.

Example

curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "eth_newFilter",
"params": [
{
"fromBlock": "earliest",
"toBlock": "latest",
"topics": []
}
],
"id": 1
}'

eth_newPendingTransactionFilter

Creates a filter to retrieve new pending transactions hashes. To poll for new pending transactions, use eth_getFilterChanges.

Parameters

  • None

Returns

  • Filter ID.

Example

curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "eth_newPendingTransactionFilter",
"params": [],
"id": 1
}'

eth_uninstallFilter

Uninstalls a filter with the specified ID. When a filter is no longer required, call this method.

Filters time out when not requested by eth_getFilterChanges or eth_getFilterLogs for 10 minutes.

Parameters

  • filterId: string - Filter ID.

Returns

  • Indicates if the filter is successfully uninstalled.

Example

curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "eth_uninstallFilter",
"params": [
"0x70355a0b574b437eaa19fe95adfedc0a"
],
"id": 1
}'