Skip to main content
@tevm/voltaire
@tevm/voltaire / primitives/LogFilter

primitives/LogFilter

Classes

InvalidLogFilterError

Defined in: src/primitives/LogFilter/errors.js:4 Error thrown when LogFilter is invalid

Extends

  • Error

Constructors

Constructor
new InvalidLogFilterError(message, details?): InvalidLogFilterError
Defined in: src/primitives/LogFilter/errors.js:9
Parameters
message
string
details?
object
Returns
InvalidLogFilterError
Overrides
Error.constructor

Properties

details
details: object | undefined
Defined in: src/primitives/LogFilter/errors.js:13
name
name: string
Defined in: src/primitives/LogFilter/errors.js:11
Inherited from
Error.name

Type Aliases

BlockTag

BlockTag = "earliest" | "latest" | "pending"
Defined in: src/primitives/LogFilter/LogFilterType.ts:10 Block identifier for log filter queries

LogFilterType

LogFilterType = object & object
Defined in: src/primitives/LogFilter/LogFilterType.ts:36 Log filter parameters for eth_getLogs and eth_newFilter Filters can specify:
  • Block range (fromBlock/toBlock) OR specific block (blockhash)
  • Contract address(es) to filter by
  • Topic filters for indexed event parameters

Type Declaration

address?
readonly optional address: AddressType | readonly AddressType[]
Single address or array of addresses to filter by
blockhash?
readonly optional blockhash: HashType
Specific block hash (mutually exclusive with fromBlock/toBlock)
fromBlock?
readonly optional fromBlock: BlockNumberType | BlockTag
Starting block number or tag
toBlock?
readonly optional toBlock: BlockNumberType | BlockTag
Ending block number or tag
topics?
readonly optional topics: TopicFilterType
Topic filters (up to 4 indexed parameters)

Type Declaration

[brand]
readonly [brand]: "LogFilter"

Example

// Filter Transfer events to specific address
const filter: LogFilter = {
  fromBlock: "latest",
  address: contractAddr,
  topics: [transferEventSig, null, recipientHash]
};

// Filter by specific block hash
const filter2: LogFilter = {
  blockhash: blockHash,
  address: contractAddr
};

Functions

from()

from(params): LogFilterType
Defined in: src/primitives/LogFilter/from.js:30 Create LogFilter from parameters

Parameters

params
Partial<LogFilterType> Filter parameters

Returns

LogFilterType

Throws

Example

import * as LogFilter from './primitives/LogFilter/index.js';
import * as Address from './primitives/Address/index.js';
import * as BlockNumber from './primitives/BlockNumber/index.js';

// Filter by address and block range
const filter = LogFilter.from({
  fromBlock: BlockNumber.from(1000000),
  toBlock: "latest",
  address: Address.from("0x...")
});

// Filter by specific block hash
const filter2 = LogFilter.from({
  blockhash: Hash.from("0x..."),
  address: Address.from("0x...")
});

isEmpty()

isEmpty(filter): boolean
Defined in: src/primitives/LogFilter/isEmpty.js:14 Check if log filter is empty (no filtering criteria)

Parameters

filter
LogFilterType

Returns

boolean

Example

import * as LogFilter from './primitives/LogFilter/index.js';
const empty = LogFilter.isEmpty(filter); // true if no criteria

matches()

matches(filter, log): boolean
Defined in: src/primitives/LogFilter/matches.js:16 Check if a log entry matches this filter

Parameters

filter
LogFilterType
log
EventLogType<AddressType, readonly HashType[]> Log entry to test

Returns

boolean

Example

import * as LogFilter from './primitives/LogFilter/index.js';
const matches = LogFilter.matches(filter, log);