Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.moralis.com/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Filters let you control exactly which events trigger webhooks. Events that don’t match your filters are ignored and don’t consume usage. Each chain exposes its own filtering primitives, because each chain models on-chain activity differently.

Filtering by Chain

EVM streams support the most filtering options:
  • Addresses — match transactions where from or to is a watched address
  • Contract events (ABI + topic0) — match specific decoded events emitted by smart contracts
  • Advanced JSON filter expressions — value comparisons, AND/OR logic, special stream variables (see below)
  • filterPossibleSpamAddresses — exclude events involving contracts flagged as spam
Filters are evaluated before webhook delivery and require a valid ABI for the event being filtered when used with decoded event data.For ergonomic primitives (templates) in the Admin Panel, see Create Your First Stream.

Advanced JSON Filter Expressions (EVM)

The JSON filter expression system below is an EVM-only feature. It applies to decoded event data and requires a valid ABI for the event being filtered. Bitcoin and Solana streams use the chain-specific primitives above.

How filters work

Filters are defined as a JSON expression using logical operators and comparison rules.
  • Filters apply to decoded event data
  • Filters require a valid ABI for the event being filtered
  • All conditions must resolve to true for the event to trigger a webhook

Supported Operators

Logical operators

OperatorDescriptionNotesExample
andAll nested conditions must matchNeed at least 2 filters{ "or" : [ {..filter1}, {...filter2} ]}
orAt least one nested condition must matchNeed at least 2 filters{ "and" : [ {..filter1}, {...filter2} ]}

Comparison operators

OperatorDescriptionNotesExample
eqEqual to{ "eq": ["value", "1000"] }
neNot equal to{ "ne": ["address", "0x...325"] }
ltLess thanNumeric values only{ "lt": ["amount", "50"] }
gtGreater thanNumeric values only{ "gt": ["price", "500000"] }
lteLess than or equalNumeric values only{ "lte": ["amount", "100"] }
gteGreater than or equalNumeric values only{ "gte": ["amount", "100"] }
inValue exists in arrayArray required{ "in": ["name": ["alice", "bob"]]}
ninValue not in arrayArray required{ "nin": ["name": ["bob", "alice"]]}

Special Stream Variables (EVM)

Moralis provides special variables that can be used in filters to access stream-level metadata. These are EVM-specific.
VariableDescription
moralis_streams_contract_addressContract emitting the event (lowercase)
moralis_streams_chain_idChain ID for the event
moralis_streams_possibleSpamIndicates if the event is flagged as spam

Example: filter by contract address

{
  "eq": ["moralis_streams_contract_address", "0x0000000000000000000000000000000000000000"]
}
Note: contract addresses must be lowercase. EVM addresses are case-insensitive, so always toLowerCase() for comparison.

Filtering Possible Spam Events (EVM)

Some EVM contract addresses are associated with spam, phishing attempts, or other suspicious activity. Moralis identifies these and flags them with possibleSpam = true. You can exclude these events entirely by enabling:
"filterPossibleSpamAddresses": true
When enabled:
  • Events involving contracts flagged as possible spam are excluded
  • No webhook is sent
  • No usage is consumed
By default, filterPossibleSpamAddresses is set to false. Spam detection is currently EVM-only — see Spam Detection.

Example: Different Rules per Contract (EVM)

You can apply different thresholds depending on which contract emitted the event.
{
  "or": [
    {
      "and": [
        { "eq": ["moralis_streams_contract_address", "0x1"] },
        { "gte": ["value", 1000000000] }
      ]
    },
    {
      "and": [
        { "eq": ["moralis_streams_contract_address", "0x2"] },
        { "gte": ["value", 1000000000000000000000] }
      ]
    }
  ]
}
This is useful when monitoring multiple tokens with different decimals or value semantics.

Example: Filtering by Value Range (EVM)

Filter transfers where the amount is between two values:
{
  "and": [
    { "gt": ["value", 5000000000] },
    { "lt": ["value", 50000000000] }
  ]
}
Example assumes a token with 6 decimals (e.g. USDC).

Example: Mint and Burn Detection (EVM)

A zero address indicates:
  • Mint when used as from
  • Burn when used as to
{
  "or": [
    {
      "and": [
        { "eq": ["from", "0x0000000000000000000000000000000000000000"] },
        { "gte": ["value", 10000000000] }
      ]
    },
    {
      "and": [
        { "eq": ["to", "0x0000000000000000000000000000000000000000"] },
        { "gte": ["value", 10000000000] }
      ]
    }
  ]
}

Important Notes (EVM JSON filters)

  • Filters require a valid ABI for the event being filtered
  • Filters are evaluated before webhook delivery
  • Invalid filters will prevent the stream from working
  • Filters use AND / OR logic only (no implicit precedence)

When to Use Filters

Use filters to:
  • Reduce webhook volume
  • Exclude spam or low-value events (EVM)
  • Trigger alerts only for meaningful activity
  • Apply different logic per contract or chain