> For the complete documentation index, see [llms.txt](https://totochain.gitbook.io/totochain/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://totochain.gitbook.io/totochain/validators/how-to-get-outstanding-referral-counts.md).

# How to Get Outstanding Referral Counts

Tracking the status of referrals is a key part of managing user onboarding and rewards on the Toto Chain. "Outstanding" referrals can mean two different things:

1. **A pending referral you have&#x20;*****received*** from someone else that you have not yet accepted.
2. **The total count of referrals you have&#x20;*****sent*** to others that they have not yet accepted.

The `referral` pallet provides direct and indirect ways to get both of these pieces of information. This guide explains how to do so using the Polkadot-JS Apps UI.

### 1.0 Checking for a Pending Referral You Have Received

This is the most direct query. The chain stores a list of pending referrals where the key is the person who was referred (the `referee`). You can directly check if your account has a pending referral waiting for it.

#### **Method of Procedure (MOP)**

1. **Connect to the Node:** Open the [Polkadot-JS Apps UI](https://polkadot.js.org/apps/) and ensure you are connected to your local Toto Chain node (e.g., `ws://127.0.0.1:9944`).
2. **Navigate to RPC Calls:** Go to the **Developer -> RPC Calls** section in the UI.
3. **Execute the RPC Call:**
   * Select the **`referral`** pallet from the "submit the following extrinsic" dropdown.
   * Select the **`getPendingReferral(accountId: AccountId)`** RPC call.
   * In the `accountId` field, select your own account address from the dropdown. This is the account you want to check for pending referrals.
   * Click **"Submit RPC call"**.
4. **Interpret the Results:**
   * **If the result is `null`:** You do not have any pending referrals waiting for you to accept.
   * **If the result is an AccountId (an address):** You have a pending referral, and the address shown is the account of the person who referred you.

### 2.0 Counting Unaccepted Referrals You Have Sent

The pallet does **not** provide a single, direct RPC call to get a count of all the unaccepted referrals you have sent to others. This is because the primary storage is indexed by the `referee`, not the `referrer`.

To get this number, a client-side application (like a dApp front-end or a script) must query all pending referrals and filter them.

#### **The Logic**

The process involves these steps:

1. **Query the Entire `PendingReferrals` Map:** A script would use an RPC call like `state_getPairs` or a library-specific function to query all entries in the `PendingReferrals` storage. This returns a list of all `[referee, referrer]` pairs currently on the chain.
2. **Filter by Your Account:** The script would then iterate through this entire list. For each pair, it would check if the `referrer` address is your own account address.
3. **Count the Matches:** The script would keep a running count of every entry where your address appears as the `referrer`.

The final count is the total number of unaccepted referrals you have sent.

{% hint style="info" %}
**Note:** This method is more resource-intensive than a direct lookup and is typically performed by a purpose-built application rather than a manual RPC call in the Polkadot-JS UI.
{% endhint %}
