> 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/en/smart-contracts/bindref-contract.md).

# Bindref Contract

## Introduction

This contract stores information such as the user's referrer, direct referrals, connection depth, team performance, and level. This information is used for contractual operations such as binding referral relationships and querying referral relationships.

### Binding

`bindReferrer(referrer)` is a state-changing user call sent by the wallet being bound. The relationship cannot be changed through a normal user interface after it is created. Confirm that the user is unbound, the referrer is not the user, and the referrer is part of the valid tree.

<figure><img src="https://67272133-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQwq1LDgDnycI1FCz8mLz%2Fuploads%2FLFZkdvMpRSNZ0AqGNjnb%2Fbindrefen.png?alt=media&amp;token=b45660e8-2055-459c-af56-31225b3fbd29" alt=""><figcaption></figcaption></figure>

### Read complete user information

`userInfo(user)` returns:

| Field                                | Meaning                                                       |
| ------------------------------------ | ------------------------------------------------------------- |
| `referrer`                           | Direct referrer                                               |
| `stakeAmount` / `stakeValue`         | Personal stake amount / value recorded by the referral system |
| `effective`                          | Whether the user is currently effective                       |
| `effectiveDirects`                   | Effective direct-referral count                               |
| `totalTeamAmount` / `totalTeamValue` | Total team amount / value                                     |
| `maxBranch`                          | Direct referral representing the largest branch               |
| `bigAreaAmount` / `bigAreaValue`     | Large-area amount / value                                     |
| `smallAreaAmount` / `smallAreaValue` | Small-area amount / value                                     |
| `level`                              | Current level from 0 to 15                                    |

<figure><img src="https://67272133-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQwq1LDgDnycI1FCz8mLz%2Fuploads%2FlPc05uUtYJIPd3aDHizq%2Fuserinfo.png?alt=media&amp;token=2b1f0159-bdba-471a-b3b0-1a2961674843" 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/en/smart-contracts/bindref-contract.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.
