Validator monitoring Web3 Action template
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:- Subscribe to relevant on-chain events: The Web3 Action listens for
ValidatorExitRequestevents from the Lido contract on the Ethereum mainnet. - Decode event using Tenderly API: When an event is detected, it retrieves the transaction details using the Tenderly API.
- Filter for specific events of interest: The
ValidatorExitRequestevent is evaluated further by checking if thestakingModuleIdis 1 and thenodeOperatorIdis 14. - Respond: If
ValidatorExitRequestof interest has happened, the Web3 Action 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 (v20 currently supported)
- 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:How it Works
Let’s break down the main components of thelidoEvents.ts file:
showLineNumbers
subscribeToLidoValidatorExitRequestFn function is the main entry point for our Web3 Action. It handles the following tasks:
- Retrieves transaction details using the Tenderly API
- Checks if the
stakingModuleIdis 1 and thenodeOperatorIdis 14 - If the condition is met, sends a notification to the specified Telegram channel
Tenderly API for Transaction Trace
A key part of this Web3 Action is retrieving the transaction trace using the Tenderly API. Here’s the API endpoint used:https://api.tenderly.co/api/v1/public-contract/: The base URL for Tenderly’s public contract API${network}: The network identifier (e.g.,1for Ethereum Mainnet)${txHash}: The hash of the transaction we’re interested in
- All emitted events and their parameters
- Internal calls made during the transaction
- State changes that occurred
ValidatorExitRequest event and extract relevant information:
showLineNumbers
Using the Tenderly API for transaction traces provides a powerful way to access detailed information about on-chain events without having to directly interact with the blockchain or set up your own node.
Customization
For Lido validator exits, events of interest are recognized by parametersstakingModuleId with value 1, and nodeOperatorId with value of 14.
To modify these filtering conditions or add more events to monitor:
- Edit the
lidoEvents.tsfile - Update the condition check in the
ifstatement to match your requirements - Modify the message format or add additional information as needed
stakingModuleId and nodeOperatorId conditions:
showLineNumbers
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