Reading Data
Retrieve the user's public key and network configuration from Freighter.
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 }>
Last updated
Was this helpful?
