Skip to main content

ERC721 Signature-Based Minting

Use signature-based minting of NFTs in your smart contract.

You can utilize these features of the SDK on your contract if it implements SignatureMintERC721.

Generate a signature

Generate a signature that can be utilized to mint an NFT by another wallet.

The signature specifies any information about the NFT such as the metadata and price.

Admin Operation

The generation of signatures requires the wallet to have the MINTER role on the contract by default.

const nftMetadata = {
name: "Cool NFT #1",
description: "This is a cool NFT",
image: fs.readFileSync("path/to/image.png"), // This can be an image url or file
};

const startTime = new Date();
const endTime = new Date(Date.now() + 60 * 60 * 24 * 1000);
const payload = {
metadata: nftMetadata, // The NFT to mint
to: {{wallet_address}}, // Who will receive the NFT
quantity: 2, // the quantity of NFTs to mint
price: 0.5, // the price per NFT
currencyAddress: NATIVE_TOKEN_ADDRESS, // the currency to pay with
mintStartTime: startTime, // can mint anytime from now
mintEndTime: endTime, // to 24h from now
royaltyRecipient: "0x...", // custom royalty recipient for this NFT
royaltyBps: 100, // custom royalty fees for this NFT (in bps)
primarySaleRecipient: "0x...", // custom sale recipient for this NFT
};

const signedPayload = await contract.erc721.signature.generate(payload);
// now anyone can use these to mint the NFT using `contract.erc721.signature.mint(signedPayload)`

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

View in React SDK Documentation

Use a signature to mint an NFT

Mint an NFT using a previously generated signature.

// see how to craft a payload to sign in the `generate()` documentation
const signedPayload = contract.erc721.signature.generate(payload);

// now anyone can mint the NFT
const tx = contract.erc721.signature.mint(signedPayload);
const receipt = tx.receipt; // the mint transaction receipt
const mintedId = tx.id; // the id of the NFT minted

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

View in React SDK Documentation