This page provides a brief summary of some of the most common approaches to bot development and best practices.
Bot Development Patterns
Labels provide a way to add more contextual data to findings generated by Forta bots. This information can be used to answer questions like "which addresses have been involved in flashloan attacks?" or "which blocks contain exploits?".
While verifing the health of your bot from the status dashboard on Forta Explorer (i.e.
https://explorer.forta.network/agent/YOUR_AGENT_ID) is useful information, bot developers may want to integrate their bot into an existing error monitoring solution (e.g. Sentry).
Some detection bots may have difficulty keeping up with the volume of blocks/transactions (either because of the bot's logic, or due to the speed of the blockchain being scanned). One solution is to use sharding to increase throughput for your detection bot. With sharding, you can increase the number of instances of your detection bot and split the blocks/transactions across these instances.
handleTransaction functions are required to return within a timeout specified by the network (currently 30 seconds). This should be enough time for most bots to complete, but if you need longer for your bot (e.g. you need to execute many network calls) you can still return findings asynchronously.
There are cases where developers need to use sensitive information in their bot (e.g. some API key) or just hide their bot code from the public. Developers can still use JWT authentication or code obfuscation as two ways to protect sensitive data.
In certain usecases bot developers may want to keep their generated alerts private. Using encryption, bot developers can publish alerts that are unreadable to anyone but themselves.
There may be cases where you need to call a private API, perhaps to save some state or load some secret. The SDK provides the methods for generating a JWT token which enables bots to make authorized requests to external APIs.
This guide will share tips and tricks on deploying a scikit-learn machine learning model in a python detection bot.
To create a time series model in Python, the Prophet Library is a good choice. A simple model can be created by querying alerts from other detection bots or hold the timeline data in the bot directly.
With the addition of the new
handleAlert handler, bots are now able to subscribe to alerts from the Forta network. This enables increased composability and higher reuse of existing bots when building your own bot.
Each Bot is an ERC-721 NFT and is minted to the creator of the Bot. This means that the owner can invoke the ERC-721
transferFrom function, and it changes the owner of the Bot.
Transaction simulation is a powerful technique that can be used by bot developers to see the results of transactions without having to pay for on-chain execution. Using simulation, you can run transactions from any account on the latest blockchain state and view the results.
This page describes how to conduct more advanced testing using a locally forked chain.