🤔 Got questions? Schedule an office hours session.
Alerts
Setting Up Alerts as Triggers for Web3Actions

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

  1. Log in to your Tenderly dashboard
  2. Navigate to the Web3Action section
  3. Click on Create New Action
  4. In the trigger type selection, choose Alert
  5. Configure your action:
  • Set a name for your action
  • Define the function that will be executed
  • Specify any necessary environment variables
  1. Click Deploy to create and deploy your Web3Action

CLI Approach

  1. Create an Alert in your Tenderly dashboard and note the ALERT_ID
  2. Initialize your Web3Action:
tenderly actions init
  1. 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.

  1. Implement your action code
  2. Deploy using:
tenderly actions deploy

Understanding the Configuration

Here’s what each configuration element means:

  • account_id and project_slug: Identify your Tenderly account and project
  • runtime: Specifies the runtime version for your action
  • sources: Indicates the directory containing your action code
  • specs: Defines the specifications for your action
  • trigger: Configures how your action is triggered
  • execution_type: Determines how multiple instances are handled

Best Practices

  1. Use descriptive names for your actions and alerts
  2. Keep your action code modular and focused
  3. Use environment variables for sensitive information
  4. Test thoroughly before deployment
  5. 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.