Connect Ethereum to your Apps: HAL meets Telegram

Some time ago you decided to see for yourself what was the fuss about that DeFi stuff everyone was talking about, and now you’re hooked. But staying on top of everything in this hectic world isn’t as easy as you wish it was — or is it?

HAL meets Telegram: a love story

So we figured it would be sweet to monitor what’s going on in the blockchain world using Telegram, right? Here’s how to do it, in two minutes, and without coding.
Let’s say you want to set up a trading strategy based on the exchange rate between KNC and DAI on Kyber. If you’re not familiar with it, Kyber is one of the most used liquidity protocols in the DeFi ecosystem, with more than 100 integrations and 950+ million dollars in volume registered since its launch.
The metric we want to track is when the exchange rate between KNC and DAI grows beyond a certain value. Normally, you would track it using the  function, a view function that takes three parameters: the source token contract address, the destination token contract address, and the amount of source token expressed in wei. It also returns two values: the expected rate, and the slippage rate.
It’s all a bit abstract, so here is what it looks like on Etherscan using (one) KNC and DAI as source and destination respectively:
What we want now is a trigger that tracks the expected rate for us, and texts us when it meets our requirements. Ready?

Create a new “Watch a Contract” trigger

Head over to https://9000.hal.xyz/discover, and create a “Watch a Contract” trigger:

Configure your trigger

We need to provide the input data to , similarly to what we did on Etherscan:
  1. In the “Contract Address” field, put the KNC Network Proxy Contract Address: 0x818e6fecd516ecc3849daf6845e3ec868087b755
  2. From the dropdown menu, select “
  3. Fill in the addresses for the tokens we are tracking: these are 0xdd974d5c2e2928dea5f71b9825b8b646686bd200 for KNC and 0x6b175474e89094c44da98b954eedeac495271d0f for DAI.
  4. And finally, insert the amount of source token in wei, for example for 1 KNC you’d put .
So much for the “input” data to our function. Now let’s specify the actual filter: we only care about the expected rate here, which is the first of the two returned values. In this example we want our trigger to fire when the expected rate is greater than 0.629 DAI, so we set in the first “Return” field. Here is what it looks like:

Connect Telegram

Now for the fun part, you’ll need to have (or create) a Telegram bot (if you haven’t done this before have a look at the doc here, it only takes a minute). Then you’ll need to provide your bot token, and the chat ID for where you want your bot to post the message. At last, you can craft your message using a number of customizable placeholders.
And that is all! Give your trigger a name, hit the “Create” button and relax — HAL will do the rest of the hard work for you. When the time is right, your bot will be in touch:
Congratulations for creating your first integration using HAL and Telegram!

Where to go from here

There’s a lot more you might want to explore:

HAL

Subscribe To Our Latest News, Tips and Insights

logo

© 2022 HAL Collective Inc.

hello@hal.xyz

Terms and Conditions