Hook to get the quantity a user owns of a specific ERC1155 NFT.
Available to use on smart contracts that implement the ERC1155 standard.
ERC1155
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>;
Instance of a NFTContract
NFTContract
let contract: RequiredParam<NFTContract>;
The wallet address to check the balance of. Use the useAddress hook to get the current wallet address.
useAddress
let ownerWalletAddress: RequiredParam<string>;
Required for ERC1155, the tokenId to look up
let tokenId: RequiredParam<BigNumberish>;
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.
data
BigNumber