🤔 Got questions? Schedule an office hours session.
Web3 Actions
How to Set Up Lido Validator Exit Notifications

Monitoring Network Validators Exits

In this tutorial, we’ll show you how to set up a Tenderly Web3 Action to monitor Lido validator exit requests and send notifications via Telegram. This project demonstrates how to use Web3 Actions to interact with smart contracts and external APIs to create a custom notification system.

Project Overview

The purpose of this project is to set up a system that monitors Lido validator exit requests and sends notifications when specific conditions are met. Here’s a quick breakdown of the project’s flow:

  1. The Web3 Action listens for ValidatorExitRequest events from the Lido contract on the Ethereum mainnet.
  2. When an event is detected, it retrieves the transaction details using the Tenderly API.
  3. It checks if the stakingModuleId is 1 and the nodeOperatorId is 14.
  4. If the condition is met, it sends a notification to the specified Telegram channel with details about the validator exit request.

Prerequisites

Before you begin, make sure you have the following:

  • Tenderly CLI installed
  • Node.js (version 16 or higher)
  • npm
  • A Telegram bot token and channel ID
  • A Tenderly account and project

Setup

Let’s go through the steps to set up your Lido Validator Exit Notification system:

Clone the Repository

First, clone the project repository and navigate to the project directory:

git clone https://github.com/Tenderly/tenderly-lido-validator-monitoring-solution
cd tenderly-lido-validator-monitoring-solution

Install Dependencies

Install the required npm packages:

npm install

Configure Tenderly Project

Set up your Tenderly project by following these steps:

  1. Log in to your Tenderly account
  2. Create a new project or use an existing one
  3. Note down your Account Name and Project Slug

Configure tenderly.yaml

Update the tenderly.yaml file with your Tenderly project information:

account_id: "<YOUR_ACCOUNT_ID>"
actions:
  <YOUR_ACCOUNT_ID>/<YOUR_PROJECT_SLUG>:
    runtime: v2
    sources: actions
    specs:
      action_name:
        description: Get a notification when condition matches on Lido tx
        function: lidoEvents:subscribeToLidoValidatorExitRequestFn
        execution_type: parallel
        trigger:
          type: transaction
          transaction:
            status:
              - mined
            filters:
              - network: 1
                eventEmitted:
                  contract:
                    address: 0x0de4ea0184c2ad0baca7183356aea5b8d5bf5c6e
                  name: ValidatorExitRequest
project_slug: "<YOUR_PROJECT_SLUG>"

Make sure to replace <YOUR_ACCOUNT_ID> and <YOUR_PROJECT_SLUG> with your actual Tenderly Account Name and Project Slug.

Set Up Secrets

Add the following secrets to your Tenderly project settings:

  • BEARER: Your Tenderly API bearer token
  • BOT-TOKEN: Your Telegram bot token
  • CHANNEL-ID: Your Telegram channel ID

To add secrets, go to your Tenderly project settings and navigate to the “Secrets” section.

Deployment

To deploy your Web3 Action, use the Tenderly CLI:

tenderly actions deploy

This command will deploy the action defined in your tenderly.yaml file.

How it Works

Let’s break down the main components of the lidoEvents.ts file:

import { Context, TransactionEvent } from "@tenderly/actions";
import axios from "axios";
 
const subscribeToLidoValidatorExitRequestFn = async (
  context: Context,
  transactionEvent: TransactionEvent,
) => {
  // Event handling logic here
};
 
// Helper functions for API calls and notifications

The lidoEvents function is the main entry point for our Web3 Action. It handles the following tasks:

  1. Retrieves transaction details using the Tenderly API
  2. Checks if the stakingModuleId is 1 and the nodeOperatorId is 14
  3. If the condition is met, sends a notification to the specified Telegram channel

Customization

To modify the conditions or add more events to monitor:

  1. Edit the lidoEvents.ts file
  2. Update the condition check in the if statement to match your requirements
  3. Modify the message format or add additional information as needed

For example, to change the stakingModuleId and nodeOperatorId conditions:

if (stakingModuleId == 1 && nodeOperatorId == 14) {
  // Your custom logic here
}

Monitoring and Troubleshooting

To ensure your Web3 Action is working correctly:

  • Monitor your Web3 Action executions in the Tenderly dashboard
  • Check the Tenderly logs for any error messages or execution details
  • Ensure your Telegram bot has permission to send messages to the specified channel

This setup is specifically designed to monitor Lido validator exit requests on the Ethereum mainnet. Make sure you have sufficient credits in your Tenderly account to run the Web3 Action.

Conclusion

You’ve now set up a custom notification system using Tenderly Web3 Actions to monitor Lido validator exit requests. This project demonstrates how to interact with smart contracts, use external APIs, and create a notification system for specific blockchain events.

For more information on Lido staking and node operator responsibilities, refer to the Lido documentation.