Triggers
A trigger determines on which event or by which schedule your function will be executed. Action trigger is configured in tenderly.yaml, if you haven't already, see the configuration.
If the action has just trigger type, it will not run automatically, but you can still use manual triggering. Here is an example of a trigger with just a type:
1
trigger:
2
type: block
Copied!
The trigger also defines the event type for your action, so block trigger will result in your function getting BlockEvent. Take a look at our API to better understand what each event type has (or log event to console, use manual trigger and check out the output).

Block

Block trigger will run your action when a block is mined on a configured network.
1
trigger:
2
type: block
3
block:
4
# This action will run when a block is mined on the network with chain id 1.
5
network: 1
6
# This action will run on every 100th block, eg. 100th, 200th, ...
7
blocks: 100
Copied!
You can also listen to blocks on multiple networks with the same trigger.
1
trigger:
2
type: block
3
block:
4
network:
5
- 1
6
- 42
7
blocks: 100
Copied!

Transaction

Transaction trigger consists of status and filters.
The status field defines at what stage you are listening for transactions. Supported stages are:
  • mined As soon as the transaction has been mined.
  • confirmed10 Exactly 10 blocks have been mined after block which contains a transaction.
  • more coming soon
    ๐ŸŽ‰
    โ€‹
Filters field defines what properties transaction must have for your action to run. Filters is a list and if ANY of the filters is matched, your action will run.
If multiple filters are matched, your actions will still run just once.
Within a single filter AND applies, so the transaction must match ALL fields. Most fields can have value or be a list of values, and if list, OR applies so transaction must match ANY value in the list for a given field.
1
trigger:
2
type: transaction
3
transaction:
4
# This trigger will listen to both mined and confirmed10 streams of transactions.
5
# If you are setting just one, you don't need a list - "status: mined".
6
status:
7
- mined
8
- confirmed10
9
# This trigger has two filters and action will run if the transaction matches
10
# any of them.
11
filters:
12
# Transaction must be from the network with chain id 1, which is a mainnet.
13
- network: 1
14
# Transaction must fail.
15
status: fail
16
# Transaction must be sent to this address.
17
to: 0x2364259ACD20Bd2A8dEfDc628f4099302449fd62
18
# Transaction must be sent from this address.
19
from: 0xDB638EB2d460CE77bDE8a564b7cEd8b43526BbE1
20
21
# Or with more possible values.
22
โ€‹
23
# Transaction must be from either mainnet (1) or kovan (42)
24
- network:
25
- 1
26
- 42
27
# Transaction must fail or succeed. This is just an example, in practice this
28
# is equivalent to not setting the status field at all.
29
status:
30
- fail
31
- success
32
# Transaction must be sent to either of these addresses.
33
to:
34
- 0x885f70E51e7203c0aBf656c10fde2c4194879d70
35
- 0xF215d4Aae591602c9abfbabD0db18DD165ad9288
36
# Transaction must be sent from either of these addresses.
37
from:
38
- 0xC2E52b2697AC97457C2B5FB69944B0537698415A
39
- 0x1c58F4812B16C405B0A4D069aEB527a61fcac849
Copied!
In the example above you can see that string fields can be represented with either values or a list of values. Int fields are represented as either an object or a list of objects following a specific schema.
1
gte: ? # greater or equal than
2
lte: ? # less or equal than
3
ge: ? # greater than
4
le: ? # less than
5
eq: ? # equal to
Copied!
1
trigger:
2
type: transaction
3
transaction:
4
status:
5
- mined
6
filters:
7
- network: 1
8
# Transaction must have a value greater than 100 wei.
9
value:
10
gt: 100
11
# Transaction must have used less than or equal to 100k gas.
12
gasUsed:
13
lte: 100000
14
# Transaction must have a gas limit greater than or equal to 200k.
15
gasLimit:
16
gte: 200000
17
# Transaction fee must be less than 1M gwei.
18
fee:
19
lt: 1000000000
20
21
# Or with more possible values.
22
โ€‹
23
- network: 1
24
# Transaction must have a value between 100 and 1000 wei.
25
value:
26
gt: 100
27
lt: 1000
28
# Transaction must have used less than or equal to 100k gas OR more than 200k gas.
29
gasUsed:
30
- lte: 100000
31
- gte: 100000
32
# Transaction must have a gas limit greater than or equal to 200k OR less than or equal to 100k.
33
gasLimit:
34
- gte: 200000
35
- lte: 100000
36
# Transaction fee must be between 1M and 2M, inclusive.
37
fee:
38
gte: 1000000000
39
lte: 2000000
Copied!
More advanced transaction filters include function invocation or an event emitted on a contract [more coming soon
๐ŸŽ‰
].
The contract must be added to your project before it can be referenced in your triggers.
1
trigger:
2
type: transaction
3
transaction:
4
status:
5
- mined
6
filters:
7
- network: 1
8
# Transaction invoked a function...
9
function:
10
# on contract with this address...
11
contract:
12
address: 0xC2E52b2697AC97457C2B5FB69944B0537698415A
13
# with function name "stake"
14
name: stake
15
# Transaction emitted an event...
16
eventEmitted:
17
# coming from this contract...
18
contract:
19
address: 0xC2E52b2697AC97457C2B5FB69944B0537698415A
20
# with name "Staked"
21
name: Staked
22
โ€‹
23
# Or written in a more compact way
24
โ€‹
25
- network: 1
26
# If put at the top, contract will apply to all fields
27
# that need it but don't have it.
28
contract:
29
address: 0xC2E52b2697AC97457C2B5FB69944B0537698415A
30
function:
31
name: stake
32
eventEmitted:
33
name: Staked
34
โ€‹
35
# Or with multiple values
36
โ€‹
37
- network: 1
38
contract:
39
address: 0xC2E52b2697AC97457C2B5FB69944B0537698415A
40
# Transaction invoked either "stake" or "stakeNew"
41
function:
42
- name: stake
43
- name: stakeNew
44
# Transaction emitted either "Staked" from 0xC2E52b2697AC97457C2B5FB69944B0537698415A...
45
eventEmitted:
46
- name: Staked
47
- contract:
48
address: 0xF215d4Aae591602c9abfbabD0db18DD165ad9288
49
# or "StakedNew" from 0xF215d4Aae591602c9abfbabD0db18DD165ad9288
50
name: StakedNew
Copied!

