useAccountInfo()
Use it to fetch the connected account info from public mirror node.
Usage
When parameter multiSession={false}
:
tsx
import { useAccountInfo } from '@buidlerlabs/hashgraph-react-wallets'
const App = () => {
const { data: accountInfo } = useAccountInfo()
return <span>{accountInfo.max_automatic_token_associations ?? '-'}</span>
}
Parameters
ts
interface IUseAccountInfoProps<Connector> {
connector?: Connector | null
autoFetch?: boolean
}
- connector
- Type:
HWBridgeConnector
- Required:
false
Request the account id for a specific wallet when multiSession={true}
tsx
import { HashpackConnector } from '@buidlerlabs/hashgraph-react-wallets/connectors'
import { useAccountInfo } from '@buidlerlabs/hashgraph-react-wallets'
const App = () => {
const { data: accountInfo } = useAccountInfo({ connector: HashpackConnector })
return <span>{accountInfo.max_automatic_token_associations ?? '-'}</span>
}
- autoFetch
- Type:
boolean
- Required:
false
tsx
import { useWallet, useAccountInfo } from '@buidlerlabs/hashgraph-react-wallets'
const App = () => {
const { isConnected } = useWallet()
const { data: accountInfo } = useAccountInfo({ autoFetch: isConnected })
return <span>{accountInfo.max_automatic_token_associations ?? '-'}</span>
}
Return Type
Returns a TanStack query result
where TData
is the response from https://mainnet.mirrornode.hedera.com/api/v1/accounts/{idOrAliasOrEvmAddress}
Read more on Hedera Rest API Docs
ts
type UseQueryResult<TData, Error>