Watch events

Filter events on arguments

EventsTrigger type triggers allows us to look for specific conditions linked to the emission of an Event. The usage is fairly straightforward:

{
  "name": "More than 100 QNT are purchased on IDEX",
  "type": "EventsTrigger",
  "statement": {
    "contract": {
      "address": "0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208",
      "abi": [{...}]
    },
    "filters": [
      {
        "method": {
          "name": "Trade"
        },
        "parameter": {
          "name": "tokenBuy",
          "type": "address"
        },
        "type": "CheckEventParameter",
        "condition": {
          "attribute": "0x4a220e6096b25eadb88358cb44068a3248254675",
          "predicate": "Eq"
        }
      },
      {
        "method": {
          "name": "Trade"
        },
        "parameter": {
          "name": "amountBuy",
          "type": "uint256"
        },
        "type": "CheckEventParameter",
        "condition": {
          "attribute": "100",
          "predicate": "BiggerThan"
        }
      }
    ]
  },
  "actions": [
    {
      "type": "Email",
      "attributes": {
        "body": "\nBlockNumber is $BlockNumber$\nBlockHash is $BlockHash$\nTransactionHash is $TransactionHash$\nBlockTimestamp is $BlockTimestamp$\n\nEvent name is: $MethodName$",
        "subject": "$MethodName$ - Crazy about QNT",
        "to": [
          "bill@alice.org"
        ]
      }
    }
  ]
}

If the event accepts arrays, you can also filter on specific elements (23rd element, in this example):

{
        "method": {
          "name": "MyEventName"
        },
        "parameter": {
          "name": "ManyIntsArray",
          "type": "uint256[47]",
          "index": 22
        },
        "type": "CheckEventParameter",
        "condition": {
          "attribute": "31415",
          "predicate": "BiggerThan"
        }
}

Or you can check if a value is included in the entire array passed as an argument to the Event:

{
        "method": {
          "name": "MyEventName"
        },
        "parameter": {
          "name": "MyAddressesArray",
          "type": "address[]",
          "index": 10
        },
        "type": "CheckEventParameter",
        "condition": {
          "attribute": "0x7Be8076f4EA4A4AD08075C2508e481d6C946D12b",
          "predicate": "IsIn"
        }
}

Last updated