Skip to main content

useMintNFT() function

This feature is currently in beta and may change based on feedback that we receive.

Use this to mint a new NFT on your NFTContract

Example 1

const Component = () => {
const nftDrop = useNFTDrop(<ContractAddress>);
const {
mutate: mintNft,
isLoading,
error,
} = useMintNFT(nftDrop);

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

return (
<button
disabled={isLoading}
onClick={() => mintNft({ name: "My awesome NFT!", to: "0x..." })}
>
Mint!
</button>
);
};

Example 2

const Component = () => {
const { contract } = useContract(<ContractAddress>);
const {
mutate: mintNft,
isLoading,
error,
} = useMintNFT(contract?.nft);

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

return (
<button
disabled={isLoading}
onClick={() => mintNft({ name: "My awesome NFT!", to: "0x..." })}
>
Mint!
</button>
);
};

Signature:

export declare function useMintNFT<TContract extends NFTContract>(
contract: RequiredParam<TContract>,
): import("@tanstack/react-query").UseMutationResult<
MintNFTReturnType<TContract>,
unknown,
MintNFTParams<TContract>,
unknown
>;

Parameters

ParameterTypeDescription
contractRequiredParam<TContract>an instance of a NFTContract

Returns:

import("@tanstack/react-query").UseMutationResult<MintNFTReturnType<TContract>, unknown, MintNFTParams<TContract>, unknown>

a mutation object that can be used to mint a new NFT token to the connected wallet