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.
The generation of signatures requires the wallet to have the MINTER
role on the contract by default.
- React
- Javascript
- Python
- Go
- Unity
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 Documentationconst 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 Javascript SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Python SDK documentation for more information.
Reach out on Discord for further assistance!
View Python SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Go SDK documentation for more information.
Reach out on Discord for further assistance!
View Go SDK Documentationvar meta = new NFTMetadata()
{
name = "Unity NFT",
description = "Minted From Unity (signature)",
image = "ipfs://QmbpciV7R5SSPb6aT9kEBAxoYoXBUsStJkMpxzymV4ZcVc"
};
string connectedAddress = await sdk.wallet.GetAddress();
var payload = new ERC721MintPayload(connectedAddress, meta);
var signature = await contract.ERC721.signature.Generate(payload); // typically generated on the backend
Use a signature to mint an NFT
Mint an NFT using a previously generated signature.
- React
- Javascript
- Python
- Go
- Unity
// 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// 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 Javascript SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Python SDK documentation for more information.
Reach out on Discord for further assistance!
View Python SDK DocumentationThis feature is missing a code snippet or might not be supported yet.
Check the Go SDK documentation for more information.
Reach out on Discord for further assistance!
View Go SDK Documentation// Provide the signature you generated above to the Mint function:
var result = await contract.ERC721.signature.Mint(signature);