Watch transactions

Filter transactions on basic fields and decoded data field

TransactionsTrigger type triggers enables to filter transactions by:

  • checking the value of Ethereum transactions' basic fields: from, to, value, gas, gas price, nonce. In the JSON data structure any of this filter is called BasicFilter.

  • if the transaction calls a function from a smart contract, the name of that function. This filter is called CheckFunctionCalled.

  • if the transaction calls a function from a smart contract, the value of the arguments passed to that function. This filter is called CheckFunctionParameter.

CheckFunctionParameteron parameter X of function Y already implies a CheckFunctionCalledon function Y. You don't have to specify it twice.

Both CheckFunctionParameter and CheckFunctionCalled need the contract's ABI because they need to decode the data field. If you create your trigger from the web wizard, we will try to fetch it from Etherscan; failing that, we will ask you to insert the ABI yourself. If you are creating the trigger via GraphQL APIs, it is your responsibility to provide the ABI.

BasicFilter

A short recap about data types and supported predicates you can use to apply filters:

Field name

Supported predicates

Type

from

Eq

address (as string)

to

"

address (as string)

value

Eq, SmallerThan, BiggerThan

int

gas

"

int

gas price

"

int

nonce

"

int

Note: gas price and valueare expressed in wei.

An example:

{
"condition": {
"attribute": "0xcf96ca897a757629040402f0c2b86d20890b540d",
"predicate": "Eq"
},
"parameter": {
"name": "from"
},
"type": "BasicFilter"
}

CheckFunctionCalled

An example:

{
"type": "CheckFunctionCalled",
"method": {
"name": "trade"
}
}

CheckFunctionParameter

An example:

{
"type": "CheckFunctionParameter",
"method": {
"name": "MyFunctionName"
},
"parameter": {
"name": "MyVariableName",
"type": "int128"
},
"condition": {
"predicate": "BiggerThan",
"attribute": "44"
}
}

Say the function parameter is an array, and we want to check the value of a specific element of that array. We can check the value of the third element (index: 2, because we start counting from 0) of the MyArrayParameterName array, which is a fixed-size (8 uint256 elements) array, this way:

{
"type": "CheckFunctionParameter",
"method": {
"name": "MyFunctionName"
},
"parameter": {
"name": "MyArrayParameterName",
"type": "uint256[8]",
"index": 2
},
"condition": {
"predicate": "BiggerThan",
"attribute": "44"
}
}

Here is a summary of supported types and predicates:

Type

Supported predicates

int8...256, uint8...256

Eq, SmallerThan, BiggerThan

int8...256[N], uint8...256[N], address[N], string[N], bytes1...32[N]

Eq, SmallerThan, BiggerThan, IsIn*

address, string, bytes1...32, bool

Eq

Predicates Eq, SmallerThan and BiggerThan applied on entire arrays (not specific elements) refer to the length of the array, e.g. len(Array) > X.

Using the predicate IsIn with attribute foo on MyArray simply means "At least one element of MyArray is equal to foo"

A full example

Here is a full example of a TransactionsTrigger (including actions):

{
"name": "A Transaction Trigger Example",
"type": "TransactionsTrigger",
"statement": {
"contract": {
"address": "0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208",
"abi": { ... }
},
"filters": [
{
"condition": {
"attribute": "0xcf96ca897a757629040402f0c2b86d20890b540d",
"predicate": "Eq"
},
"parameter": {
"name": "from"
},
"type": "BasicFilter"
},
{
"type": "CheckFunctionParameter",
"method": {
"name": "trade"
},
"parameter": {
"name": "tradeValues",
"type": "uint256[8]",
"index": 0
},
"condition": {
"predicate": "BiggerThan",
"attribute": "100"
}
},
{
"type": "CheckFunctionParameter",
"method": {
"name": "trade"
},
"parameter": {
"name": "tradeValues",
"type": "uint256[8]",
"index": 0
},
"condition": {
"predicate": "SmallerThan",
"attribute": "150"
}
},
{
"type": "CheckFunctionParameter",
"method": {
"name": "trade"
},
"parameter": {
"name": "tradeAddresses",
"type": "address[4]",
"index": 0
},
"condition": {
"predicate": "Eq",
"attribute": "0xe41d2489571d322189246dafa5ebde1f4699f498"
}
}
] // End of filters
}, // End of "Statement"
"actions": [
{
"type": "Email",
"attributes": {
"body": "Lorem ipsum...",
"subject": "This is a subject",
"to": [
"hi@myaddress.com"
]
}
},
{
"type": "Webhook",
"attributes": {
"uri": "https//www.foo.bar"
}
},
{
"type": "Slack",
"attributes": {
"uri": "https://hooks.slack.com/services/xxx/yyy/zzz",
"body": "Lorem ipsum..."
}
},
{
"type": "Telegram",
"attributes": {
"body": "Lorem ipsum...",
"chatid": "123456",
"format": "HTML",
"token": "secret"
}
},
{
"type": "Twitter",
"attributes": {
"status": "hello tweet",
"token": "my token",
"secret": "my secret"
}
}
] // end of actions
} // end of trigger