Skip to content

useAccount

Usage

connect() must be called and WalletConnect session must be initiated before account information will be returned.

The useAccount hook returns the currently selected account at the time of connection. When your account change in the wallet, the account change will be reflected in the dApp. If you create or import a new account after connection, you’ll have to reconnect your dApp to the wallet.

import { useAccount } from '@puzzlehq/sdk';
const { account, error, loading } = useAccount();

Types

type PuzzleAccount = {
network: string, // 'aleo'
chainId: string, // '0', '1', '3'
address: string,
shortenedAddress: string // e.g. "aleo1asu88azw3u...5qgqetuvr6"
};

Return Value

{
account?: PuzzleAccount, // currently selected account info
error?: string,
loading: boolean
};