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 Erc721OrErc1155

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);

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,
unknown
>;

Parameters

ParameterTypeDescription
contractRequiredParam<TContract>an instance of a NFTContract

Returns:

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

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