> For the complete documentation index, see [llms.txt](https://docs.freighter.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.freighter.app/extension-freighter-api/token-management.md).

# Token Management

Unlike Stellar assets, contract tokens a user owns are not automatically displayed in Freighter — they must be explicitly added. This method lets your dapp prompt users to add a contract token directly, without the user having to find and add it in Freighter manually.

{% hint style="info" %}
In a future release, Freighter will auto-detect token transfers and display them automatically. Once that ships, `addToken()` will become a no-op.
{% endhint %}

## Adding a Token

### `addToken()`

Trigger an "add token" flow that displays token details in a modal for the user to review and approve.

```
addToken({ contractId: string, networkPassphrase?: string })
  -> Promise<{ contractId: string } & { error?: FreighterApiError }>
```

When called, Freighter loads the token's **symbol**, **name**, **decimals**, and **balance** from the contract and displays them for the user to verify before adding.

### Parameters

| Parameter           | Type     | Description                                           |
| ------------------- | -------- | ----------------------------------------------------- |
| `contractId`        | `string` | **Required.** The contract token ID (`C...` address). |
| `networkPassphrase` | `string` | Defaults to Mainnet passphrase if omitted.            |

### Example

```typescript
import { isConnected, addToken } from "@stellar/freighter-api";

const { isConnected: connected } = await isConnected();
if (!connected) return;

const result = await addToken({
  contractId: "CC...ABCD",
  networkPassphrase: "Test SDF Network ; September 2015", // optional
});

if (result.error) {
  console.error(result.error.message);
} else {
  console.log(`Token added: ${result.contractId}`);
}
```

{% hint style="info" %}
After the user approves, Freighter will automatically track the token's balance and display it alongside other account balances.
{% endhint %}


---

# 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://docs.freighter.app/extension-freighter-api/token-management.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.
