Skip to main content

ERC721 - Mint NFTs

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

Mint a unique NFT

Provide a metadata object to mint a unique NFT.

This function automatically uploads and pins your metadata to IPFS.

If you already have your metadata uploaded to IPFS (or any URL that points to valid metadata), you can directly pass the URI as the second argument; rather than a metadata object.

const Component = () => {
const { contract } = useContract("{{contract_address}}");
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: "{{wallet_address}}" })}
>
Mint!
</button>
);
};

This snippet is for v3 of the SDK. Learn how to upgrade.

View in React SDK Documentation