Skip to main content

ERC1155 Standard

You can utilize these features of the SDK if your contract implements the ERC1155 standard.

View NFT Balance

Get a wallet's NFT balance (number of NFTs in this contract owned by the wallet) for a specific token ID.

const { contract } = useContract(<ContractAddress>);
const { data: ownerBalance, isLoading, error } = useNFTBalance(contract, <OwnerWalletAddress>);
View in React SDK Documentation

Get NFT Metadata

Read the URI this NFT points to and fetch that data automatically.

If the metadata is stored on IPFS, this function uses our IPFS gateway (or the one you specify) to read the data.

const { contract } = useContract(<ContractAddress>);
const { data: nft, isLoading, error } = useNFT(contract, <tokenId>);
View in React SDK Documentation

Transfer NFTs

Transfer an NFT from the connected wallet to another wallet.

const Component = () => {
const { contract } = useContract(<ContractAddress>);
const {
mutate: transferNFT,
isLoading,
error,
} = useTransferNFT(contract);

if (error) {
console.error("failed to transfer nft", error);
}

return (
<button
disabled={isLoading}
onClick={() => transferNFT({ to: "0x...", tokenId: 2 })}
>
Transfer
</button>
);
};
View in React SDK Documentation

Airdrop NFTs

Transfer NFTs to a list of wallets in one transaction.

const Component = () => {
const { contract } = useContract(<ContractAddress>);
const {
mutate: airdropNFT,
isLoading,
error,
} = useAirdropNFT(contract);

if (error) {
console.error("failed to transfer batch NFTs", error);
}

return (
<button
disabled={isLoading}
onClick={() => airdropNFT({
tokenId: 2,
addresses: [{ address: "0x...", quantity: 2 }, { address: "0x...", quantity: 4 } }]
)}
>
Airdrop NFT
</button>
);
};
View in React SDK Documentation