This repository has been archived by the owner on Jan 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new hook: useBalanceForAddress (#1098)
* Add hook: useBalanceForAddress * Update
- Loading branch information
Showing
3 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0627d34
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
docs – ./
docs-chi-eight.vercel.app
docs.thirdweb.com
docs-git-main.thirdweb-preview.com
portal.thirdweb.com
docs.thirdweb-preview.com