Skip to main content
In this guide, you will learn how to use Envio HyperIndex to create a Telegram bot that sends notifications whenever WMON tokens are transferred on the Monad Testnet. We’ll walk through setting up both the indexer and the Telegram bot. Envio HyperIndex is an open development framework for building blockchain application backends. It offers real-time indexing, automatic indexer generation from contract addresses, and triggers for external API calls.

Prerequisites

You’ll need the following installed:
  • Node.js v18 or newer
  • pnpm v8 or newer
  • Docker Desktop (required for running the Envio indexer locally)

Setting up the project

First, create and enter a new directory:

Get the contract ABI

  1. Create an abi.json file:
  1. Copy the WrappedMonad ABI from the explorer
image of explorer
  1. Paste the ABI into your abi.json file

Initialize the project

Run the initialization command:
Follow the prompts:
  1. Press Enter when asked for a folder name (to use current directory)
  2. Select TypeScript as your language
  3. Choose Evm as the blockchain ecosystem
  4. Select Contract Import for initialization
  5. Choose Local ABI as the import method
  6. Enter ./abi.json as the path to your ABI file
  7. Select only the Transfer event to index
  8. Choose <Enter Network Id> and input 10143 (Monad Testnet chain ID)
  9. Enter WrappedMonad as the contract name
  10. Input the contract address: 0xFb8bf4c1CC7a94c73D209a149eA2AbEa852BC541
  11. Select I'm finished since we’re only indexing one contract
  12. Choose whether to create or add an existing API token. If you choose to create a new token, you’ll be taken to a page that looks like this:
new API token view Once the project is initialized, you should see the following project structure in your project directory. envio dashboard Add the following code to config.yaml file, to make transaction hash available in event handler:
config.yaml
More details about the field_selection config here

Starting the indexer

Start Docker Desktop. To start the indexer run the following command in the project directory:
You should see something similar to the below image in your terminal; this means that the indexer is syncing and will eventually reach the tip of the chain. envio indexer syncing You will also see this page open in your browser automatically, the password is testing. hasura local page We can use this interface to query the indexer using GraphQL. Results will depend on the sync progress: query interface Currently, the indexer is catching up to the tip of the chain. Once syncing is complete the indexer will be able to identify latest WMON transfers. We can shut down the indexer for now, so we can proceed with Telegram integration.

Creating the Telegram bot

  1. Visit BotFather to create your bot and get an API token
  2. Add these environment variables to your .env file:
To get your chat ID:
  1. Create a Telegram group and add your bot
  2. Send /start to the bot: @YourBot /start
  3. Visit https://api.telegram.org/bot<YourBOTToken>/getUpdates
  4. Look for the channel chat ID (it should start with ”-”)
If you don’t see the chat ID, try removing and re-adding the bot to the group.
The Telegram bot is now ready.

Integrating Telegram API to HyperIndex Event Handler

Create a folder libs inside src folder in the project directory, create a file inside it telegram.ts and add the following code
src/libs/telegram.ts
You will come across some errors, let’s fix them. Install axios package
Create a file in src folder called constants.ts and add the following code:
src/constants.ts
We can now edit the EventHandlers.ts in src folder, to add the code for sending the telegram message:
src/EventHandlers.ts
Let us now fix the import error. Create a file called helpers.ts in src/libs folder, paste the following code in it:
src/libs/helpers.ts
That’s it! We can now run the indexer, and the telegram bot will start sending messages in the telegram channel when the indexer detects a WMON transfer! example bot message Note: Screenshot was taken before message format was changed. The message will be slightly different if you followed the guide.
You may not immediately start seeing messages because the indexer take some time to catch up to the tip of the the recent blocks.The bot will only send notifications for transfers when the indexer detects a WMON transfer in finalized blocks, with timestamp greater than or equal to the indexer start time.