.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_namewhen you need a specific event (e.g., onlyTransfer, notApprovalForAll) - Use
event_categorywhen you want to detect any event in a category (e.g., all approval-related events)
Limitations
Not Supported
❌ Direct array index access: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