diff --git a/docs/react/hooks/token/usebalance.mdx b/docs/react/hooks/token/usebalance.mdx index 1994176f9e..dcc4c9a55d 100644 --- a/docs/react/hooks/token/usebalance.mdx +++ b/docs/react/hooks/token/usebalance.mdx @@ -4,7 +4,7 @@ slug: /react.usebalance displayed_sidebar: react --- -Hook for getting a wallet's current balance of an ERC20 token, (including native tokens such as Ether). +Hook for getting the connected wallet's current balance of an ERC20 token, (including native tokens such as Ether). ```jsx import { useBalance } from "@thirdweb-dev/react"; diff --git a/docs/react/hooks/token/usebalanceforaddress.mdx b/docs/react/hooks/token/usebalanceforaddress.mdx new file mode 100644 index 0000000000..268bd09092 --- /dev/null +++ b/docs/react/hooks/token/usebalanceforaddress.mdx @@ -0,0 +1,41 @@ +--- +title: useBalanceForAddress +slug: /react.usebalanceforaddress +displayed_sidebar: react +--- + +This hook is similar to the [useBalance](/react/react.usebalance) hook, however it takes in a mandatory `walletAddress` parameter. +This hook only fetches the native token balance of the given address and does not work with ERC20 tokens. If you want to get the ERC20 balance from a given wallet, use [useTokenBalance](/react/react.usetokenbalance) + +```jsx +import { useBalanceForAddress } from "@thirdweb-dev/react"; +``` + +## Usage + +Provide the wallet address as the argument. + +```jsx +import { useBalanceForAddress } from "@thirdweb-dev/react"; + +// The EVM wallet address that you want to fetch info from +const walletAddress = "{{wallet_address}}"; + +function App() { + const { data, isLoading } = useBalanceForAddress(walletAddress); +} +``` + +## Return Value + +The hook's `data` property, once loaded, contains the following properties: + +```ts +{ + symbol: string; + value: BigNumber; + name: string; + decimals: number; + displayValue: string; +} | undefined>; +``` diff --git a/docs/react/hooks/token/usetokenbalance.mdx b/docs/react/hooks/token/usetokenbalance.mdx index 35d8b17e4d..7a55f68000 100644 --- a/docs/react/hooks/token/usetokenbalance.mdx +++ b/docs/react/hooks/token/usetokenbalance.mdx @@ -10,7 +10,7 @@ import CodeBlock from "@theme/CodeBlock"; Hook for fetching the balance a wallet has for a specific ERC20 token. -_Note: This hook is for **custom** ERC20 tokens. For native tokens such as Ether, use [useBalance](/react/react.usebalance) instead._ +_Note: This hook is for **custom** ERC20 tokens. For native tokens such as Ether, use [useBalance](/react/react.usebalance) or [useBalanceForAddress](/react/react.usebalanceforaddress) instead._ Available to use on contracts that implement the [ERC20](/solidity/extensions/erc20) interface.