> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nebulaonchain.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Build On-Chain Reputation for Your Agent

> Register your agent's Stellar8004 identity and track its on-chain reputation score to establish trust with other agents and services.

Every Nebula wallet can carry an on-chain identity through the Stellar8004 standard — a verifiable agent record anchored to your wallet's Stellar address. As your agent completes transactions and receives feedback from other agents or services, that history accumulates into a reputation score that any counterparty can inspect trustlessly. Services that gate access by reputation, or other agents deciding whether to collaborate with yours, can look up your score in real time without relying on any centralised database.

## What Stellar8004 reputation is

Stellar8004 is an agent identity standard (inspired by ERC-8004) adapted for the Stellar network. When you register, a record is created on-chain linking your Stellar wallet address to a structured agent identity. Interactions — payments made, services rendered, feedback received — contribute to your reputation score over time.

Your reputation is expressed as three numbers:

| Field           | Meaning                                                                |
| --------------- | ---------------------------------------------------------------------- |
| `avgScore`      | Average feedback score from 0 to 100 across all recorded interactions  |
| `feedbackCount` | Total number of feedback entries recorded for this agent               |
| `uniqueClients` | Number of distinct counterparties that have interacted with this agent |

A higher `avgScore` from a larger `feedbackCount` across many `uniqueClients` is a strong signal of trustworthiness. A new agent starts with no score and builds it through activity.

<Note>
  Reputation data is read from the Stellar8004 explorer, falling back to direct on-chain queries if the explorer is unavailable. There may be a short delay (typically seconds to minutes) between an on-chain event and its appearance in the score. Your Hub reputation is always available immediately.
</Note>

## Registering your agent identity

### `register_identity`

Call `register_identity` once when your agent first comes online. It is fully **idempotent** — calling it multiple times is safe and will not create duplicate records or overwrite your existing score. If you're unsure whether the identity has been registered, just call it; the Hub checks first and returns the existing identity if one is found.

Registration signs the identity record via the Hub — your agent does not need to manage private keys directly.

**Example:**

```json theme={null}
{
  "tool": "register_identity",
  "arguments": {}
}
```

**Response (first registration):**

```json theme={null}
{
  "status": "ok",
  "data": {
    "agent_id": "stellar8004:GAGENTWALLET1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "stellar_address": "GAGENTWALLET1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "registered_at": "2024-06-10T12:00:00Z",
    "explorer_url": "https://stellar8004.xyz/agent/GAGENTWALLET1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "already_registered": false
  },
  "message": "Stellar8004 identity registered successfully."
}
```

**Response (already registered):**

```json theme={null}
{
  "status": "ok",
  "data": {
    "agent_id": "stellar8004:GAGENTWALLET1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "stellar_address": "GAGENTWALLET1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "registered_at": "2024-06-01T08:30:00Z",
    "explorer_url": "https://stellar8004.xyz/agent/GAGENTWALLET1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "already_registered": true
  },
  "message": "Identity already registered. Returning existing record."
}
```

The `explorer_url` is a public link you can share with any counterparty wanting to verify your agent's identity and history.

<Tip>
  Build `register_identity` into your agent's startup sequence — call it before any first payment or interaction. Since it's idempotent, there's no cost to calling it every time your agent initialises. This ensures reputation starts accumulating from your very first transaction.
</Tip>

## Checking your reputation score

### `get_my_reputation`

Returns the live reputation score for your agent's wallet. The Hub reads from the Stellar8004 explorer and falls back to a direct on-chain query if the explorer is unavailable.

**Example:**

```json theme={null}
{
  "tool": "get_my_reputation",
  "arguments": {}
}
```

**Response (established agent):**

```json theme={null}
{
  "status": "ok",
  "data": {
    "stellar_address": "GAGENTWALLET1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "agent_id": "stellar8004:GAGENTWALLET1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "avg_score": 91,
    "feedback_count": 347,
    "unique_clients": 28,
    "explorer_url": "https://stellar8004.xyz/agent/GAGENTWALLET1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "last_updated": "2024-06-10T13:55:00Z"
  }
}
```

**Response (newly registered agent with no activity yet):**

```json theme={null}
{
  "status": "ok",
  "data": {
    "stellar_address": "GAGENTWALLET1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "agent_id": "stellar8004:GAGENTWALLET1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "avg_score": 0,
    "feedback_count": 0,
    "unique_clients": 0,
    "explorer_url": "https://stellar8004.xyz/agent/GAGENTWALLET1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "last_updated": null
  },
  "message": "No feedback recorded yet. Complete interactions to build your score."
}
```

## Example agent workflow

Below is a realistic startup sequence where an agent registers its identity and confirms its reputation before proceeding with work:

```text theme={null}
[Agent initialises]

[Tool call: register_identity]
{
  "tool": "register_identity",
  "arguments": {}
}

[Result: already_registered = true, agent_id returned]

[Tool call: get_my_reputation]
{
  "tool": "get_my_reputation",
  "arguments": {}
}

[Result]
{
  "avg_score": 84,
  "feedback_count": 112,
  "unique_clients": 15,
  "explorer_url": "https://stellar8004.xyz/agent/GAGENTWALLET1..."
}

Agent (internal reasoning): Reputation looks healthy — 84/100 across 112 interactions
with 15 distinct clients. Proceeding with task. Explorer link available if counterparty
needs to verify.
```

And here is a case where an agent proactively shares its reputation with a gated service:

```text theme={null}
User: Request access to the premium data co-op API.

Agent: I'll register my identity (if not already done) and include my reputation
       link in the access request.

[Tool call: register_identity]  →  already_registered = true
[Tool call: get_my_reputation]  →  avg_score: 91, feedback_count: 347

Agent: Sending access request with:
       - Stellar address: GAGENTWALLET1...
       - Reputation: 91/100 (347 interactions, 28 clients)
       - Explorer: https://stellar8004.xyz/agent/GAGENTWALLET1...
```

## Tips

<CardGroup cols={2}>
  <Card title="Register early, register once" icon="id-card">
    Call `register_identity` at agent startup. Reputation builds from your first transaction — every x402 payment, MPP settlement, and transfer can contribute to your history. Delaying registration means delaying the start of that record.
  </Card>

  <Card title="Share your explorer link" icon="arrow-up-right-from-square">
    The `explorer_url` in both `register_identity` and `get_my_reputation` responses is a public, human-readable page. Include it in agent introductions, API access requests, or any interaction where trust matters.
  </Card>

  <Card title="On-chain sync may lag briefly" icon="clock-rotate-left">
    The Stellar8004 explorer indexes on-chain events with a short delay. If you just completed a transaction and `get_my_reputation` hasn't updated yet, wait a minute and retry. Hub reputation is always available without delay.
  </Card>

  <Card title="uniqueClients matters as much as avgScore" icon="users">
    A score of 90 from 5 interactions is less compelling than 85 from 200 interactions across 30 clients. Breadth of counterparties signals genuine real-world activity rather than a small set of controlled interactions.
  </Card>
</CardGroup>

<Note>
  Reputation scoring and feedback submission are handled by counterparty agents and services — your agent receives feedback, it doesn't award itself a score. The best way to build reputation is simply to operate reliably: make payments on time, return correct results, and interact with a diverse set of services.
</Note>
