useOwnedNFTs
Hook for accessing a list of NFTs owned by a single wallet address.
Available to use on smart contracts that implement either ERC721Enumerable, ERC1155Enumerable, or ERC721Supply extensions.
import { useOwnedNFTs } from "@thirdweb-dev/react";
const { data, isLoading, error } = useOwnedNFTs(contract, "{{wallet_address}}");
Usage
Provide your NFT collection contract and a wallet address as the arguments.
import { useOwnedNFTs, useContract, useAddress } from "@thirdweb-dev/react";
// Your smart contract address
const contractAddress = "{{contract_address}}";
function App() {
const address = useAddress();
const { contract } = useContract(contractAddress);
const { data, isLoading, error } = useOwnedNFTs(contract, address);
}
Configuration
ownerWalletAddress
ownerWalletAddress (required)
The wallet address you want to query for.
Likely, you will want to view the connected wallet’s NFTs.
se the useAddress
hook to get this value.
import { useOwnedNFTs, useContract, useAddress } from "@thirdweb-dev/react";
// Your smart contract address
const contractAddress = "{{contract_address}}";
function App() {
const address = useAddress();
const { contract } = useContract(contractAddress);
const { data, isLoading, error } = useOwnedNFTs(
contract,
address,
);
}
Return Value
Return Value
The hook's data
property, once loaded, contains an array of NFT
objects, each containing the following properties:
{
metadata: {
id: string;
uri: string;
name?: string | number | undefined;
description?: string | null | undefined;
image?: string | null | undefined;
external_url?: string | null | undefined;
animation_url?: string | null | undefined;
background_color?: string | undefined;
properties?: {
[x: string]: unknown;
} | {
[x: string]: unknown;
}[] | undefined;
};
owner: string;
type: "ERC1155" | "ERC721";
supply: number;
quantityOwned?: number; // Only available for ERC1155
}[];