Skip to main content
Complete reference of transaction fields available in rule conditions. All fields are always available and don’t require any special configuration.

Basic Transaction Fields

Essential transaction information available in every transaction.

Block Data

Block-level context for the transaction.

Function Detection

Blocklight provides three ways to detect function calls, each with different use cases:

Using tx.function_selector (Raw Selector)

The raw 4-byte function selector extracted from transaction input. Use this when:
  • You need to detect a function that’s not in Blocklight’s database
  • You want maximum precision and control
  • You’re monitoring a specific protocol’s custom functions

Using tx.function_name (Specific Function)

The human-readable function name from Blocklight’s function database. Use this when:
  • You want to detect a specific function (e.g., only transfer, not transferFrom)
  • You need human-readable conditions for better maintainability
  • The function is in Blocklight’s database

Using tx.function_category (Function Group)

The category that groups related functions together. Use this when:
  • You want to detect any function in a category (e.g., all transfer functions)
  • You need broad detection without listing every function variant
  • You want rules that automatically include new functions as they’re added to the database
Available Function Categories: Transfer, Approval, Swap, Liquidity, Lending, FlashLoan, Multicall, Mint, Burn, Claim Available Event Categories: Transfer, Approval, Swap
Note: Function categories and event categories are designed to be consistent where possible. However, not all function categories have corresponding event categories because functions represent what was called while events represent what was emitted. Some operations (like Liquidity, Lending, FlashLoan) may emit standard events like Transfer or protocol-specific events that vary by implementation.
Function Database: Blocklight includes a database of common function selectors (ERC-20, ERC-721, Uniswap, Aave, etc.). If a function is not in the database, tx.function_name and tx.function_category will be empty, but tx.function_selector will always be available.Backward Compatibility: You can still use startswith(tx.input, "0x...") for raw selector matching.

When to Use Each Field

Recommendation: Start with tx.function_category for broad detection, then use tx.function_name or tx.function_selector when you need more specificity.

Arrays: Event Logs with Automatic Parsing

Blocklight provides a single array tx.logs for all event logs, with automatic parsing of known events.

tx.logs - Event Logs (Unified Array)

All event logs emitted by contracts. Use with array methods (.any(), .count()). 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 without needing separate arrays.Recognized Events: Transfer, Approval, ApprovalForAll, Swap, UnknownEvent Categories: Transfer, Approval, Swap (more categories will be added as we expand event recognition)Address Format: Parsed addresses (from, to, owner, spender) are padded to 32 bytes (64 hex characters) as they appear in event topics. Example: 0x000000000000000000000000742d35cc6634c0532925a3b844bc9e7595f0beb

When to Use tx.logs.any() vs tx.function_name

Key Difference:
  • tx.function_name / tx.function_category: Detects the function being called in the transaction (from tx.input)
  • tx.logs.any(event_name == ...) / tx.logs.any(event_category == ...): Detects events emitted during transaction execution (from tx.logs)
Use tx.function_name / tx.function_category when:
  • You want to detect what function was called in the transaction
  • You’re monitoring function calls to specific contracts
  • Example: tx.function_category == "Transfer" detects when someone calls a transfer function
Use tx.logs.any(event_name == ...) / tx.logs.any(event_category == ...) when:
  • You want to detect events emitted during execution
  • You need to check event parameters (from, to, amount, etc.)
  • You’re monitoring token transfers, approvals, or other on-chain events
  • Example: tx.logs.any(event_category == "Transfer" and to == "0x...") detects Transfer events with specific parameters
Common Pattern: Combine both for comprehensive detection:

Unit Suffixes

Use these suffixes for better readability. Blocklight automatically converts units for you.

Choosing the Right Field: Functions vs Events

Understanding when to use function detection vs event detection is crucial for writing effective rules.

Functions: What Was Called

Fields: tx.function_selector, tx.function_name, tx.function_category Use when:
  • You want to detect what function was called in the transaction
  • You’re monitoring function calls to specific contracts
  • You need to know the exact function being invoked
Examples:
Key Point: Functions are detected from tx.input (the calldata sent with the transaction).

Events: What Was Emitted

Fields: tx.logs.any(event_name == ...), tx.logs.any(event_category == ...) Use when:
  • You want to detect events emitted during transaction execution
  • You need to check event parameters (from, to, amount, etc.)
  • You’re monitoring token transfers, approvals, or other on-chain events
Examples:
Key Point: Events are detected from tx.logs (events emitted by contracts during execution).

When to Use Each

Common Patterns

Detect both function calls AND events:
Detect Swap operations (function call OR event):
Detect function call with specific event:

Field Naming Patterns

All fields follow consistent patterns:
  • Direct properties: tx.value, tx.hash, tx.from, tx.function_selector, tx.function_name, tx.function_category
  • Nested structures: tx.block.timestamp, tx.block.number
  • Arrays: tx.logs (use with array methods) - includes event_name and event_category

Next Steps

Array Methods

Learn how to use .any() and .count() with arrays

Operators

See all available operators and functions

Examples

See complete rule examples using these fields

Placeholders

Use placeholders in alert messages