Transaction Filter
When handling transaction streams across various APIs, including webhooks and backfilling operations, we consistently employ the TransactionFilter
specification to ensure that filters are set up uniformly. This specification outlines the data structures and criteria used to select the desired transactions.
Using a standardized TransactionFilter
across different API interfaces streamlines the process and avoids redundancy. Below is the JSON representation of the complete TransactionFilter
structure for reference. Developers can adapt this template to meet the specific filtering requirements of their individual use cases.
TransactionFilter Overview
Our TransactionFilter
currently supports granular instruction filtering based on program or individual instruction parameters. In upcoming releases, we plan to expand its functionality to include filters for events and accounts. To facilitate the discovery of programs and instruction activities, we recommend utilizing our Programs API
, which provides the necessary discriminators.
TransactionFilter JSON Schema
Below is the TransactionFilter
structure in its JSON format. Note the inclusion of optional parameters id
and name
, which can aid in event stream identification if needed.
Key Definitions
id
: (optional) A unique identifier for the transaction filter.name
: (optional) A descriptive name for the transaction filter.include
: Defines the rules for matching transactions.instructions
: An array of objects to specify instruction filters.address
: The address of the program (required).discriminator
: The unique identifier for the instruction (optional).discriminatorType
: The type of discriminator, such asu8
,u16
,u32
, oranchor
(optional).
Leverage this TransactionFilter
structure to customize your filtering needs according to the specifications of the individual use cases. Keep an eye out for our updates, which will enhance the filtering capabilities with additional features.
Examples
Example 1: Basic Program Address Filter
To track transactions associated with a specific program, you can set the address field in the instructions array:
Example 2: Instruction Discriminator Filter
To filter transactions based on a particular type of instruction within a program, include the discriminator:
Example 3: Combining Multiple Required instructions
For more complex filtering, you can combine multiple instruction criteria in the instructions array:
Example 4: Combining Multiple Filters
Want to monitor several instruction types? Simply stack your filters in one go like this:
Customize each filter block with the specific instruction details. This way, you capture all relevant instruction types in a single filter configuration. Something like this:
These examples should get you started on using TransactionFilter
to track transactions that are most relevant to your application logic. Adjust the filters to your specific needs by tweaking the parameters provided.
Last updated