Erc721WithQuantitySignatureMintable
Enables generating dynamic ERC721 NFTs with rules and an associated signature, which can then be minted by anyone securely
class Erc721WithQuantitySignatureMintable implements DetectableFeature {}
function constructor( contractWrapper: ContractWrapper<SignatureMintERC721 | TokenERC721>,
Generate a signature that can be used to mint a dynamic NFT
Takes in an NFT and some information about how it can be minted, uploads the metadata and signs it with your private key. The generated signature can then be used to mint an NFT using the exact payload and signature generated.
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)`
function generate(mintRequest: { currencyAddress?: string; metadata?: string | (objectInputType<extendShape<{ animation_url: ZodNullable<ZodOptional<ZodUnion<[ZodUnion<[..., ...]>, ZodString]>>>; description: ZodNullable<ZodOptional<ZodNullable<ZodString>>>; image: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<[..., ...]>, ZodString]>>>; name: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodNumber]>>> }, { attributes: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<ZodArray<..., ...>, Array<...>, Array<...>>, ZodArray<ZodObject<..., ..., ..., ..., ...>, "many">, ZodObject<{ }, "strip", ZodUnion<...>, objectOutputType<..., ..., ...>, objectInputType<..., ..., ...>>]>>>; background_color: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodEffects<ZodString, string, string>, ZodString]>>>; external_url: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<[..., ...]>, ZodString]>>>; properties: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<ZodArray<..., ...>, Array<...>, Array<...>>, ZodArray<ZodObject<..., ..., ..., ..., ...>, "many">, ZodObject<{ }, "strip", ZodUnion<...>, objectOutputType<..., ..., ...>, objectInputType<..., ..., ...>>]>>> }>, ZodUnion<[ZodEffects<ZodUnion<[ZodBigInt, ZodType<BigNumber, ZodTypeDef, BigNumber>, ZodType<BN, ZodTypeDef, BN>]>, string, bigint | (BN) | (BigNumber)>, ZodUnknown]>, "strip">); mintEndTime?: number | (Date); mintStartTime?: number | (Date); price?: string | number; primarySaleRecipient?: string; quantity?: string | number | bigint | (BigNumber); royaltyBps?: number; royaltyRecipient?: string; to: string; uid?: string }) : Promise<SignedPayload721WithQuantitySignature>
the payload to sign
let mintRequest: { currencyAddress?: string; metadata?: string | (objectInputType<extendShape<{ animation_url: ZodNullable<ZodOptional<ZodUnion<[ZodUnion<[..., ...]>, ZodString]>>>; description: ZodNullable<ZodOptional<ZodNullable<ZodString>>>; image: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<[..., ...]>, ZodString]>>>; name: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodNumber]>>> }, { attributes: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<ZodArray<..., ...>, Array<...>, Array<...>>, ZodArray<ZodObject<..., ..., ..., ..., ...>, "many">, ZodObject<{ }, "strip", ZodUnion<...>, objectOutputType<..., ..., ...>, objectInputType<..., ..., ...>>]>>>; background_color: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodEffects<ZodString, string, string>, ZodString]>>>; external_url: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<[..., ...]>, ZodString]>>>; properties: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<ZodArray<..., ...>, Array<...>, Array<...>>, ZodArray<ZodObject<..., ..., ..., ..., ...>, "many">, ZodObject<{ }, "strip", ZodUnion<...>, objectOutputType<..., ..., ...>, objectInputType<..., ..., ...>>]>>> }>, ZodUnion<[ZodEffects<ZodUnion<[ZodBigInt, ZodType<BigNumber, ZodTypeDef, BigNumber>, ZodType<BN, ZodTypeDef, BN>]>, string, bigint | (BN) | (BigNumber)>, ZodUnknown]>, "strip">); mintEndTime?: number | (Date); mintStartTime?: number | (Date); price?: string | number; primarySaleRecipient?: string; quantity?: string | number | bigint | (BigNumber); royaltyBps?: number; royaltyRecipient?: string; to: string; uid?: string }
The signed payload and the corresponding signature
Genrate a batch of signatures that can be used to mint many dynamic NFTs.
See Erc721WithQuantitySignatureMintable.generate
function generateBatch(payloadsToSign: Array<{ currencyAddress?: string; metadata?: string | (objectInputType<extendShape<{ animation_url: ZodNullable<ZodOptional<ZodUnion<[ZodUnion<...>, ZodString]>>>; description: ZodNullable<ZodOptional<ZodNullable<ZodString>>>; image: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<...>, ZodString]>>>; name: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodNumber]>>> }, { attributes: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<..., ..., ...>, ZodArray<..., ...>, ZodObject<..., ..., ..., ..., ...>]>>>; background_color: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodEffects<..., ..., ...>, ZodString]>>>; external_url: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<...>, ZodString]>>>; properties: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<..., ..., ...>, ZodArray<..., ...>, ZodObject<..., ..., ..., ..., ...>]>>> }>, ZodUnion<[ZodEffects<ZodUnion<[ZodBigInt, ZodType<BigNumber, ZodTypeDef, BigNumber>, ZodType<BN, ZodTypeDef, BN>]>, string, bigint | (BN) | (BigNumber)>, ZodUnknown]>, "strip">); mintEndTime?: number | (Date); mintStartTime?: number | (Date); price?: string | number; primarySaleRecipient?: string; quantity?: string | number | bigint | (BigNumber); royaltyBps?: number; royaltyRecipient?: string; to: string; uid?: string }>) : Promise<Array<SignedPayload721WithQuantitySignature>>
the payloads to sign
let payloadsToSign: Array<{ currencyAddress?: string; metadata?: string | (objectInputType<extendShape<{ animation_url: ZodNullable<ZodOptional<ZodUnion<[ZodUnion<...>, ZodString]>>>; description: ZodNullable<ZodOptional<ZodNullable<ZodString>>>; image: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<...>, ZodString]>>>; name: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodNumber]>>> }, { attributes: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<..., ..., ...>, ZodArray<..., ...>, ZodObject<..., ..., ..., ..., ...>]>>>; background_color: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodEffects<..., ..., ...>, ZodString]>>>; external_url: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<...>, ZodString]>>>; properties: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<..., ..., ...>, ZodArray<..., ...>, ZodObject<..., ..., ..., ..., ...>]>>> }>, ZodUnion<[ZodEffects<ZodUnion<[ZodBigInt, ZodType<BigNumber, ZodTypeDef, BigNumber>, ZodType<BN, ZodTypeDef, BN>]>, string, bigint | (BN) | (BigNumber)>, ZodUnknown]>, "strip">); mintEndTime?: number | (Date); mintStartTime?: number | (Date); price?: string | number; primarySaleRecipient?: string; quantity?: string | number | bigint | (BigNumber); royaltyBps?: number; royaltyRecipient?: string; to: string; uid?: string }>
An array of payloads and signatures
Verify that a payload is correctly signed
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 you can verify if the signed payload is validconst isValid = await contract.erc721.signature.verify(signedPayload);
function verify(): Promise<boolean>;
function mint(): Promise<TResult>;
Preparable
You can also prepare the transaction without executing it by calling mint.prepare()
with same arguments. Learn more
function mintBatch(): Promise<TResult>;
Preparable
You can also prepare the transaction without executing it by calling mintBatch.prepare()
with same arguments. Learn more