dApp Kit
Wallet Hooks
useCurrentAccount

useCurrentAccount

The useCurrentAccount hook retrieves the wallet account that is currently selected, if one exists.

import { ConnectButton, useCurrentAccount } from '@mysten/dapp-kit';
 
function MyComponent() {
	const account = useCurrentAccount();
 
	return (
		<div>
			<ConnectButton />
			{!account && <div>No account connected</div>}
			{account && (
				<div>
					<h2>Current account:</h2>
					<div>Address: {account.address}</div>
				</div>
			)}
		</div>
	);
}

Example

Account properties

  • address: The address of the account, corresponding with a public key.
  • publicKey: The public key of the account, represented as a Uint8Array.
  • chains: The chains supported by the account.
  • features: The features supported by the account.
  • label: An optional user-friendly descriptive label or name for the account.
  • icon: An optional user-friendly icon for the account.