Account Balance Alert

How to setup an alert to monitor an account balance

A common alert use case is an alert that triggers when a given account balance is below a particular threshold. Here we'll walk through how to set up such an alert with Denotify.

Step 1: Create Alert

Click the "New Alert" Button

Where you'll be taken to the New Alert Wizard.

Step 2: Configure the Trigger

Alerts are made up of two components, the Trigger and the Notification. The trigger monitors on chain changes and initiates the notification if its conditions are met.

Step 2.1: Name the Alert

Let's kick off by naming the trigger "My Balance Alert"

Step 2.2: Alert Type

Denotify currently supports 2 Alert Types. "Poll Function" and "Onchain Event". To get the balance we want to periodically check our balance, so we're going to use Poll Function.

Step 2.3: Contract & Function Configuration

Our account is on Avalanche - Select Avalanche.

For the contract address, we're going to use a helper contract to fetch our balance. We're prepared on Avalanche: 0x26985888d5b7019ff2A7444fB567D8F386c3b538. This has a tidy little function for getting the AVAX balance of an account:

Enter in the helper contract and set the poll period to 10. This will check your balance every 10 blocks. Now select the getBalance function from the Function drop-down list. Once you do this, you'll see the argument input box appear. This is where you put your address.

Step 2.4: Conditional Trigger

There are 2 options to trigger on, either trigger everytime or conditional. Everytime would trigger every poll period (10 blocks). In this scenario, that's obviously not very useful. What we want is to receive a trigger when our balance is below a threshold, so we select Conditional.

We now need to configure the conditional trigger. The Arguement drop-down box lists all the arguments the getBalance() function returns, which in this scenario is a single argument, the balance. Select 0: unknown (uint256)

The balance is returned in 18 decimals, enter 18 into the decimals field.

Now we want it to trigger when the balance is less than a value. Select < for the condition.

Now I want to know when I have less than 1 AVAX, so I enter 1 into Compared With.

There are two options for the alert behaviour, Everytime or Latch. Everytime means the alert will fire everytime the condition is met. So when I have less than 1 AVAX, I would receive this alert every 10 blocks, that would be annoying. So let's choose Latch. Latch means it will trigger once when the condition is met, and it wont trigger again until the latch is cleared (condition is not met).

Step 3: Notification

As of writing this, the only target is Discord. This will send a discord notification to a discord channel. More infomation about discord webhooks can be found here.

You must collect the webhook url from discord, here is a guide for finding it.

The display name will overwrite the username of the alert bot, you'll see this name when the alert if triggered.

The avatar is the icon of the alert message in discord. The URL needs to be a url to a PNG or JPG.

The message is the contents of the dicord messages. You have access to some infomation about the alert, see Message Formatting for more info. Enter the following message:

------------------
Warning: Our balance is below {constant} AVAX!
Balance: {args_0 / 1000000000000000000} AVAX
Address: https://snowtrace.io/tx/{fixedArgs_0}
------------------

This will yield the following message:

Warning: Our balance is below 1 AVAX! Balance: 0.8 AVAX Address: https://snowtrace.io/tx/0xce3c97a4e1b8b19304fe6cf091e3f5c906533004

Voila

You have a real-time Alert running 24/7!

Please submit feedback, bug reports or feature requests here, and share DeNotify with your friends!

Last updated