useBalance
Hook to get the balance of an account
Import
import { useBalance } from '@lawallet/react';Usage
index.tsx
import { useBalance } from '@lawallet/react';
function App() {
const balance = useBalance();
}Parameters
import { type UseBalanceParameters } from '@lawallet/react';pubkey
String
- Public key of the account for which you want to consult the balance
import { useBalance } from '@lawallet/react';
function App() {
const balance = useBalance({
pubkey: '17efe7a5f1...53936f68b',
tokenId: 'BTC',
});
}tokenId
String
- Id of the token to be transferred
import { useBalance } from '@lawallet/react';
function App() {
const balance = useBalance({
pubkey: '17efe7a5f1...53936f68b',
tokenId: 'BTC',
});
}enabled
Boolean | undefined
- Set this to false to disable this query from automatically running.
- The default parameter is true.
import { useBalance } from '@lawallet/react';
function App() {
const balance = useBalance({
pubkey: '17efe7a5f1...53936f68b',
tokenId: 'BTC',
enabled: false,
});
}config
Config | undefined
Config to use instead of retrieving from the from nearest LaWalletProvider.
import { useBalance } from '@lawallet/react';
import { config } from './config';
function App() {
const balance = useBalance({
pubkey: '17efe7a5f1...53936f68b',
tokenId: 'BTC',
config,
});
}Return Type
import { type UseBalanceReturns } from '@lawallet/react';balance
Returns the requested account and token balance information