Skip to main content
Use placeholders in the output field to include dynamic values in your alert messages. Format: %variable (single % prefix, no trailing %).
Important: Use %tx.hash NOT %tx.hash%. Only one % at the beginning!

Available Placeholders

Basic Transaction Fields

PlaceholderOutput ValueExample
%tx.hashTransaction hash0xd6343c3d...
%tx.fromSender address0x2fb074...
%tx.toRecipient address0x6c3ea9...
%tx.valueValue in wei (string)1000000000000000000
%tx.value_ethValue in ETH (formatted to 4 decimals)1.0000
%tx.nonceTransaction nonce952
%tx.gasGas limit21000
%tx.gas_usedActual gas consumed102876
%tx.gas_priceGas price in wei (string)100000000000
%tx.gas_price_gweiGas price in gwei (formatted to 2 decimals)100.00
%tx.inputTransaction input data (hex)0x095ea7b3...
%tx.function_selectorFunction selector (4 bytes, hex)0xa9059cbb
%tx.function_nameFunction name (if in database)transfer(address,uint256)
%tx.function_categoryFunction category (if in database)Transfer
%tx.block.numberBlock number18500000
%tx.block.timestampBlock timestamp (Unix timestamp)1705312200
%tx.block_hashBlock hash0x1234abcd...
%tx.tx_indexTransaction index in block5
%tx.chainChain identifierethereum
%tx.statusTransaction status1 (success) or 0 (failed)
%tx.logs_countNumber of event logs5
%tx.timestampTimestamp (RFC3339 format)2024-01-15T10:30:00Z
%tx.timestamp_unixUnix timestamp (seconds)1705312200

Matched Log Placeholders

When a rule uses tx.logs.any(...) in its condition, you can access information about the log that matched using these placeholders: Raw Fields (always available):
PlaceholderOutput ValueExample
%tx.logs.matched.addressContract address that emitted the matched log0x6c3ea9...
%tx.logs.matched.event_nameName of the matched eventTransfer
%tx.logs.matched.event_categoryCategory of the matched eventTransfer
%tx.logs.matched.event_signatureEvent signature hash (topic[0])0xddf252ad...
%tx.logs.matched.log_indexIndex of the matched log in the transaction0
%tx.logs.matched.dataLog data (hex string)0x0000000000000000000000000000000000000000000000000de0b6b3a7640000
%tx.logs.matched.block_numberBlock number where the log was emitted18500000
%tx.logs.matched.tx_indexTransaction index in the block5
%tx.logs.matched.removedWhether the log was removed (true/false)false
Parsed Fields (automatically added for known events): For Transfer events (event_name == "Transfer"):
PlaceholderOutput ValueExample
%tx.logs.matched.contractToken contract address0x6c3ea9...
%tx.logs.matched.fromSource address (padded 32 bytes)0x0000000000000000000000001234567890123456789012345678901234567890
%tx.logs.matched.toDestination address (padded 32 bytes)0x0000000000000000000000005678901234567890123456789012345678901234
%tx.logs.matched.amountTransfer amount (hex string)0x2386f26fc10000
For Approval events (event_name == "Approval"):
PlaceholderOutput ValueExample
%tx.logs.matched.contractToken contract address0x6c3ea9...
%tx.logs.matched.ownerOwner address (padded 32 bytes)0x0000000000000000000000001234567890123456789012345678901234567890
%tx.logs.matched.spenderSpender address (padded 32 bytes)0x0000000000000000000000005678901234567890123456789012345678901234
%tx.logs.matched.amountApproval amount (hex string)0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
When Available: These placeholders are only populated when:
  • The rule condition uses tx.logs.any(...)
  • The condition matches (rule triggers)
  • The matched log is from tx.logs
Parsed Fields: Fields like from, to, amount, owner, spender, and contract are automatically parsed and added to the log entry when Blocklight recognizes the event (Transfer or Approval). If the matched log is not a recognized event, these parsed fields will be empty strings.If no item matched or the condition doesn’t use tx.logs.any(...), all placeholders will be empty strings.

Format Details

  • %tx.value: Raw wei value as string (e.g., "1000000000000000000")
  • %tx.value_eth: Formatted ETH value with 4 decimal places (e.g., "1.0000")
  • %tx.gas_price: Raw gas price in wei as string (e.g., "100000000000")
  • %tx.gas_price_gwei: Formatted gas price in gwei with 2 decimal places (e.g., "100.00")
  • %tx.timestamp: RFC3339 formatted timestamp (e.g., "2024-01-15T10:30:00Z")
  • %tx.timestamp_unix: Unix timestamp in seconds (e.g., "1705312200")
  • %tx.block.number: Block number (same syntax as in conditions: tx.block.number)
  • %tx.block.timestamp: Block timestamp in Unix seconds (same syntax as in conditions: tx.block.timestamp)
  • Numeric fields: All converted to strings (e.g., %tx.nonce"952")
  • Address fields: Full address in hex format (e.g., %tx.from"0x2fb074...")
