getAccountDisplayName
Returns a human-readable display name for an account. If the account has a BNS username, it returns the first label (e.g. myname.btc → myname). Otherwise, it returns Account {index + 1}.
Usage
import { getAccountDisplayName, generateWallet } from '@stacks/wallet-sdk';
const wallet = await generateWallet({
secretKey: 'your 24-word seed phrase ...',
password: 'password',
});
const account = wallet.accounts[0];
// Account without a username
console.log(getAccountDisplayName(account));
// 'Account 1'
// Account with a username
account.username = 'myname.btc';
console.log(getAccountDisplayName(account));
// 'myname'Signature
Returns
string
The display name for the account.
Parameters
account (required)
Type:
Account
The account to get the display name for.
Last updated
Was this helpful?