.any() and .count().
Supported Arrays
| Array | Description | Always Available? |
|---|---|---|
tx.logs | Event logs with automatic parsing for known events | ✅ Yes |
.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):
| Field | Type | Description | Example |
|---|---|---|---|
address | address | Contract that emitted the log | tx.logs.any(address == "0x...") |
event_signature | string | Event signature hash (topic[0]) | tx.logs.any(event_signature == "0xddf...") |
event_name | string | Parsed event name | tx.logs.any(event_name == "Transfer") |
event_category | string | Event category (group of related events) | tx.logs.any(event_category == "Transfer") |
data | string | Log data (hex string) | tx.logs.any(data != "0x") |
log_index | uint | Index of the log in the transaction | tx.logs.any(log_index == 0) |
block_number | uint64 | Block number where the log was emitted | tx.logs.any(block_number > 18000000) |
tx_index | uint | Transaction index in the block | tx.logs.any(tx_index == 5) |
removed | bool | Whether the log was removed | tx.logs.any(removed == false) |
event_name == "Transfer"):
| Field | Type | Description | Example |
|---|---|---|---|
contract | address | Token contract address | tx.logs.any(event_name == "Transfer" and contract == "0x...") |
from | address | Source address (padded 32 bytes) | tx.logs.any(event_name == "Transfer" and from == "0x0000...") |
to | address | Destination address (padded 32 bytes) | tx.logs.any(event_name == "Transfer" and to == "0x0000...") |
amount | string | Transfer amount (hex string) | tx.logs.any(event_name == "Transfer" and amount != "0x0") |
event_name == "Approval"):
| Field | Type | Description | Example |
|---|---|---|---|
contract | address | Token contract address | tx.logs.any(event_name == "Approval" and contract == "0x...") |
owner | address | Owner address (padded 32 bytes) | tx.logs.any(event_name == "Approval" and owner == "0x0000...") |
spender | address | Spender address (padded 32 bytes) | tx.logs.any(event_name == "Approval" and spender == "0x0000...") |
amount | string | Approval amount (hex string) | tx.logs.any(event_name == "Approval" and amount == "0xffff...") |
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: