useNFTBalance

Hook to get the quantity a user owns of a specific ERC1155 NFT.

Available to use on smart contracts that implement the ERC1155 standard.

Example

import { useNFTBalance, useContract } from "@thirdweb-dev/react";
function App() {
const { contract } = useContract(contractAddress);
const { isLoading, data, error } = useNFTBalance(
contract,
"{{wallet_address}}",
"{{token_id}}",
);
}
function useNFTBalance(
contract: RequiredParam<NFTContract>,
ownerWalletAddress: RequiredParam<string>,
tokenId?: RequiredParam<BigNumberish>,
): UseQueryResult<BigNumber, unknown>;

Parameters

Instance of a NFTContract

Type

let contract: RequiredParam<NFTContract>;

The wallet address to check the balance of. Use the useAddress hook to get the current wallet address.

Type

let ownerWalletAddress: RequiredParam<string>;

Required for ERC1155, the tokenId to look up

Type

let tokenId: RequiredParam<BigNumberish>;

Returns

let returnType: UseQueryResult<BigNumber, unknown>;

The hook's data property, once loaded, returns a BigNumber representing the quantity of the NFT owned by the wallet.