Skip to main content
Array methods allow you to search, filter, and count elements in transaction data arrays. Blocklight supports two methods: .any() and .count().

Supported Arrays

.any() Method

Check if any element in an array matches a condition.

Syntax

Examples

.count() Method

Count how many elements match a condition, then compare the count.

Syntax

Supported Comparisons

  • > - Greater than
  • < - Less than
  • >= - Greater than or equal
  • <= - Less than or equal
  • == - Equal to
  • != - Not equal to

Examples

Combining with Other Conditions

Array methods work seamlessly with logical operators (and, or, not):

Available Fields in Arrays

tx.logs Fields

Raw Fields (always available): Parsed Fields (automatically added for known events): For Transfer events (event_name == "Transfer"): For Approval events (event_name == "Approval"):
Automatic Parsing: When Blocklight recognizes an event (Transfer, Approval), it automatically parses and adds the relevant fields (from, to, amount, etc.) to the log entry. This means you can use tx.logs.any(event_name == "Transfer" and to == "0x...") directly.Recognized Events: Transfer, Approval, ApprovalForAll, Swap, UnknownEvent Categories: Transfer, Approval, Swap (more categories will be added as we expand event recognition)When to Use event_name vs event_category:
  • Use event_name when you need a specific event (e.g., only Transfer, not ApprovalForAll)
  • Use event_category when you want to detect any event in a category (e.g., all approval-related events)
Address Format: Parsed addresses (from, to, owner, spender) are padded to 32 bytes (64 hex characters) as they appear in event topics. See Fields for details.

Limitations

Not Supported

Direct array index access:
Complex nested conditions inside array methods:

Workarounds

For complex conditions, use multiple .any() or .count() calls:

Common Patterns

Token Burn Detection

Multiple Transfers

Next Steps

Fields

Learn about transaction fields

Examples

See complete rule examples