> For the complete documentation index, see [llms.txt](https://document.sunprotocol.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://document.sunprotocol.io/zhi-neng-he-yue/bang-ding-guan-xi-he-yue.md).

# 绑定关系合约

## 简介

该合约保存用户的推荐人、直接下级、绑定深度、团队业绩和等级信息，用于绑定推荐关系，查询推荐关系等合约操作

## 相关函数

`bindReferrer(referrer)` 是用户写入函数。交易由被绑定的钱包本人发送，参数是上级地址。绑定关系一旦建立，不能通过普通用户接口修改。发送前应确认：

* 用户尚未绑定；
* 上级不是用户自己；
* 上级地址已经处于有效的关系树中；

<figure><img src="https://554674054-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7CKKhHI2WonLxUL3XwJ6%2Fuploads%2FADCTVOpfkXt4dz8pr6jo%2Fbindref.png?alt=media&amp;token=a9b5d705-939b-4d90-94a8-5d1029996d64" alt=""><figcaption></figcaption></figure>

### 查询用户完整信息

`userInfo(user)` 调用链上读取，输入要查询的用户地址，返回如下数据

| 字段                                   | 含义                 |
| ------------------------------------ | ------------------ |
| `referrer`                           | 直接推荐人              |
| `stakeAmount`                        | 用户计入关系系统的质押 SUN 数量 |
| `stakeValue`                         | 用户计入关系系统的价值        |
| `effective`                          | 当前是否为有效用户          |
| `effectiveDirects`                   | 有效直推数量             |
| `totalTeamAmount` / `totalTeamValue` | 团队总数量 / 总价值        |
| `maxBranch`                          | 当前最大业绩分支的直接下级      |
| `bigAreaAmount` / `bigAreaValue`     | 大区数量 / 价值          |
| `smallAreaAmount` / `smallAreaValue` | 小区数量 / 价值          |
| `level`                              | 当前等级，范围为 0–15      |

<figure><img src="https://554674054-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7CKKhHI2WonLxUL3XwJ6%2Fuploads%2FRkAhm3mBDpIAXfq9c3Fc%2Fuserinfo.png?alt=media&amp;token=8791cc37-0f0d-49bb-b7ed-99da2e0d2cdc" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://document.sunprotocol.io/zhi-neng-he-yue/bang-ding-guan-xi-he-yue.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
