llms.txt
@mysten/sui v2.0 and a new dApp Kit are here! Check out the migration guide
Mysten Labs SDKs
dApp Kit (Legacy)Wallet hooks

useAccounts

Legacy React hook to list connected wallet accounts authorized by the app.

The useAccounts hook retrieves a list of connected accounts the app authorizes.

import { ConnectButton, useAccounts } from '@mysten/dapp-kit';

function MyComponent() {
	const accounts = useAccounts();

	return (
		<div>
			<ConnectButton />
			<h2>Available accounts:</h2>
			{accounts.length === 0 && <div>No accounts detected</div>}
			<ul>
				{accounts.map((account) => (
					<li key={account.address}>- {account.address}</li>
				))}
			</ul>
		</div>
	);
}

Example

Loading...

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 the account supports.
  • features: The features the account supports.
  • label: An optional user-friendly descriptive label or name for the account.
  • icon: An optional user-friendly icon for the account.

On this page