# 【Indexed】

`indexed` 作為 `event` 的參數綴詞是用於在呼叫 `event` 時我們可以用 `indexed` 來作為過濾，找到我們要找的參數。

需要注意的是最多只有三個 `event` 參數可以被宣告 `indexed`。

舉例來說有一個事件為：

```solidity
event Transfer(address indexed _from, address indexed _to, uint256 _value)
```

這代表前端可以有效率的查出 token 的交易資訊：

* 從何地址送出：`tokenContract.Transfer({_from: senderAddress})`
* 被何地址接收：`tokenContract.Transfer({_to: receiverAddress})`
* 從一個地址送往另一個特定地址：`tokenContract.Transfer({_from: senderAddress, _to: receiverAddress})`

只有當我們想要這個 `event` 的參數可以被搜尋的到時才使用 `indexed`。

使用或不使用 indexed 的 gas 花費比較：

```solidity
event NewEvent(address addr)
event NewEvent(address indexed addr) 
```


---

# 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://chihaolu.gitbook.io/all-in-one-solidity/part-ii-medium/chapter-10-shi-jian-event/indexed.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.
