Skip to main content
Combine conditions using these operators and functions.

Comparison Operators

OperatorDescriptionExample
==Equaltx.value == 0
!=Not equaltx.to != null
> / >=Greater than (or equal)tx.value > 100 ether
< / <=Less than (or equal)tx.gas < 21000
andLogical ANDtx.value > 0 and tx.to != null
orLogical ORtx.value == 0 or tx.gas > 1000000
notLogical NOTnot tx.from in (whitelist)
inMembership (see Lists & Macros)tx.to in (known_dex_routers)

String Functions

Use these functions for string matching and manipulation.
FunctionDescriptionExample
contains(field, "text")Check if field contains textcontains(tx.to, "0x742d")
startswith(field, "prefix")Check if field starts with prefixstartswith(tx.input, "0xa9059cbb")
endswith(field, "suffix")Check if field ends with suffixendswith(tx.to, "abcd")
matches(field, "regex")Check if field matches regex patternmatches(tx.hash, "^0x[a-f0-9]{64}$")
len(field)Get length of fieldlen(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