Consistency: Placeholders use the same syntax as conditions. For example:
  • Condition: tx.block.number > 18000000
  • Placeholder: %tx.block.number
This ensures that any field you can use in a condition can also be used as a placeholder in the output.

Example Usage

Basic Transaction Information

- rule: High Value Transfer
  desc: Detects large ETH transfers
  tags: ["high-value"]
  condition: tx.value > 100 ether
  output: >
    Large transfer detected!
    From: %tx.from
    To: %tx.to
    Amount: %tx.value_eth ETH
    TX: %tx.hash
    Block: %tx.block.number (%tx.block_hash)
    Gas: %tx.gas_used / %tx.gas
    Chain: %tx.chain
    Time: %tx.timestamp
  priority: WARNING
  enabled: true

Using Matched Log Placeholders

- rule: Transfer Event Detected
  desc: Detects Transfer events in transaction logs
  tags: ["events", "erc20"]
  condition: tx.logs.any(event_name == "Transfer")
  output: >
    Transfer event detected!
    Event: %tx.logs.matched.event_name
    Contract: %tx.logs.matched.address
    Signature: %tx.logs.matched.event_signature
    Log Index: %tx.logs.matched.log_index
    TX: %tx.hash
  priority: NOTICE
  enabled: true

Using Parsed Transfer Fields

- rule: High Value ERC-20 Transfer
  desc: Detects large ERC-20 token transfers
  tags: ["erc20", "high-value"]
  condition: >
    tx.logs.any(event_name == "Transfer" and to == "0x0000000000000000000000001234567890123456789012345678901234567890")
  output: >
    High value transfer detected!
    Event: %tx.logs.matched.event_name
    Contract: %tx.logs.matched.contract
    From: %tx.logs.matched.from
    To: %tx.logs.matched.to
    Amount: %tx.logs.matched.amount
    TX: %tx.hash
  priority: WARNING
  enabled: true

Using Parsed Approval Fields

- rule: Unlimited Approval Detected
  desc: Detects unlimited token approvals
  tags: ["erc20", "approval", "security"]
  condition: >
    tx.logs.any(event_name == "Approval" and amount == "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
  output: >
    Unlimited approval detected!
    Event: %tx.logs.matched.event_name
    Contract: %tx.logs.matched.contract
    Owner: %tx.logs.matched.owner
    Spender: %tx.logs.matched.spender
    Amount: %tx.logs.matched.amount (unlimited)
    TX: %tx.hash
  priority: WARNING
  enabled: true

Using Function Name and Category Placeholders

- rule: ERC-20 Transfer Function
  desc: Detects ERC-20 transfer() function calls
  tags: ["erc20", "function"]
  condition: tx.function_name == "transfer(address,uint256)"
  output: >
    Transfer function called!
    Function: %tx.function_name
    Category: %tx.function_category
    Selector: %tx.function_selector
    From: %tx.from
    To: %tx.to
    TX: %tx.hash
  priority: NOTICE
  enabled: true

Using Function Category Placeholders

- rule: Any Transfer Function
  desc: Detects any transfer-related function call
  tags: ["function", "transfer"]
  condition: tx.function_category == "Transfer"
  output: >
    Transfer function category detected!
    Function: %tx.function_name
    Category: %tx.function_category
    Selector: %tx.function_selector
    From: %tx.from
    To: %tx.to
    TX: %tx.hash
  priority: NOTICE
  enabled: true

Using Event Category Placeholders

- rule: Transfer Event Category
  desc: Detects any Transfer category event
  tags: ["events", "transfer"]
  condition: tx.logs.any(event_category == "Transfer")
  output: >
    Transfer event category detected!
    Event: %tx.logs.matched.event_name
    Category: %tx.logs.matched.event_category
    Contract: %tx.logs.matched.contract
    From: %tx.logs.matched.from
    To: %tx.logs.matched.to
    TX: %tx.hash
  priority: NOTICE
  enabled: true

Using Swap Event Category Placeholders

- rule: Swap Event Category
  desc: Detects any Swap category event
  tags: ["events", "swap", "defi"]
  condition: tx.logs.any(event_category == "Swap")
  output: >
    Swap event category detected!
    Event: %tx.logs.matched.event_name
    Category: %tx.logs.matched.event_category
    Contract: %tx.logs.matched.address
    Signature: %tx.logs.matched.event_signature
    TX: %tx.hash
  priority: NOTICE
  enabled: true

Best Practices

  1. Use %tx.value_eth for human-readable amounts instead of %tx.value (which shows raw wei)
  2. Include transaction hash (%tx.hash) for easy lookup on block explorers
  3. Format consistently - numeric placeholders are already formatted, don’t add extra formatting

Next Steps