Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/pages/controller/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const account = await controller.connect();
// You're ready to execute transactions!
```

When `connect()` is called, users will see an improved controller creation interface with username autocomplete functionality. As users type their username, they'll see matching existing accounts with user profiles, making it easier to connect to existing controllers or choose unique usernames for new accounts.

:::info
Controller will set **essential cookies** as part of the initialization.
These are necessary for the controller to function properly.
Expand Down
33 changes: 32 additions & 1 deletion src/pages/controller/usernames.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
description: Discover how to use Cartridge Controller's username and address lookup service, including API access, helper methods, and best practices.
description: Discover how to use Cartridge Controller's username and address lookup service, including API access, helper methods, and the new autocomplete features.
title: Username Lookup
---

Expand All @@ -8,8 +8,20 @@ title: Username Lookup
A service for looking up usernames and addresses in the Cartridge ecosystem.
You can use either the helper methods from the SDK or query the endpoint directly.

## Username Autocomplete

When creating a new controller, Cartridge now provides an enhanced username input with real-time autocomplete functionality.
As you type a username, the system will query existing usernames and render a list of matches for easy selection.
This feature makes it easier for users to discover and connect to existing controllers.

:::tip
The autocomplete feature uses the same GraphQL `searchAccounts` query described in the API section below, providing up to 5 matching results with a 300ms debounce for optimal performance.
:::

## Direct API Access

### Account Lookup Endpoint

The lookup endpoint can be accessed directly via HTTP POST:

```bash
Expand All @@ -19,6 +31,25 @@ curl -X POST \
https://api.cartridge.gg/accounts/lookup
```

### Account Search GraphQL Query

For real-time username search (used by the autocomplete feature), you can use the GraphQL endpoint:

```graphql
query AccountSearch($query: String!, $limit: Int = 5) {
searchAccounts(query: $query, limit: $limit) {
username
credits {
amount
decimals
}
updatedAt
}
}
```

This query returns matching usernames along with their credit information and last update timestamp, perfect for implementing search and autocomplete functionality.

Request Format
```json
{
Expand Down