For the complete documentation index, see llms.txt. This page is also available as Markdown.

Reading Data

Retrieve the user's public key and network configuration from Freighter.

These methods require that the user has previously authorized your app via requestAccess() or setAllowed().

Getting the User's Address

getAddress()

A lightweight way to retrieve the user's public key. Unlike requestAccess(), this will not prompt the user — it returns an empty string if the app isn't authorized or Freighter isn't connected.

Returns: Promise<{ address: string } & { error?: FreighterApiError }>

import { getAddress } from "@stellar/freighter-api";

const { address, error } = await getAddress();

if (error) {
  console.error(error.message);
} else {
  console.log("Public key:", address);
}

Getting the Network

getNetwork()

Get the name and passphrase of the network the user has selected in Freighter.

Returns: Promise<{ network: string; networkPassphrase: string } & { error?: FreighterApiError }>

Possible network values: PUBLIC, TESTNET, FUTURENET, or STANDALONE (custom networks).

getNetworkDetails()

Get comprehensive network configuration including the Horizon URL, passphrase, and Soroban RPC URL.

Returns: Promise<{ network: string; networkUrl: string; networkPassphrase: string; sorobanRpcUrl?: string } & { error?: FreighterApiError }>

Use getNetworkDetails() instead of getNetwork() when working with Soroban smart contracts or when you need specific network endpoints.

Last updated

Was this helpful?