Traditional financial markets are only open during business hours, closed on the weekends, and take off for holidays. In contrast, crypto never sleeps. The blockchain never takes a day off (unless it’s Cardano). Handling this deluge of information is impossible for a single person to handle, and trying to ingest it all manually is inefficient.
But what if you can’t code bots to watch the chain for you? Fear not! I’ve written this quick guide on how to monitor smart contracts automatically, using simple, free tools.
Why You Need Alerts
I know a thing or two about the power of alerts. In my day job, I spend a lot of time looking at trends and data from running processes. Just by looking at a number, it can be hard to tell what’s actually going on in a system. If the temperature of this machine is 50 C, is that low? High? Way too high and about to explode? What’s the context?
Properly configured alarm conditions let me skim through reams of data and ignore the stuff that’s running fine, to focus on what’s messed up or important. It also frees up brainpower from having to watch the parameters all the time. You could never keep up with everything properly on your own.
In crypto, having timely notice of important things is especially critical as the timescales are accelerated. A pending transaction landing in a multisig could turn into a hard rug in a matter of minutes. A contract being paused could immediately begin causing expensive failed transactions for your arbitrage bot.
Maybe you want to know when known scammers move their money into one of your projects. Automatic alerts can help.
Alert Systems For Non-Coders
All information on the blockchain is publicly available. You are absolutely free to spin up your own node and run your own monitoring bots – and if you have the means to do it, some might argue that you should do it. But for those of us without the time, resources, or technical inclination to run our own monitoring units, we can employ some centralized services to do the heavy lifting for us.
The two services we’ll look at are Tenderly and OpenZeppelin Defender. Both offer free plans and no credit card is required, although you will have to make an account.
Tenderly is a very comprehensive information suite, with the ability to simulate transactions and setup custom analytics. OpenZeppelin Defender is designed more for protocol administration/operation, but has the alerting and custom analytics that we’ll need.
Setting An Alert In Tenderly
After making an account, head to the dashboard and look for the Alerting tab of the sidebar menu.
Next, go to New Alert.
For this demo, I’m going to watch the Wonderland Money multisig on AVAX for changes to the multisig owners. That function emits an event, so I’m going to watch for Event Emitted.
Select the Target type as Address and paste in the multisig address, then select the contract that shows up.
Next, select the desired event you want to watch for. Tenderly has automatically pulled the contract’s ABI, so it knows what the contract’s code is. I’m going to watch for OwnerAddition.
Lastly, set how you want to receive your alerts, and click save! Note that if you want to track other events, you need to set up an alert for each of them. You can duplicate the one you just made to save some time.
Setting An Alert In Defender
After making your account, go to the Sentinel sidebar tab, then click Add first Sentinel.
We’ll set this up to watch the same Wonderland multisig as in the Tenderly demo. You want the Contract sentinel type, Forta refers to more advanced agents from another OpenZeppelin product. You can see my setup below.
Paste in the address, then you need to retrieve the contract ABI. OpenZeppelin does not do this for you automatically.
To do that, go to the Contract code section on Snowtrace, and look for the contract ABI. Then hit the copy button, and paste it into the ABI box in Defender.
Here’s my full setup.
Click Next, then we’ll set up what to track for. Note that this product lets us track multiple events with the same Sentinel agent. You can get highly specific on what conditions to trigger on, and even trigger tasks to run automatically, but this is all you need for right now.
(Don’t know how to tell what events do what? Check out How To Read Smart Contracts Without Knowing Solidity)
Hit Next, setup your notification, and you’re off to the races!
Wrapping Up
Well-configured automatic notifications can cut through the noise and deliver prompt, relevant information to keep you and your bags safe. I highly recommend signing up for one of these products with a burner email and playing with them. They are user friendly and require no coding experience to operate.
The world is your oyster. Get an email summary of a DAO’s onchain transactions. Set up a Discord bot for your private alpha group to stalk Tetranode’s wallets. Automatically watch the network for times of low gas. Do whatever you think would be useful!