Webhook

Webhook lets you trigger an action with a POST request.
If you don't want to schedule your action and just want to run when needed with a custom payload, you can set the trigger type to webhook and use a manual trigger.
You can decide if the request should be authenticated or not. If it should be authenticated you must make a request with a valid Tenderly token that can access this action's project.
1
trigger:
2
type: webhook
3
webhook:
4
authenticated: true
Copied!
You can trigger this action with a curl.
1
curl -X POST -H "x-access-key: $TENDERLY_TOKEN" -H "Content-Type: application/json" \
2
https://api.tenderly.co/api/v1/actions/$ACTION_UUID/webhook \
3
-d '{"dataKey": "dataValue"}'
Copied!
You can get this curl generated for your action when you open action in the dashboard.
For non-authenticated webhook, you don't have to pass x-access-key header.
You can access the body from the request in runtime through WebhookEvent. In this example, webhookEvent.payload.dataKey will have value "dataValue"
The payload must be valid JSON and the webhook endpoint will respond with 200 and {} if action was triggered successfully.

Periodic

A periodic trigger means your action will be invoked on a fixed schedule.
1
# Runs every 5 min: 00:00, 00:05, 00:10...
2
trigger:
3
type: periodic
4
periodic:
5
# Supported values for interval are
6
# {5m, 10m, 15m, 30m, 1h, 3h, 6h, 12h, 1d}
7
interval: 5m
Copied!
Supported values for interval scheduling are: 5m, 10m, 15m, 30m, 1h, 3h, 6h, 12h, 1d.
You can also use CRON scheduling. If you haven't worked with CRON, see https://crontab.guru.
1
trigger:
2
type: periodic
3
periodic:
4
# At minute 5 past every hour.
5
cron: "5 */1 * * *"
Copied!

Alert

An alert trigger means your action will be used as a destination for the alert.
1
trigger:
2
type: alert
3
alert: {}
Copied!
A single action can be used as a destination for multiple alerts.
Last modified 15d ago