Search
⌃K

Triggers

A few examples of get-triggers queries

Get all triggers

The following fields can be queried to retrieve all triggers data:
Query
Response
query {
allTriggers {
UUID
name
isActive
createdAt
updatedAt
type
matchesCount
... on EventsTrigger {
statement {
contract {
address
abi
}
filters {
method {
name
}
type
parameter
condition {
predicate
attribute
unit
}
}
}
}
... on TransactionsTrigger {
statement {
contract {
address
abi
}
filters {
type
method {
name
}
parameter
condition {
predicate
attribute
unit
}
}
}
}
... on ContractsTrigger {
statement {
contract {
address
abi
}
method {
name
}
inputs
outputFilters {
returnIndex
condition {
predicate
attribute
unit
}
parameter
}
}
}
actions {
... on EmailAction {
type
attributes {
to
subject
body
}
}
... on WebhookAction {
type
attributes {
uri
}
}
}
}
}
{
"data": {
"allTriggers": [
{
"UUID": "c9cbcb30-927b-4d96-a323-cc48f51bf189",
"name": "My first trigger",
"isActive": true,
"createdAt": "2019-12-19 13:14:16.902706+00",
"updatedAt": "2019-12-19 13:14:16.902706+00",
"type": "EventsTrigger",
"matchesCount": 1,
"statement": {
"contract": {
"address": "0xf92c1ad75005e6436b4ee84e88cb23ed8a290988",
"abi": "[{...}]"
},
"filters": [
{
"method": {
"name": "WhitelistAdded"
},
"type": "CheckEventParameter",
"parameter": {
"name": "account",
"type": "address"
},
"condition": {
"predicate": "Eq",
"attribute": "0x21718c0fbd10900565fa57c76e1862cd3f6a4d8e",
"unit": null
}
}
]
},
"actions": [
{
"type": "Email",
"attributes": {
"to": [
],
"subject": "Event name is: $MethodName$",
"body": "BlockNumber is $BlockNumber$\nBlockHash is $BlockHash$\nTransactionHash is $TransactionHash$\nBlockTimestamp is $BlockTimestamp$\n\nEvent name is: $MethodName$\n\nThis Event was logged by this contract: $ContractAddress$\n\n!account"
}
},
{
"type": "Webhook",
"attributes": {
"uri": "https://webhook.site/ae4b3417-745a-4d7d-aa4a-ac748b5d26f2"
}
}
]
},
{
"UUID": "0f96098d-e505-47d7-a60b-452681523ca9",
"name": "My second trigger",
"isActive": true,
"createdAt": "2019-11-20 15:40:16+00",
"updatedAt": "2019-06-23 02:10:25+00",
"type": "ContractsTrigger",
"matchesCount": 13,
"statement": {
"contract": {
"address": "0x09cabec1ead1c0ba254b09efb3ee13841712be14",
"abi": "[{...}]"
},
"method": {
"name": "getTokenToEthOutputPrice"
},
"inputs": [
{
"type": "uint256",
"value": "1"
}
],
"outputFilters": [
{
"returnIndex": null,
"condition": {
"predicate": "BiggerThan",
"attribute": "140",
"unit": null
},
"parameter": {
"type": "uint256"
}
}
]
},
"actions": [
{
"type": "Email",
"attributes": {
"to": [
],
"subject": "WAC The price of ETH is > 140 on block $BlockNumber$",
"body": "BlockNumber is $BlockNumber$, the matched value is $MatchedValue$, which is smaller than the returned value $ReturnedValues$"
}
}
]
},
{
"UUID": "6228392f-b670-4abb-be71-4b9d9d103c80",
"name": "My third trigger",
"isActive": true,
"createdAt": "2019-12-20 14:18:59.813141+00",
"updatedAt": "2019-12-20 14:18:59.813141+00",
"type": "TransactionsTrigger",
"matchesCount": 3918,
"statement": {
"contract": {
"address": "0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208",
"abi": "[{...}]"
},
"filters": [
{
"type": "BasicFilter",
"method": null,
"parameter": {
"name": "To"
},
"condition": {
"predicate": "Eq",
"attribute": "0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208",
"unit": null
}
},
{
"type": "CheckFunctionParameter",
"method": {
"name": "trade"
},
"parameter": {
"index": 1,
"name": "tradeValues",
"type": "uint256[8]"
},
"condition": {
"predicate": "BiggerThan",
"attribute": "8099997953046032478",
"unit": null
}
},
{
"type": "CheckFunctionParameter",
"method": {
"name": "trade"
},
"parameter": {
"name": "tradeAddresses",
"type": "address[4]"
},
"condition": {
"predicate": "IsIn",
"attribute": "0x4a220e6096b25eadb88358cb44068a3248254675",
"unit": null
}
}
]
},
"actions": [
{
"type": "Email",
"attributes": {
"to": [
],
"subject": "!tradeValues[0] !tradeAddress[1]",
"body": "Hi,\nyou can customize the text of this email using these variables... (by the way, you can put variables in Subject as well!):\n\nBlockNumber is $BlockNumber$\nBlockHash is $BlockHash$\nTransactionHash is $TransactionHash$\nBlockTimestamp is $BlockTimestamp$\nFrom is $From$\nTo is $To$\nValue is $Value$\nGas is $Gas$\nGasPrice is $GasPrice$\nNonce is $Nonce$\n\nFunction name (if the transaction calls a function!) is: $MethodName$\n\nYou can access the function parameters using !ParameterName. If the variable you want to access is an array, you can access a specific element of that array using !ParameterName[0], !ParameterName[1] and so on.\n© 2019 GitHub, Inc."
}
},
{
"type": "Webhook",
"attributes": {
"uri": "https://webhook.site/3e94a980-cc28-4fb3-8733-8e398e20c066"
}
}
]
}
]
}
}
We also support specific trigger-type queries, if you if you are only interested in a specific trigger type.

