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
Copy
# Using full function signaturecondition: tx.function_name == "transfer(address,uint256)"# Using short function name (without parameters)condition: tx.function_name == "transfer"# ERC-20 approvecondition: tx.function_name == "approve(address,uint256)"
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
Copy
# Detect any transfer function (transfer, transferFrom, safeTransferFrom, etc.)condition: tx.function_category == "Transfer"# Detect any swap function (all Uniswap swap variants)condition: tx.function_category == "Swap"# Detect any approval functioncondition: tx.function_category == "Approval"
Available Function Categories:Transfer, Approval, Swap, Liquidity, Lending, FlashLoan, Multicall, Mint, Burn, ClaimAvailable 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.
All event logs emitted by contracts. Use with array methods (.any(), .count()).Raw Fields (always available):
Property
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)
Parsed Fields (automatically added for known events):For Transfer events (event_name == "Transfer"):
Property
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")
For Approval events (event_name == "Approval"):
Property
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 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
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:
Copy
# Detect any transfer function callcondition: tx.function_category == "Transfer"# Detect specific transfer functioncondition: tx.function_name == "transfer"# Detect custom function (not in database)condition: tx.function_selector == "0x12345678"
Key Point: Functions are detected from tx.input (the calldata sent with the transaction).
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:
Copy
# Detect any Transfer eventcondition: tx.logs.any(event_category == "Transfer")# Detect specific Transfer event with parameterscondition: tx.logs.any(event_name == "Transfer" and to == "0x...")# Detect any Approval eventcondition: tx.logs.any(event_category == "Approval")# Detect any Swap eventcondition: tx.logs.any(event_category == "Swap")
Key Point: Events are detected from tx.logs (events emitted by contracts during execution).