Combine conditions using these operators and functions.
Comparison Operators
| Operator | Description | Example |
|---|
== | Equal | tx.value == 0 |
!= | Not equal | tx.to != null |
> / >= | Greater than (or equal) | tx.value > 100 ether |
< / <= | Less than (or equal) | tx.gas < 21000 |
and | Logical AND | tx.value > 0 and tx.to != null |
or | Logical OR | tx.value == 0 or tx.gas > 1000000 |
not | Logical NOT | not tx.from in (whitelist) |
in | Membership (see Lists & Macros) | tx.to in (known_dex_routers) |
String Functions
Use these functions for string matching and manipulation.
| Function | Description | Example |
|---|
contains(field, "text") | Check if field contains text | contains(tx.to, "0x742d") |
startswith(field, "prefix") | Check if field starts with prefix | startswith(tx.input, "0xa9059cbb") |
endswith(field, "suffix") | Check if field ends with suffix | endswith(tx.to, "abcd") |
matches(field, "regex") | Check if field matches regex pattern | matches(tx.hash, "^0x[a-f0-9]{64}$") |
len(field) | Get length of field | len(tx.input) > 1000 |
String Comparisons: All string comparisons are case-insensitive for addresses and hex values.
Array Methods
When working with arrays (tx.logs, tx.transfers, tx.approvals), use chained methods:
.any(condition) - Check if any element matches
.count(condition) - Count elements matching condition
See Array Methods for complete documentation.
Examples
Combining Operators
# Multiple conditions with AND
condition: >
tx.value > 100 ether and
tx.to in (monitored_addresses) and
tx.status == 1
# OR conditions
condition: >
tx.from == "0x..." or
tx.to == "0x..."
# NOT condition
condition: >
not tx.from in (whitelist)
# Function selector check
condition: >
startswith(tx.input, "0xa9059cbb") and
tx.value > 0
Using with Arrays
# Array method with other conditions
condition: >
tx.logs.any(event_name == "Transfer") and
tx.value > 100 ether
# Count with comparison
condition: >
tx.transfers.count(from != "") > 10 and
tx.gas_used > 1000000
Next Steps