Get events triggers

Query
Response
query {
eventsTriggers {
UUID
name
isActive
createdAt
updatedAt
type
matchesCount
statement {
contract {
address
abi
}
filters {
type
method {
name
}
parameter
condition {
predicate
attribute
unit
}
}
}
actions {
... on EmailAction {
type
attributes {
to
subject
body
}
}
... on WebhookAction {
type
attributes {
uri
}
}
}
}
}
{
"data": {
"allTriggers": [
{
"UUID": "c9cbcb30-927b-4d96-a323-cc48f51bf189",
"name": "My first trigger",
"isActive": true,
"createdAt": "2019-12-19 13:14:16.902706+00",
"updatedAt": "2019-12-19 13:14:16.902706+00",
"type": "EventsTrigger",
"matchesCount": 1,
"statement": {
"contract": {
"address": "0xf92c1ad75005e6436b4ee84e88cb23ed8a290988",
"abi": "[{...}]"
},
"filters": [
{
"method": {
"name": "WhitelistAdded"
},
"type": "CheckEventParameter",
"parameter": {
"name": "account",
"type": "address"
},
"condition": {
"predicate": "Eq",
"attribute": "0x21718c0fbd10900565fa57c76e1862cd3f6a4d8e",
"unit": null
}
}
]
},
"actions": [
{
"type": "Email",
"attributes": {
"to": [
],
"subject": "Event name is: $MethodName$",
"body": "BlockNumber is $BlockNumber$\nBlockHash is $BlockHash$\nTransactionHash is $TransactionHash$\nBlockTimestamp is $BlockTimestamp$\n\nEvent name is: $MethodName$\n\nThis Event was logged by this contract: $ContractAddress$\n\n!account"
}
},
{
"type": "Webhook",
"attributes": {
"uri": "https://webhook.site/ae4b3417-745a-4d7d-aa4a-ac748b5d26f2"
}
}
]
}
]
}
}

Get contracts triggers

