# 定义与用途

Graph Indexer是Relation Protocol中索引SBT数据的解析器标准，它的主要功能是构建一个社交图谱。

[事件](https://ethereum.org/en/glossary/#events)是Relation社交图谱中的原子单元。在Relation Protocol的通用技术[规范](http://eips.ethereum.org/EIPS/eip-6239)中定义了三个事件：

* CreateRDF：当一个包含RDF语义的SBT被创建的时候会发出此事件。
* UpdateRDF：当一个包含RDF语义的SBT被更新的时候会发出此事件。
* RemoveRDF：当一个包含RDF语义的SBT被销毁的时候会发出此事件。

Graph Indexer通过监听区块链的交易并解析以上三个事件，将用户的社交行为以图结构存入数据库，构建出一个社交图谱(图 7-1)，方便社区的开发者和企业在DApp和去中心化项目上搭建有意义的用户关系。通过本服务，开发者可以更加轻松地构建用户的社交关系，为社区用户提供更为丰富的服务体验。

<figure><img src="/files/cvNKFCAkX1pn0fw8N92A" alt=""><figcaption><p>图 7-1</p></figcaption></figure>

本章将讲述如何构建一个`Graph Indexer`：

1. [监听链上事件](/protocol/protocol-zh/indexer/event-listener.md)：监听区块链上所有符合[EIP6239](http://eips.ethereum.org/EIPS/eip-6239)规范的事件。
2. [解析RDF数据](/protocol/protocol-zh/indexer/parse-data.md)：将事件中符合[Schema规范](/protocol/protocol-zh/schema-standard/how-schema-limit-contract.md)的RDF解析成图结构的数据。
3. [构建社交图谱](/protocol/protocol-zh/indexer/build-graph.md)：将数据存入图数据库。

{% embed url="<https://youtu.be/8X420sNwygI>" %}


---

# 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://relationlabs.gitbook.io/protocol/protocol-zh/indexer/introduction.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.
