Intro to Web3 Actions
Tenderly Web3 Actions will run your code in response to on-chain (or even off-chain) events, usually on your smart contracts.
You can use Web3 Actions to create custom scenarios in order to further deepen your debugging process, create alerting patterns that are not available out-of-the-box in the Alerting section, automating testing or live production execution in the Simulator and Forks, or anything else that comes to (your) mind.
The code Web3 Actions run is called a function. The function must be written in TypeScript (or JavaScript) and run in Node 14 runtime. Specification of events that your action listens to is called a trigger. There are 5 types of triggers:
  • Transaction - runs a function in response to transactions, with statuses like as soon as the transaction is mined or after 10 blocks have passed and filters such as emitted events, invoked methods, etc.
  • Block - runs your function when the block is mined on a chosen chain(s).
  • Webhook - runs your function when a request is POSTed to an endpoint.
  • Periodic - runs your function in periodic intervals or configured CRON.
  • Alert - use your action as the destination channel for an alert (trigger your action when your defined alert is triggered).

Getting Started (CLI)

To get started, run tenderly actions init in a directory where you want to initialize actions project, which will lead you through setting up a project for your Web3 Actions.
You will need Tenderly CLI to initialize Web3 Actions. You will need npm if you are using TypeScript actions or use tenderly actions init --language javascript.
After initialization, the project contains:
  • tenderly.yaml with the specification of all actions (e.g. name, description, etc.) and their triggers. For more details, see the configuration page.
  • actions directory (or whatever is chosen during setup) where functions implementation should go including files package.json or tsconfig.json in the case of TypeScript.
All tenderly actions commands must be run from a directory that contains tenderly.yaml.
When you initialize actions project, you must select a Tenderly project which will be used for deploying your actions. You can deploy actions from multiple locations to the same Tenderly project. You can also initialize actions multiple times in the same directory and select a different Tenderly project for each initialization.
If your actions are very different or have different dependencies, it is recommended to separate them. You can still use the same Tenderly project to deploy them.
If your actions have dependencies, node_modules directory located in the same directory with your actions source files will be packaged and deployed with your actions. npm install must be run from a directory where actions sources are. Note that this might be a different directory than one where you run tenderly actions commands.
Zipped dependencies must not exceed 45MB. Reach out to us if your requirements exceed this limit.

Step-by-Step Guide

If you want to create your first Web3 Action and go through a step-by-step guide, we prepared for you an onboarding flow in the UI. When you go to Actions Page, you will see an onboarding flow that will help you to get started with Web3 Actions.
Quick Guide provides a quick overview of the steps you need to reproduce in order to deploy your first Web3 Action.
Quick Guide
Step-by-Step Guide provides an in-depth explanation for each step you need to reproduce in order to deploy your first Web3 Action.
You need to import an example contract into your project in order to start the tutorial and create your Web3 Action example. If you are not using the tutorial, you don't have to do this in order to use Web3 Actions.
Step-by-Step Guide
Create a Function Step
Use Secrets Step
Configure a Trigger Step
Deploy Action Step

Deploying Actions

To view your actions in the dashboard, you must deploy them first. Run tenderly actions deploy in an initialized project to deploy generated example and go to provided link to view the action in the dashboard. If you initialized actions for multiple projects in the same directory, you will be asked to select a project which you want to deploy. All actions for a single project are deployed together.
Deployed action can be stopped through the dashboard. Action will stay deployed, but it won't run automatically.
If you just want to validate configuration or build implementation without deploying it, run tenderly actions build.

Manual Trigger

While action must specify trigger type, it doesn't have to configure a trigger. Without a configured trigger, the action will never run automatically. But you can still run your action manually! This can be useful for testing. Navigate to the specific action and click the Manual Trigger button.
You can provide any payload you want, as long as it matches the required schema. If your trigger type is transaction or block, you can fetch a transaction or block from a network instead of manually creating a payload.
If you deployed initialized block action, here is an example of a valid payload:
"network": "1",
"blockNumber": 1000,
"blockHash": "0x5b4590a9905fa1c9cc273f32e6dc63b4c512f0ee14edc6fa41c26b416a7b5d58"
You can use a manual trigger even if the action is stopped.
Last modified 26d ago