Setting Up Alerts as Triggers for Web3Actions
Web3Actions in Tenderly provide a powerful way to automate responses to blockchain events. This guide will walk you through the process of setting up Alerts as triggers for Web3Actions, allowing you to create automated workflows based on specific blockchain conditions.
This guide assumes you have a Tenderly account and basic familiarity with Web3Actions.
Prerequisites
Before you begin, make sure you have:
- Tenderly CLI installed
- A Tenderly account with appropriate permissions
- Basic understanding of Web3Actions
Setup Process
You can set up Alert triggers for Web3Actions through either the UI or CLI approach.
UI Approach
- Log in to your Tenderly dashboard
- Navigate to the Web3Action section
- Click on
Create New Action
- In the trigger type selection, choose
Alert
- Configure your action:
- Set a name for your action
- Define the function that will be executed
- Specify any necessary environment variables
- Click
Deploy
to create and deploy your Web3Action
CLI Approach
- Create an Alert in your Tenderly dashboard and note the
ALERT_ID
- Initialize your Web3Action:
tenderly actions init
- Configure your
tenderly.yaml
:
account_id: "<YOUR_ACCOUNT_ID>"
actions:
<YOUR_ACCOUNT_ID>/<YOUR_PROJECT_SLUG>:
runtime: v2
sources: actions
specs:
<YOUR_ACTION_NAME>:
description: "Description of what your action does"
function: example:actionFn
trigger:
type: alert
alert: { <YOUR_ALERT_ID> }
execution_type: parallel
project_slug: "<YOUR_PROJECT_SLUG>"
Make sure to replace all placeholder values (<YOUR_ACCOUNT_ID>
, <YOUR_PROJECT_SLUG>
, and <ALERT_ID>
) with your actual values.
- Implement your action code
- Deploy using:
tenderly actions deploy
Understanding the Configuration
Here’s what each configuration element means:
account_id
andproject_slug
: Identify your Tenderly account and projectruntime
: Specifies the runtime version for your actionsources
: Indicates the directory containing your action codespecs
: Defines the specifications for your actiontrigger
: Configures how your action is triggeredexecution_type
: Determines how multiple instances are handled
Best Practices
- Use descriptive names for your actions and alerts
- Keep your action code modular and focused
- Use environment variables for sensitive information
- Test thoroughly before deployment
- Monitor your action executions regularly
Following these best practices will help ensure smooth operation of your Web3Actions.
Troubleshooting
If you encounter issues:
- Verify your
ALERT_ID
matches the created alert - Check alert conditions are properly configured
- Review Tenderly dashboard logs for errors
- Ensure CLI is up to date and properly authenticated
If your action isn’t triggering, first check the alert configuration and action logs in the Tenderly dashboard.
Conclusion
By following this guide, you should now have a Web3Action set up to trigger based on an Alert. This powerful combination allows you to create automated, responsive systems that can react to specific blockchain events or conditions in real-time.