> For the complete documentation index, see [llms.txt](https://docs.mercurydata.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mercurydata.app/smart-account-indexer/introduction.md).

# Smart Account Indexer

Mercury runs a free, public indexer for smart accounts (passkey wallets) on Stellar. It indexes the OpenZeppelin smart-account events (context rules, signers, policies) live on both mainnet and testnet, with the full smart-account history already indexed on both networks, and serves them through a REST API compatible with the [smart-account-kit](https://github.com/kalepail/smart-account-kit) `IndexerClient`: point the kit's `indexerUrl` at Mercury and everything works unchanged.

The indexer is currently free to use, and for now requires no authentication or API key.

### Base URLs

| Network | `indexerUrl`                                                 |
| ------- | ------------------------------------------------------------ |
| Testnet | `https://testnet.mercurydata.app/rest/smart-account-indexer` |
| Mainnet | `https://mainnet.mercurydata.app/rest/smart-account-indexer` |

### Usage with smart-account-kit

Set the indexer URL in your kit configuration to the Mercury base URL for your network. Nothing else changes:

```ts
indexerUrl: "https://testnet.mercurydata.app/rest/smart-account-indexer"
```

### Endpoints

All endpoints are `GET`, public, and return JSON.

| Endpoint                       | Description                                                                                |
| ------------------------------ | ------------------------------------------------------------------------------------------ |
| `/`                            | Health check: `{"status":"ok","service":"smart-account-indexer"}`                          |
| `/api/lookup/:credentialId`    | Find smart accounts by passkey credential ID (hex, `0x` prefix optional, case-insensitive) |
| `/api/lookup/address/:address` | Find smart accounts by signer address                                                      |
| `/api/contract/:contractId`    | Full details for one smart account: context rules, signers, policies                       |
| `/api/stats`                   | Indexer statistics: totals, ledger range, per-event-type counts                            |

Example:

```bash
curl https://testnet.mercurydata.app/rest/smart-account-indexer/api/lookup/aabbcc...
```

```json
{
  "credentialId": "aabbcc...",
  "contracts": [
    {
      "contract_id": "C...",
      "context_rule_count": 1,
      "external_signer_count": 1,
      "delegated_signer_count": 0,
      "native_signer_count": 0,
      "first_seen_ledger": 123456,
      "last_seen_ledger": 123789,
      "context_rule_ids": [0]
    }
  ],
  "count": 1
}
```

Lookups match **active** signers only: if a signer was removed, or all of a contract's context rules were removed, the contract no longer resolves through `/api/lookup/*` (and `/api/contract/:contractId` returns 404 once no rules remain).
