# Event Bot 监控

### Event bot 监控是什么？

> Event 是指智能合约中的 event，当某个交易发生时，对触发对应的 event，因此用户可以通过监听该 event 进而达到追溯该交易的目的。

Event 监控通过监听智能合约中 event 的产生达到监听链上特定行为的目的。

### Event Bot 监控的典型场景

1. Defi 流动性事件监控
   1. Defi 流动性大于设置的阈值
   2. Defi 流动性小于设置的阈值
2. NFT mint 事件监控
   1. 某个 NFT 开始 mint
3. Token mint 事件监控
   1. Token 大额解锁监控
4. 其他等等

#### 支持的数据源

| 数据源           | 类型       | 稳定性 |
| ------------- | -------- | --- |
| Ethereum      | on chain | 极高  |
| BSC           | on chain | 高   |
| Avalanche     | on chain | 高   |
| Polygon Pos   | on chain | 高   |
| Arbitrum      | on chain | 高   |
| Optimism      | on chain | 高   |
| Polygon zkEVM | on chain | 高   |
| ZkSync Era    | on chain | 高   |
| Base          | on chain | 高   |
| Scroll        | on chain | 高   |
| Manta         | on chain | 高   |
| ZKFair        | on chain | 高   |
| Blast         | on chain | 高   |
| Linea         | on chain | 高   |
| B2            | on chain | 高   |
| Merlin        | on chain | 高   |

### 如何配置 Event Bot 监控？

登录 ChainBot 平台后，右上角 "Create Bot" -> "Event Monitor"。

<figure><img src="/files/vfH5ApWYww3Y8Hl8O4kh" alt=""><figcaption><p>Chosen Event Monitor</p></figcaption></figure>

⚠️ 注意

当选择指定的 Event 时，Conditions 会自动解析出该 Event 所包含的字段，且只能是该 Event 的字段。因此 Event 和 Conditions 为对应关系。

#### Info 说明

| 字段名      | 说明               | 是否必填 |
| -------- | ---------------- | ---- |
| Name     | 监控 Bot 名称        | 是    |
| Chain    | 用户选定的链           | 是    |
| Contract | 用户选定的合约          | 是    |
| Event    | 用户选定的事件          | 是    |
| Tags     | Bot 监控 tags，利于搜索 | 是    |

#### Conditions 说明

Event 监控中的 condition 根据选定的 Event 而动态变化。

比如监控 USDT 合约中的 Approval 事件时，由于 Event Approval(owner: address, spender: address, value uint256) 的参数为三个，因此在 conditions 中可选的 field 也为三个，分别为 owner, spender, value，根据您的条件配置您的参数即可达到目的。

#### 模板变量说明

| 变量                  | 说明                      | 示例                      |
| ------------------- | ----------------------- | ----------------------- |
| $alert.time         | 该事件产生的区块                | 16073651                |
| $tx.hash            | 产生该事件的 transaction hash | transaction hash        |
| $event.contract     | 产生该事件的合约地址              | 16073651                |
| $event.params.{abc} | 事件产生后，解析出事件中关键的字段。      | $event.params.tokens    |
| $chain.explore      | 当前链浏览器的前缀               | <https://etherscan.io/> |

#### 默认通知模板

```
[ {$bot.name} ]
Contract: {$event.contract}
Time: {$alert.time}
Explore: {$chain.explore}/tx/{$tx.hash}
```

[了解告警通知模板？](/zh/advanced-features/alarm-notification-template.md)

#### 通知消息示例

> \[ CRV Liquidation Call Monitor ]\
> Contract: 0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9\
> Amount: 187743.2161384799 CRV\
> Time: 2022-11-23T02:09:23+08:00\
> Explore: <https://etherscan.io/tx/0x47ffc7939cf8deed6a28357934f98402892b370ac2d3be0c6576f733f6d97b1e>\
> Created By [ChainBot.io](http://chainbot.io/)

#### Event Bot 监控案例

[Event Bot 案例](/zh/bot-case/event-bot-demo.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.chainbot.io/zh/basic-usage/bots/event-bot.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
