Accounts
Once a dApp has established a connection, it can read the connected account’s address, public key, and balance without prompting the user again.
accounts()
Returns already-connected accounts without prompting the user for a new connection.
const accounts: string[] = await window.starkey.supra.accounts()Returns: Promise<string[]> — the same connected-address list connect() returns. Resolves to [] when no wallet is connected.
;['0x841c9ce3...389', '0x161a497a...9ab6d']account() — deprecated
account() (singular) is the older method with the same behavior and return shape as accounts(). It still works but is deprecated — use accounts() in new code.
// deprecated
const result: string[] = await window.starkey.supra.account()getActiveAccount()
Returns metadata for the currently active/selected account — its address and public key together, rather than just the address.
const activeAccount = await window.starkey.supra.getActiveAccount()Returns:
interface ActiveAccount {
address: string
publicKey: string
}{ address: '0x841c9ce3...389', publicKey: '0xf348...42b' }balance()
Returns the active account’s balance on the currently connected chain.
const balance = await window.starkey.supra.balance()Returns:
interface Balance {
balance: number
formattedBalance: number
decimal: number
displayUnit: string
}{ balance: 0, formattedBalance: 0, decimal: 8, displayUnit: 'SUPRA' }Error handling
accounts()/account()resolve to[]if the dApp isn’t connected — they never throw for “not connected”.- Call
isConnected()first if you need to distinguish “not connected” from “connected with zero accounts.”
Notes
- Re-fetch
accounts(),getActiveAccount(), andbalance()whenever theaccountChangedornetworkChangedevent fires — balances and active account are chain- and account-scoped.
Best practices
- Prefer
accounts()over the deprecatedaccount()in new integrations. - Don’t call
connect()on every page load just to read the address — checkisConnected()and useaccounts()/getActiveAccount()instead.