Checking Starknet Wallet Account Type
When working with multiple blockchain types, you may need to check if a wallet account is specifically a Starknet wallet account. The isStarknetWalletAccount type guard function helps you narrow down the type safely.
Usage
import { isStarknetWalletAccount } from '@dynamic-labs-sdk/starknet';
import { getPrimaryWalletAccount } from '@dynamic-labs-sdk/client';
const walletAccount = getPrimaryWalletAccount();
if (walletAccount && isStarknetWalletAccount(walletAccount)) {
// walletAccount is now typed as StarknetWalletAccount
console.log('Starknet address:', walletAccount.address);
}
Parameters
| Parameter | Type | Description |
|---|
walletAccount | WalletAccount | The wallet account to check |
Returns
boolean - Returns true if the wallet account is a Starknet wallet account, false otherwise. Also acts as a TypeScript type guard, narrowing the type to StarknetWalletAccount.
React
isStarknetWalletAccount is a synchronous type guard that works the same in React. Use it to filter wallet accounts reactively:
import { isStarknetWalletAccount } from '@dynamic-labs-sdk/starknet';
import { useGetWalletAccounts } from '@dynamic-labs-sdk/react-hooks';
function StarknetWalletDisplay() {
const { data: walletAccounts = [] } = useGetWalletAccounts();
const starknetAccount = walletAccounts.find(isStarknetWalletAccount);
if (!starknetAccount) return <p>No Starknet wallet connected</p>;
return <p>Starknet address: {starknetAccount.address}</p>;
}
Last modified on June 24, 2026