Query
Response
query {
contractsTriggers {
UUID
name
isActive
createdAt
updatedAt
type
matchesCount
statement {
contract {
address
abi
}
method {
name
}
inputs
outputFilters {
returnIndex
condition {
predicate
attribute
unit
}
parameter
}
}
actions {
... on EmailAction {
type
attributes {
to
subject
body
}
}
... on WebhookAction {
type
attributes {
uri
}
}
}
}
}
{
"data": {
"contractsTriggers": [
{
"UUID": "0f96098d-e505-47d7-a60b-452681523ca9",
"name": "My second trigger",
"isActive": true,
"createdAt": "2019-11-20 15:40:16+00",
"updatedAt": "2019-06-23 02:10:25+00",
"type": "ContractsTrigger",
"matchesCount": 13,
"statement": {
"contract": {
"address": "0x09cabec1ead1c0ba254b09efb3ee13841712be14",
"abi": "[{...}]"
},
"method": {
"name": "getTokenToEthOutputPrice"
},
"inputs": [
{
"type": "uint256",
"value": "1"
}
],
"outputFilters": [
{
"returnIndex": null,
"condition": {
"predicate": "BiggerThan",
"attribute": "140",
"unit": null
},
"parameter": {
"type": "uint256"
}
}
]
},
"actions": [
{
"type": "Email",
"attributes": {
"to": [
],
"subject": "WAC The price of ETH is > 140 on block $BlockNumber$",
"body": "BlockNumber is $BlockNumber$, The matched value is $MatchedValue$, which is smaller than the returned value $ReturnedValues$"
}
}
]
}
]
}
}

Get transactions triggers

Query
Response
query {
transactionsTriggers {
UUID
name
isActive
createdAt
updatedAt
type
matchesCount
statement {
contract {
address
abi
}
filters {
type
method {
name
}
parameter
condition {
predicate
attribute
unit
}
}
}
actions {
... on EmailAction {
type
attributes {
to
subject
body
}
}
... on WebhookAction {
type
attributes {
uri
}
}
}
}
}
{
"data": {
"transactionsTriggers": [
{
"UUID": "6228392f-b670-4abb-be71-4b9d9d103c80",
"name": "My third trigger",
"isActive": true,
"createdAt": "2019-12-20 14:18:59.813141+00",
"updatedAt": "2019-12-20 14:18:59.813141+00",
"type": "TransactionsTrigger",
"matchesCount": 3918,
"statement": {
"contract": {
"address": "0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208",
"abi": "[{...}]"
},
"filters": [
{
"type": "BasicFilter",
"method": null,
"parameter": {
"name": "To"
},
"condition": {
"predicate": "Eq",
"attribute": "0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208",
"unit": null
}
},
{
"type": "CheckFunctionParameter",
"method": {
"name": "trade"
},
"parameter": {
"index": 1,
"name": "tradeValues",
"type": "uint256[8]"
},
"condition": {
"predicate": "BiggerThan",
"attribute": "8099997953046032478",
"unit": null
}
},
{
"type": "CheckFunctionParameter",
"method": {
"name": "trade"
},
"parameter": {
"name": "tradeAddresses",
"type": "address[4]"
},
"condition": {
"predicate": "IsIn",
"attribute": "0x4a220e6096b25eadb88358cb44068a3248254675",
"unit": null
}
}
]
},
"actions": [
{
"type": "Email",
"attributes": {
"to": [
],
"subject": "!tradeValues[0] !tradeAddress[1]",
"body": "Hi,\nyou can customize the text of this email using these variables... (by the way, you can put variables in Subject as well!):\n\nBlockNumber is $BlockNumber$\nBlockHash is $BlockHash$\nTransactionHash is $TransactionHash$\nBlockTimestamp is $BlockTimestamp$\nFrom is $From$\nTo is $To$\nValue is $Value$\nGas is $Gas$\nGasPrice is $GasPrice$\nNonce is $Nonce$\n\nFunction name (if the transaction calls a function!) is: $MethodName$\n\nYou can access the function parameters using !ParameterName. If the variable you want to access is an array, you can access a specific element of that array using !ParameterName[0], !ParameterName[1] and so on.\n© 2019 GitHub, Inc."
}
},
{
"type": "Webhook",
"attributes": {
"uri": "https://webhook.site/3e94a980-cc28-4fb3-8733-8e398e20c066"
}
}
]
}
]
}
}

Query a single trigger

Using filters you can retrieve a single trigger by UUID or by name.
Query
Response
query {
allTriggers(filter: {UUID: {eq: "8a30c4e8-e6cf-444b-863e-cf786c7f1a2b"]}}) {
UUID
}
}
{
"data": {
"allTriggers": [
{
"UUID": "2ae04b3c-b008-4183-b13f-e23de4f19f13"
}
]
}
}
Please refer to the filtering record section of this guide for details on how to use the filter argument.
Last modified 3yr ago